Browse Source

Moved ENvironment.Variable to a top level class.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270321 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
11adb2a02c
14 changed files with 116 additions and 86 deletions
  1. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java
  2. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java
  3. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
  4. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  5. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java
  6. +2
    -37
      proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java
  7. +46
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentVariable.java
  8. +2
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java
  9. +2
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java
  10. +2
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
  11. +2
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  12. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java
  13. +2
    -37
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java
  14. +46
    -0
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentVariable.java

+ 2
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -23,6 +23,7 @@ import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* This task acts as a loader for java applications but allows to use the same * This task acts as a loader for java applications but allows to use the same
@@ -166,7 +167,7 @@ public class Java extends Task
* *
* @param sysp The feature to be added to the Sysproperty attribute * @param sysp The feature to be added to the Sysproperty attribute
*/ */
public void addSysproperty( EnvironmentData.Variable sysp )
public void addSysproperty( EnvironmentVariable sysp )
{ {
cmdl.addSysproperty( sysp ); cmdl.addSysproperty( sysp );
} }


+ 2
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java View File

@@ -21,6 +21,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* Executes a given command if the os platform is appropriate. * Executes a given command if the os platform is appropriate.
@@ -175,7 +176,7 @@ public class ExecTask extends Task
* *
* @param var The feature to be added to the Env attribute * @param var The feature to be added to the Env attribute
*/ */
public void addEnv( EnvironmentData.Variable var )
public void addEnv( EnvironmentVariable var )
{ {
env.addVariable( var ); env.addVariable( var );
} }


+ 2
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java View File

@@ -24,6 +24,7 @@ import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* Websphere deployment tool that augments the ejbjar task. * Websphere deployment tool that augments the ejbjar task.
@@ -966,7 +967,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool


// Set the EnvironmentData variable // Set the EnvironmentData variable


EnvironmentData.Variable var = new EnvironmentData.Variable();
EnvironmentVariable var = new EnvironmentVariable();
var.setKey( "websphere.lib.dir" ); var.setKey( "websphere.lib.dir" );
var.setValue( getTask().getProject().getProperty( "websphere.home" ) + "/lib" ); var.setValue( getTask().getProject().getProperty( "websphere.home" ) + "/lib" );
javaTask.addSysproperty( var ); javaTask.addSysproperty( var );


+ 2
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -30,6 +30,7 @@ import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* Ant task to run JUnit tests. <p> * Ant task to run JUnit tests. <p>
@@ -319,7 +320,7 @@ public class JUnitTask extends Task
* *
* @param sysp The feature to be added to the Sysproperty attribute * @param sysp The feature to be added to the Sysproperty attribute
*/ */
public void addSysproperty( EnvironmentData.Variable sysp )
public void addSysproperty( EnvironmentVariable sysp )
{ {
commandline.addSysproperty( sysp ); commandline.addSysproperty( sysp );
} }


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java View File

@@ -189,7 +189,7 @@ public class CommandlineJava implements Cloneable
return vmVersion; return vmVersion;
} }


public void addSysproperty( EnvironmentData.Variable sysp )
public void addSysproperty( EnvironmentVariable sysp )
{ {
sysProperties.addVariable( sysp ); sysProperties.addVariable( sysp );
} }
@@ -341,7 +341,7 @@ public class CommandlineJava implements Cloneable


for( Iterator e = m_variables.iterator(); e.hasNext(); ) for( Iterator e = m_variables.iterator(); e.hasNext(); )
{ {
EnvironmentData.Variable v = (EnvironmentData.Variable)e.next();
EnvironmentVariable v = (EnvironmentVariable)e.next();
p.put( v.getKey(), v.getValue() ); p.put( v.getKey(), v.getValue() );
} }
System.setProperties( p ); System.setProperties( p );


+ 2
- 37
proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java View File

@@ -28,50 +28,15 @@ public class EnvironmentData
final int size = m_variables.size(); final int size = m_variables.size();
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
final Variable variable = (Variable)m_variables.get( i );
final EnvironmentVariable variable = (EnvironmentVariable)m_variables.get( i );
environment.setProperty( variable.getKey(), variable.getValue() ); environment.setProperty( variable.getKey(), variable.getValue() );
} }
return environment; return environment;
} }


public void addVariable( Variable var )
public void addVariable( EnvironmentVariable var )
{ {
m_variables.add( var ); m_variables.add( var );
} }


public static class Variable
{
private String m_key;
private String m_value;

public void setFile( final File file )
{
m_value = file.getAbsolutePath();
}

public void setKey( final String key )
{
m_key = key;
}

public void setPath( final Path path )
{
m_value = path.toString();
}

public void setValue( final String value )
{
m_value = value;
}

public String getKey()
{
return m_key;
}

public String getValue()
{
return m_value;
}
}
} }

+ 46
- 0
proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentVariable.java View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.types;

import java.io.File;

public class EnvironmentVariable
{
private String m_key;
private String m_value;

public void setFile( final File file )
{
m_value = file.getAbsolutePath();
}

public void setKey( final String key )
{
m_key = key;
}

public void setPath( final Path path )
{
m_value = path.toString();
}

public void setValue( final String value )
{
m_value = value;
}

public String getKey()
{
return m_key;
}

public String getValue()
{
return m_value;
}
}

