From 11adb2a02c61890c0fbe5231cede16880ccd369b Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sat, 22 Dec 2001 21:46:13 +0000 Subject: [PATCH] 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 --- .../org/apache/tools/ant/taskdefs/Java.java | 3 +- .../tools/ant/taskdefs/exec/ExecTask.java | 3 +- .../optional/ejb/WebsphereDeploymentTool.java | 3 +- .../taskdefs/optional/junit/JUnitTask.java | 3 +- .../tools/ant/types/CommandlineJava.java | 4 +- .../tools/ant/types/EnvironmentData.java | 39 +--------------- .../tools/ant/types/EnvironmentVariable.java | 46 +++++++++++++++++++ .../org/apache/tools/ant/taskdefs/Java.java | 3 +- .../tools/ant/taskdefs/exec/ExecTask.java | 3 +- .../optional/ejb/WebsphereDeploymentTool.java | 3 +- .../taskdefs/optional/junit/JUnitTask.java | 3 +- .../tools/ant/types/CommandlineJava.java | 4 +- .../tools/ant/types/EnvironmentData.java | 39 +--------------- .../tools/ant/types/EnvironmentVariable.java | 46 +++++++++++++++++++ 14 files changed, 116 insertions(+), 86 deletions(-) create mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentVariable.java create mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentVariable.java diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java index 7c8c9375f..f95200d5c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -23,6 +23,7 @@ import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; 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 @@ -166,7 +167,7 @@ public class Java extends Task * * @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 ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java index 65ac9cbc7..a2253b448 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java @@ -21,6 +21,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnvironmentData; +import org.apache.tools.ant.types.EnvironmentVariable; /** * 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 */ - public void addEnv( EnvironmentData.Variable var ) + public void addEnv( EnvironmentVariable var ) { env.addVariable( var ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java index fb7feeb0d..07ba2f48c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java @@ -24,6 +24,7 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.EnvironmentVariable; /** * Websphere deployment tool that augments the ejbjar task. @@ -966,7 +967,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool // Set the EnvironmentData variable - EnvironmentData.Variable var = new EnvironmentData.Variable(); + EnvironmentVariable var = new EnvironmentVariable(); var.setKey( "websphere.lib.dir" ); var.setValue( getTask().getProject().getProperty( "websphere.home" ) + "/lib" ); javaTask.addSysproperty( var ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 3aabbc1fb..ade21f89b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -30,6 +30,7 @@ import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.EnvironmentVariable; /** * Ant task to run JUnit tests.

@@ -319,7 +320,7 @@ public class JUnitTask extends Task * * @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 ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java index dd5b5bccb..75f014581 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -189,7 +189,7 @@ public class CommandlineJava implements Cloneable return vmVersion; } - public void addSysproperty( EnvironmentData.Variable sysp ) + public void addSysproperty( EnvironmentVariable sysp ) { sysProperties.addVariable( sysp ); } @@ -341,7 +341,7 @@ public class CommandlineJava implements Cloneable 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() ); } System.setProperties( p ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java index 126545ec0..9dc427a3b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java @@ -28,50 +28,15 @@ public class EnvironmentData final int size = m_variables.size(); 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() ); } return environment; } - public void addVariable( Variable var ) + public void addVariable( EnvironmentVariable 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; - } - } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentVariable.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentVariable.java new file mode 100644 index 000000000..f389dc3e1 --- /dev/null +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentVariable.java @@ -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; + } +} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java index 7c8c9375f..f95200d5c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java @@ -23,6 +23,7 @@ import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; 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 @@ -166,7 +167,7 @@ public class Java extends Task * * @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 ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java index 65ac9cbc7..a2253b448 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java @@ -21,6 +21,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnvironmentData; +import org.apache.tools.ant.types.EnvironmentVariable; /** * 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 */ - public void addEnv( EnvironmentData.Variable var ) + public void addEnv( EnvironmentVariable var ) { env.addVariable( var ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java index fb7feeb0d..07ba2f48c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java @@ -24,6 +24,7 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.EnvironmentVariable; /** * Websphere deployment tool that augments the ejbjar task. @@ -966,7 +967,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool // Set the EnvironmentData variable - EnvironmentData.Variable var = new EnvironmentData.Variable(); + EnvironmentVariable var = new EnvironmentVariable(); var.setKey( "websphere.lib.dir" ); var.setValue( getTask().getProject().getProperty( "websphere.home" ) + "/lib" ); javaTask.addSysproperty( var ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 3aabbc1fb..ade21f89b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -30,6 +30,7 @@ import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.EnvironmentVariable; /** * Ant task to run JUnit tests.

@@ -319,7 +320,7 @@ public class JUnitTask extends Task * * @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 ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java index dd5b5bccb..75f014581 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java @@ -189,7 +189,7 @@ public class CommandlineJava implements Cloneable return vmVersion; } - public void addSysproperty( EnvironmentData.Variable sysp ) + public void addSysproperty( EnvironmentVariable sysp ) { sysProperties.addVariable( sysp ); } @@ -341,7 +341,7 @@ public class CommandlineJava implements Cloneable 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() ); } System.setProperties( p ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java index 126545ec0..9dc427a3b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java @@ -28,50 +28,15 @@ public class EnvironmentData final int size = m_variables.size(); 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() ); } return environment; } - public void addVariable( Variable var ) + public void addVariable( EnvironmentVariable 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; - } - } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentVariable.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentVariable.java new file mode 100644 index 000000000..f389dc3e1 --- /dev/null +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentVariable.java @@ -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; + } +}