+ 2
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java View File

@@ -23,6 +23,7 @@ import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* This task acts as a loader for java applications but allows to use the same * This task acts as a loader for java applications but allows to use the same
@@ -166,7 +167,7 @@ public class Java extends Task
* *
* @param sysp The feature to be added to the Sysproperty attribute * @param sysp The feature to be added to the Sysproperty attribute
*/ */
public void addSysproperty( EnvironmentData.Variable sysp )
public void addSysproperty( EnvironmentVariable sysp )
{ {
cmdl.addSysproperty( sysp ); cmdl.addSysproperty( sysp );
} }


+ 2
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java View File

@@ -21,6 +21,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* Executes a given command if the os platform is appropriate. * Executes a given command if the os platform is appropriate.
@@ -175,7 +176,7 @@ public class ExecTask extends Task
* *
* @param var The feature to be added to the Env attribute * @param var The feature to be added to the Env attribute
*/ */
public void addEnv( EnvironmentData.Variable var )
public void addEnv( EnvironmentVariable var )
{ {
env.addVariable( var ); env.addVariable( var );
} }


+ 2
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java View File

@@ -24,6 +24,7 @@ import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* Websphere deployment tool that augments the ejbjar task. * Websphere deployment tool that augments the ejbjar task.
@@ -966,7 +967,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool


// Set the EnvironmentData variable // Set the EnvironmentData variable


EnvironmentData.Variable var = new EnvironmentData.Variable();
EnvironmentVariable var = new EnvironmentVariable();
var.setKey( "websphere.lib.dir" ); var.setKey( "websphere.lib.dir" );
var.setValue( getTask().getProject().getProperty( "websphere.home" ) + "/lib" ); var.setValue( getTask().getProject().getProperty( "websphere.home" ) + "/lib" );
javaTask.addSysproperty( var ); javaTask.addSysproperty( var );


+ 2
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -30,6 +30,7 @@ import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentData;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.EnvironmentVariable;


/** /**
* Ant task to run JUnit tests. <p> * Ant task to run JUnit tests. <p>
@@ -319,7 +320,7 @@ public class JUnitTask extends Task
* *
* @param sysp The feature to be added to the Sysproperty attribute * @param sysp The feature to be added to the Sysproperty attribute
*/ */
public void addSysproperty( EnvironmentData.Variable sysp )
public void addSysproperty( EnvironmentVariable sysp )
{ {
commandline.addSysproperty( sysp ); commandline.addSysproperty( sysp );
} }


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java View File

@@ -189,7 +189,7 @@ public class CommandlineJava implements Cloneable
return vmVersion; return vmVersion;
} }


public void addSysproperty( EnvironmentData.Variable sysp )
public void addSysproperty( EnvironmentVariable sysp )
{ {
sysProperties.addVariable( sysp ); sysProperties.addVariable( sysp );
} }
@@ -341,7 +341,7 @@ public class CommandlineJava implements Cloneable


for( Iterator e = m_variables.iterator(); e.hasNext(); ) for( Iterator e = m_variables.iterator(); e.hasNext(); )
{ {
EnvironmentData.Variable v = (EnvironmentData.Variable)e.next();
EnvironmentVariable v = (EnvironmentVariable)e.next();
p.put( v.getKey(), v.getValue() ); p.put( v.getKey(), v.getValue() );
} }
System.setProperties( p ); System.setProperties( p );


+ 2
- 37
proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java View File

@@ -28,50 +28,15 @@ public class EnvironmentData
final int size = m_variables.size(); final int size = m_variables.size();
for( int i = 0; i < size; i++ ) for( int i = 0; i < size; i++ )
{ {
final Variable variable = (Variable)m_variables.get( i );
final EnvironmentVariable variable = (EnvironmentVariable)m_variables.get( i );
environment.setProperty( variable.getKey(), variable.getValue() ); environment.setProperty( variable.getKey(), variable.getValue() );
} }
return environment; return environment;
} }


public void addVariable( Variable var )
public void addVariable( EnvironmentVariable var )
{ {
m_variables.add( var ); m_variables.add( var );
} }


public static class Variable
{
private String m_key;
private String m_value;

public void setFile( final File file )
{
m_value = file.getAbsolutePath();
}

public void setKey( final String key )
{
m_key = key;
}

public void setPath( final Path path )
{
m_value = path.toString();
}

public void setValue( final String value )
{
m_value = value;
}

public String getKey()
{
return m_key;
}

public String getValue()
{
return m_value;
}
}
} }

+ 46
- 0
proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentVariable.java View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.types;

import java.io.File;

public class EnvironmentVariable
{
private String m_key;
private String m_value;

public void setFile( final File file )
{
m_value = file.getAbsolutePath();
}

public void setKey( final String key )
{
m_key = key;
}

public void setPath( final Path path )
{
m_value = path.toString();
}

public void setValue( final String value )
{
m_value = value;
}

public String getKey()
{
return m_key;
}

public String getValue()
{
return m_value;
}
}

Loading…
Cancel
Save