git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270322 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -20,6 +20,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.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Mapper; | import org.apache.tools.ant.types.Mapper; | ||||
| import org.apache.tools.ant.types.Marker; | |||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | import org.apache.tools.ant.util.SourceFileScanner; | ||||
| @@ -36,9 +37,9 @@ public class ExecuteOn extends ExecTask | |||||
| private boolean relative = false; | private boolean relative = false; | ||||
| private boolean parallel = false; | private boolean parallel = false; | ||||
| protected String type = "file"; | protected String type = "file"; | ||||
| protected Commandline.Marker srcFilePos = null; | |||||
| protected Marker srcFilePos = null; | |||||
| private boolean skipEmpty = false; | private boolean skipEmpty = false; | ||||
| protected Commandline.Marker targetFilePos = null; | |||||
| protected Marker targetFilePos = null; | |||||
| protected Mapper mapperElement = null; | protected Mapper mapperElement = null; | ||||
| protected FileNameMapper mapper = null; | protected FileNameMapper mapper = null; | ||||
| protected File destDir = null; | protected File destDir = null; | ||||
| @@ -132,7 +133,7 @@ public class ExecuteOn extends ExecTask | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Marker createSrcfile() | |||||
| public Marker createSrcfile() | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( srcFilePos != null ) | if( srcFilePos != null ) | ||||
| @@ -149,7 +150,7 @@ public class ExecuteOn extends ExecTask | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Marker createTargetfile() | |||||
| public Marker createTargetfile() | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( targetFilePos != null ) | if( targetFilePos != null ) | ||||
| @@ -24,6 +24,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * 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 | ||||
| @@ -185,7 +186,7 @@ public class Java extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createArg() | |||||
| public Argument createArg() | |||||
| { | { | ||||
| return cmdl.createArgument(); | return cmdl.createArgument(); | ||||
| } | } | ||||
| @@ -206,7 +207,7 @@ public class Java extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdl.createVmArgument(); | return cmdl.createVmArgument(); | ||||
| } | } | ||||
| @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| 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.Argument; | |||||
| import org.apache.tools.ant.util.GlobPatternMapper; | import org.apache.tools.ant.util.GlobPatternMapper; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | import org.apache.tools.ant.util.SourceFileScanner; | ||||
| @@ -914,7 +915,7 @@ public class Javac extends MatchingTask | |||||
| * @author RT | * @author RT | ||||
| */ | */ | ||||
| public class ImplementationSpecificArgument | public class ImplementationSpecificArgument | ||||
| extends Commandline.Argument | |||||
| extends Argument | |||||
| { | { | ||||
| private String impl; | private String impl; | ||||
| @@ -22,6 +22,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Executes a given command if the os platform is appropriate. | * Executes a given command if the os platform is appropriate. | ||||
| @@ -186,7 +187,7 @@ public class ExecTask extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createArg() | |||||
| public Argument createArg() | |||||
| { | { | ||||
| return cmdl.createArgument(); | return cmdl.createArgument(); | ||||
| } | } | ||||
| @@ -21,6 +21,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * ANTLR task. | * ANTLR task. | ||||
| @@ -104,7 +105,7 @@ public class ANTLR extends Task | |||||
| * the JVM. | * the JVM. | ||||
| * @see #setFork(boolean) | * @see #setFork(boolean) | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return commandline.createVmArgument(); | return commandline.createVmArgument(); | ||||
| } | } | ||||
| @@ -23,6 +23,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; | |||||
| import org.apache.tools.ant.taskdefs.exec.ExecuteStreamHandler; | import org.apache.tools.ant.taskdefs.exec.ExecuteStreamHandler; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and | * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and | ||||
| @@ -491,7 +492,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exec | |||||
| javaTask = (Java)getTask().getProject().createTask( "java" ); | javaTask = (Java)getTask().getProject().createTask( "java" ); | ||||
| javaTask.setClassname( VERIFY ); | javaTask.setClassname( VERIFY ); | ||||
| Commandline.Argument arguments = javaTask.createArg(); | |||||
| Argument arguments = javaTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| Path classpath = getCombinedClasspath(); | Path classpath = getCombinedClasspath(); | ||||
| if( classpath != null ) | if( classpath != null ) | ||||
| @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Build a serialised deployment descriptor given a text file description of the | * Build a serialised deployment descriptor given a text file description of the | ||||
| @@ -122,7 +123,7 @@ public class DDCreator extends MatchingTask | |||||
| Java ddCreatorTask = (Java)getProject().createTask( "java" ); | Java ddCreatorTask = (Java)getProject().createTask( "java" ); | ||||
| ddCreatorTask.setFork( true ); | ddCreatorTask.setFork( true ); | ||||
| ddCreatorTask.setClassname( "org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper" ); | ddCreatorTask.setClassname( "org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper" ); | ||||
| Commandline.Argument arguments = ddCreatorTask.createArg(); | |||||
| Argument arguments = ddCreatorTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| ddCreatorTask.setClasspath( new Path( getProject(), execClassPath ) ); | ddCreatorTask.setClasspath( new Path( getProject(), execClassPath ) ); | ||||
| if( ddCreatorTask.executeJava() != 0 ) | if( ddCreatorTask.executeJava() != 0 ) | ||||
| @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Build EJB support classes using Weblogic's ejbc tool from a directory | * Build EJB support classes using Weblogic's ejbc tool from a directory | ||||
| @@ -181,7 +182,7 @@ public class Ejbc extends MatchingTask | |||||
| args += " " + files[ i ]; | args += " " + files[ i ]; | ||||
| } | } | ||||
| Commandline.Argument arguments = helperTask.createArg(); | |||||
| Argument arguments = helperTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| helperTask.setClasspath( new Path( getProject(), execClassPath ) ); | helperTask.setClasspath( new Path( getProject(), execClassPath ) ); | ||||
| if( helperTask.executeJava() != 0 ) | if( helperTask.executeJava() != 0 ) | ||||
| @@ -25,6 +25,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Websphere deployment tool that augments the ejbjar task. | * Websphere deployment tool that augments the ejbjar task. | ||||
| @@ -982,7 +983,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool | |||||
| // Set the Java class name | // Set the Java class name | ||||
| javaTask.setClassname( "com.ibm.etools.ejbdeploy.EJBDeploy" ); | javaTask.setClassname( "com.ibm.etools.ejbdeploy.EJBDeploy" ); | ||||
| Commandline.Argument arguments = javaTask.createArg(); | |||||
| Argument arguments = javaTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| Path classpath = wasClasspath; | Path classpath = wasClasspath; | ||||
| if( classpath == null ) | if( classpath == null ) | ||||
| @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Taskdef for the JJTree compiler compiler. | * Taskdef for the JJTree compiler compiler. | ||||
| @@ -180,7 +181,7 @@ public class JJTree extends Task | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| final Commandline.Argument arg = cmdl.createVmArgument(); | |||||
| final Argument arg = cmdl.createVmArgument(); | |||||
| arg.setValue( "-mx140M" ); | arg.setValue( "-mx140M" ); | ||||
| arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Taskdef for the JavaCC compiler compiler. | * Taskdef for the JavaCC compiler compiler. | ||||
| @@ -230,7 +231,7 @@ public class JavaCC extends Task | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| final Commandline.Argument arg = cmdl.createVmArgument(); | |||||
| final Argument arg = cmdl.createVmArgument(); | |||||
| arg.setValue( "-mx140M" ); | arg.setValue( "-mx140M" ); | ||||
| arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -23,6 +23,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.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.Argument; | |||||
| /** | /** | ||||
| * Ant task to run JDepend tests. <p> | * Ant task to run JDepend tests. <p> | ||||
| @@ -219,7 +220,7 @@ public class JDependTask extends Task | |||||
| * the JVM. | * the JVM. | ||||
| * @see #setFork(boolean) | * @see #setFork(boolean) | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg( CommandlineJava commandline ) | |||||
| public Argument createJvmarg( CommandlineJava commandline ) | |||||
| { | { | ||||
| return commandline.createVmArgument(); | return commandline.createVmArgument(); | ||||
| } | } | ||||
| @@ -31,6 +31,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Ant task to run JUnit tests. <p> | * Ant task to run JUnit tests. <p> | ||||
| @@ -367,7 +368,7 @@ public class JUnitTask extends Task | |||||
| * the JVM. | * the JVM. | ||||
| * @see #setFork(boolean) | * @see #setFork(boolean) | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return commandline.createVmArgument(); | return commandline.createVmArgument(); | ||||
| } | } | ||||
| @@ -25,6 +25,7 @@ import org.apache.tools.ant.types.Commandline; | |||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Somewhat abstract framework to be used for other metama 2.0 tasks. This | * Somewhat abstract framework to be used for other metama 2.0 tasks. This | ||||
| @@ -169,7 +170,7 @@ public abstract class AbstractMetamataTask extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdl.createVmArgument(); | return cmdl.createVmArgument(); | ||||
| } | } | ||||
| @@ -226,7 +227,7 @@ public abstract class AbstractMetamataTask extends Task | |||||
| classPath.createPathElement().setLocation( jar ); | classPath.createPathElement().setLocation( jar ); | ||||
| // set the metamata.home property | // set the metamata.home property | ||||
| final Commandline.Argument vmArgs = cmdl.createVmArgument(); | |||||
| final Argument vmArgs = cmdl.createVmArgument(); | |||||
| vmArgs.setValue( "-Dmetamata.home=" + metamataHome.getAbsolutePath() ); | vmArgs.setValue( "-Dmetamata.home=" + metamataHome.getAbsolutePath() ); | ||||
| // retrieve all the files we want to scan | // retrieve all the files we want to scan | ||||
| @@ -237,7 +238,7 @@ public abstract class AbstractMetamataTask extends Task | |||||
| ArrayList options = getOptions(); | ArrayList options = getOptions(); | ||||
| optionsFile = createTmpFile(); | optionsFile = createTmpFile(); | ||||
| generateOptionsFile( optionsFile, options ); | generateOptionsFile( optionsFile, options ); | ||||
| Commandline.Argument args = cmdl.createArgument(); | |||||
| Argument args = cmdl.createArgument(); | |||||
| args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | ||||
| } | } | ||||
| @@ -22,6 +22,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Simple Metamata MParse task based on the original written by <a | * Simple Metamata MParse task based on the original written by <a | ||||
| @@ -160,7 +161,7 @@ public class MParse extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdl.createVmArgument(); | return cmdl.createVmArgument(); | ||||
| } | } | ||||
| @@ -218,14 +219,14 @@ public class MParse extends Task | |||||
| } | } | ||||
| // set the metamata.home property | // set the metamata.home property | ||||
| final Commandline.Argument vmArgs = cmdl.createVmArgument(); | |||||
| final Argument vmArgs = cmdl.createVmArgument(); | |||||
| vmArgs.setValue( "-Dmetamata.home=" + metahome.getAbsolutePath() ); | vmArgs.setValue( "-Dmetamata.home=" + metahome.getAbsolutePath() ); | ||||
| // write all the options to a temp file and use it ro run the process | // write all the options to a temp file and use it ro run the process | ||||
| String[] options = getOptions(); | String[] options = getOptions(); | ||||
| optionsFile = createTmpFile(); | optionsFile = createTmpFile(); | ||||
| generateOptionsFile( optionsFile, options ); | generateOptionsFile( optionsFile, options ); | ||||
| Commandline.Argument args = cmdl.createArgument(); | |||||
| Argument args = cmdl.createArgument(); | |||||
| args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | ||||
| } | } | ||||
| @@ -25,6 +25,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.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Convenient task to run Sitraka JProbe Coverage from Ant. Options are pretty | * Convenient task to run Sitraka JProbe Coverage from Ant. Options are pretty | ||||
| @@ -217,7 +218,7 @@ public class Coverage extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createArg() | |||||
| public Argument createArg() | |||||
| { | { | ||||
| return cmdlJava.createArgument(); | return cmdlJava.createArgument(); | ||||
| } | } | ||||
| @@ -244,7 +245,7 @@ public class Coverage extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdlJava.createVmArgument(); | return cmdlJava.createVmArgument(); | ||||
| } | } | ||||
| @@ -0,0 +1,72 @@ | |||||
| /* | |||||
| * 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; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | |||||
| * Used for nested xml command line definitions. | |||||
| */ | |||||
| public class Argument | |||||
| { | |||||
| private String[] m_parts; | |||||
| /** | |||||
| * Sets a single commandline argument to the absolute filename of the | |||||
| * given file. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setFile( final File value ) | |||||
| { | |||||
| m_parts = new String[]{value.getAbsolutePath()}; | |||||
| } | |||||
| /** | |||||
| * Line to split into several commandline arguments. | |||||
| * | |||||
| * @param line line to split into several commandline arguments | |||||
| */ | |||||
| public void setLine( final String line ) | |||||
| throws TaskException | |||||
| { | |||||
| m_parts = Commandline.translateCommandline( line ); | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument and treats it like a PATH - | |||||
| * ensures the right separator for the local platform is used. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setPath( final Path value ) | |||||
| { | |||||
| m_parts = new String[]{value.toString()}; | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setValue( final String value ) | |||||
| { | |||||
| m_parts = new String[]{value}; | |||||
| } | |||||
| /** | |||||
| * Returns the parts this Argument consists of. | |||||
| * | |||||
| * @return The Parts value | |||||
| */ | |||||
| public String[] getParts() | |||||
| { | |||||
| return m_parts; | |||||
| } | |||||
| } | |||||
| @@ -35,13 +35,12 @@ import org.apache.myrmidon.api.TaskException; | |||||
| public class Commandline | public class Commandline | ||||
| implements Cloneable | implements Cloneable | ||||
| { | { | ||||
| private ArrayList m_arguments = new ArrayList(); | |||||
| protected final ArrayList m_arguments = new ArrayList(); | |||||
| private String m_executable; | private String m_executable; | ||||
| public Commandline( String to_process ) | public Commandline( String to_process ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| super(); | |||||
| String[] tmp = translateCommandline( to_process ); | String[] tmp = translateCommandline( to_process ); | ||||
| if( tmp != null && tmp.length > 0 ) | if( tmp != null && tmp.length > 0 ) | ||||
| { | { | ||||
| @@ -206,11 +205,11 @@ public class Commandline | |||||
| * | * | ||||
| * @param executable The new Executable value | * @param executable The new Executable value | ||||
| */ | */ | ||||
| public void setExecutable( String executable ) | |||||
| public void setExecutable( final String executable ) | |||||
| { | { | ||||
| if( executable == null || executable.length() == 0 ) | if( executable == null || executable.length() == 0 ) | ||||
| return; | return; | ||||
| this.m_executable = executable.replace( '/', File.separatorChar ) | |||||
| m_executable = executable.replace( '/', File.separatorChar ) | |||||
| .replace( '\\', File.separatorChar ); | .replace( '\\', File.separatorChar ); | ||||
| } | } | ||||
| @@ -222,11 +221,12 @@ public class Commandline | |||||
| */ | */ | ||||
| public String[] getArguments() | public String[] getArguments() | ||||
| { | { | ||||
| ArrayList result = new ArrayList( m_arguments.size() * 2 ); | |||||
| for( int i = 0; i < m_arguments.size(); i++ ) | |||||
| final int size = m_arguments.size(); | |||||
| final ArrayList result = new ArrayList( size * 2 ); | |||||
| for( int i = 0; i < size; i++ ) | |||||
| { | { | ||||
| Argument arg = (Argument)m_arguments.get( i ); | |||||
| String[] s = arg.getParts(); | |||||
| final Argument arg = (Argument)m_arguments.get( i ); | |||||
| final String[] s = arg.getParts(); | |||||
| for( int j = 0; j < s.length; j++ ) | for( int j = 0; j < s.length; j++ ) | ||||
| { | { | ||||
| result.add( s[ j ] ); | result.add( s[ j ] ); | ||||
| @@ -246,7 +246,9 @@ public class Commandline | |||||
| { | { | ||||
| final String[] args = getArguments(); | final String[] args = getArguments(); | ||||
| if( m_executable == null ) | if( m_executable == null ) | ||||
| { | |||||
| return args; | return args; | ||||
| } | |||||
| final String[] result = new String[ args.length + 1 ]; | final String[] result = new String[ args.length + 1 ]; | ||||
| result[ 0 ] = m_executable; | result[ 0 ] = m_executable; | ||||
| System.arraycopy( args, 0, result, 1, args.length ); | System.arraycopy( args, 0, result, 1, args.length ); | ||||
| @@ -315,7 +317,7 @@ public class Commandline | |||||
| */ | */ | ||||
| public Marker createMarker() | public Marker createMarker() | ||||
| { | { | ||||
| return new Marker( m_arguments.size() ); | |||||
| return new Marker( this, m_arguments.size() ); | |||||
| } | } | ||||
| public int size() | public int size() | ||||
| @@ -328,109 +330,4 @@ public class Commandline | |||||
| return toString( getCommandline() ); | return toString( getCommandline() ); | ||||
| } | } | ||||
| /** | |||||
| * Used for nested xml command line definitions. | |||||
| * | |||||
| * @author RT | |||||
| */ | |||||
| public static class Argument | |||||
| { | |||||
| private String[] parts; | |||||
| /** | |||||
| * Sets a single commandline argument to the absolute filename of the | |||||
| * given file. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setFile( File value ) | |||||
| { | |||||
| parts = new String[]{value.getAbsolutePath()}; | |||||
| } | |||||
| /** | |||||
| * Line to split into several commandline arguments. | |||||
| * | |||||
| * @param line line to split into several commandline arguments | |||||
| */ | |||||
| public void setLine( String line ) | |||||
| throws TaskException | |||||
| { | |||||
| parts = translateCommandline( line ); | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument and treats it like a PATH - | |||||
| * ensures the right separator for the local platform is used. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setPath( Path value ) | |||||
| { | |||||
| parts = new String[]{value.toString()}; | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setValue( String value ) | |||||
| { | |||||
| parts = new String[]{value}; | |||||
| } | |||||
| /** | |||||
| * Returns the parts this Argument consists of. | |||||
| * | |||||
| * @return The Parts value | |||||
| */ | |||||
| public String[] getParts() | |||||
| { | |||||
| return parts; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Class to keep track of the position of an Argument. | |||||
| * | |||||
| * @author RT | |||||
| */ | |||||
| // <p>This class is there to support the srcfile and targetfile | |||||
| // elements of <execon> and <transform> - don't know | |||||
| // whether there might be additional use cases.</p> --SB | |||||
| public class Marker | |||||
| { | |||||
| private int realPos = -1; | |||||
| private int position; | |||||
| Marker( int position ) | |||||
| { | |||||
| this.position = position; | |||||
| } | |||||
| /** | |||||
| * Return the number of arguments that preceeded this marker. <p> | |||||
| * | |||||
| * The name of the executable - if set - is counted as the very first | |||||
| * argument.</p> | |||||
| * | |||||
| * @return The Position value | |||||
| */ | |||||
| public int getPosition() | |||||
| { | |||||
| if( realPos == -1 ) | |||||
| { | |||||
| realPos = ( m_executable == null ? 0 : 1 ); | |||||
| for( int i = 0; i < position; i++ ) | |||||
| { | |||||
| Argument arg = (Argument)m_arguments.get( i ); | |||||
| realPos += arg.getParts().length; | |||||
| } | |||||
| } | |||||
| return realPos; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -218,7 +218,7 @@ public class CommandlineJava implements Cloneable | |||||
| return c; | return c; | ||||
| } | } | ||||
| public Commandline.Argument createArgument() | |||||
| public Argument createArgument() | |||||
| { | { | ||||
| return javaCommand.createArgument(); | return javaCommand.createArgument(); | ||||
| } | } | ||||
| @@ -232,7 +232,7 @@ public class CommandlineJava implements Cloneable | |||||
| return classpath; | return classpath; | ||||
| } | } | ||||
| public Commandline.Argument createVmArgument() | |||||
| public Argument createVmArgument() | |||||
| { | { | ||||
| return vmCommand.createArgument(); | return vmCommand.createArgument(); | ||||
| } | } | ||||
| @@ -38,5 +38,4 @@ public class EnvironmentData | |||||
| { | { | ||||
| m_variables.add( var ); | m_variables.add( var ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,53 @@ | |||||
| /* | |||||
| * 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.util.ArrayList; | |||||
| /** | |||||
| * Class to keep track of the position of an Argument. | |||||
| * | |||||
| * <p>This class is there to support the srcfile and targetfile | |||||
| * elements of <execon> and <transform> - don't know | |||||
| * whether there might be additional use cases.</p> --SB | |||||
| */ | |||||
| public class Marker | |||||
| { | |||||
| private int m_realPos = -1; | |||||
| private int m_position; | |||||
| private Commandline m_commandline; | |||||
| Marker( Commandline commandline, int position ) | |||||
| { | |||||
| m_commandline = commandline; | |||||
| m_position = position; | |||||
| } | |||||
| /** | |||||
| * Return the number of arguments that preceeded this marker. <p> | |||||
| * | |||||
| * The name of the executable - if set - is counted as the very first | |||||
| * argument.</p> | |||||
| * | |||||
| * @return The Position value | |||||
| */ | |||||
| public int getPosition() | |||||
| { | |||||
| if( m_realPos == -1 ) | |||||
| { | |||||
| m_realPos = ( m_commandline.getExecutable() == null ? 0 : 1 ); | |||||
| final ArrayList arguments = m_commandline.m_arguments; | |||||
| for( int i = 0; i < m_position; i++ ) | |||||
| { | |||||
| final Argument arg = (Argument)arguments.get( i ); | |||||
| m_realPos += arg.getParts().length; | |||||
| } | |||||
| } | |||||
| return m_realPos; | |||||
| } | |||||
| } | |||||
| @@ -20,6 +20,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.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Mapper; | import org.apache.tools.ant.types.Mapper; | ||||
| import org.apache.tools.ant.types.Marker; | |||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | import org.apache.tools.ant.util.SourceFileScanner; | ||||
| @@ -36,9 +37,9 @@ public class ExecuteOn extends ExecTask | |||||
| private boolean relative = false; | private boolean relative = false; | ||||
| private boolean parallel = false; | private boolean parallel = false; | ||||
| protected String type = "file"; | protected String type = "file"; | ||||
| protected Commandline.Marker srcFilePos = null; | |||||
| protected Marker srcFilePos = null; | |||||
| private boolean skipEmpty = false; | private boolean skipEmpty = false; | ||||
| protected Commandline.Marker targetFilePos = null; | |||||
| protected Marker targetFilePos = null; | |||||
| protected Mapper mapperElement = null; | protected Mapper mapperElement = null; | ||||
| protected FileNameMapper mapper = null; | protected FileNameMapper mapper = null; | ||||
| protected File destDir = null; | protected File destDir = null; | ||||
| @@ -132,7 +133,7 @@ public class ExecuteOn extends ExecTask | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Marker createSrcfile() | |||||
| public Marker createSrcfile() | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( srcFilePos != null ) | if( srcFilePos != null ) | ||||
| @@ -149,7 +150,7 @@ public class ExecuteOn extends ExecTask | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Marker createTargetfile() | |||||
| public Marker createTargetfile() | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( targetFilePos != null ) | if( targetFilePos != null ) | ||||
| @@ -24,6 +24,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * 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 | ||||
| @@ -185,7 +186,7 @@ public class Java extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createArg() | |||||
| public Argument createArg() | |||||
| { | { | ||||
| return cmdl.createArgument(); | return cmdl.createArgument(); | ||||
| } | } | ||||
| @@ -206,7 +207,7 @@ public class Java extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdl.createVmArgument(); | return cmdl.createVmArgument(); | ||||
| } | } | ||||
| @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| 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.Argument; | |||||
| import org.apache.tools.ant.util.GlobPatternMapper; | import org.apache.tools.ant.util.GlobPatternMapper; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | import org.apache.tools.ant.util.SourceFileScanner; | ||||
| @@ -914,7 +915,7 @@ public class Javac extends MatchingTask | |||||
| * @author RT | * @author RT | ||||
| */ | */ | ||||
| public class ImplementationSpecificArgument | public class ImplementationSpecificArgument | ||||
| extends Commandline.Argument | |||||
| extends Argument | |||||
| { | { | ||||
| private String impl; | private String impl; | ||||
| @@ -22,6 +22,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Executes a given command if the os platform is appropriate. | * Executes a given command if the os platform is appropriate. | ||||
| @@ -186,7 +187,7 @@ public class ExecTask extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createArg() | |||||
| public Argument createArg() | |||||
| { | { | ||||
| return cmdl.createArgument(); | return cmdl.createArgument(); | ||||
| } | } | ||||
| @@ -21,6 +21,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * ANTLR task. | * ANTLR task. | ||||
| @@ -104,7 +105,7 @@ public class ANTLR extends Task | |||||
| * the JVM. | * the JVM. | ||||
| * @see #setFork(boolean) | * @see #setFork(boolean) | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return commandline.createVmArgument(); | return commandline.createVmArgument(); | ||||
| } | } | ||||
| @@ -23,6 +23,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; | |||||
| import org.apache.tools.ant.taskdefs.exec.ExecuteStreamHandler; | import org.apache.tools.ant.taskdefs.exec.ExecuteStreamHandler; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and | * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and | ||||
| @@ -491,7 +492,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exec | |||||
| javaTask = (Java)getTask().getProject().createTask( "java" ); | javaTask = (Java)getTask().getProject().createTask( "java" ); | ||||
| javaTask.setClassname( VERIFY ); | javaTask.setClassname( VERIFY ); | ||||
| Commandline.Argument arguments = javaTask.createArg(); | |||||
| Argument arguments = javaTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| Path classpath = getCombinedClasspath(); | Path classpath = getCombinedClasspath(); | ||||
| if( classpath != null ) | if( classpath != null ) | ||||
| @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Build a serialised deployment descriptor given a text file description of the | * Build a serialised deployment descriptor given a text file description of the | ||||
| @@ -122,7 +123,7 @@ public class DDCreator extends MatchingTask | |||||
| Java ddCreatorTask = (Java)getProject().createTask( "java" ); | Java ddCreatorTask = (Java)getProject().createTask( "java" ); | ||||
| ddCreatorTask.setFork( true ); | ddCreatorTask.setFork( true ); | ||||
| ddCreatorTask.setClassname( "org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper" ); | ddCreatorTask.setClassname( "org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper" ); | ||||
| Commandline.Argument arguments = ddCreatorTask.createArg(); | |||||
| Argument arguments = ddCreatorTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| ddCreatorTask.setClasspath( new Path( getProject(), execClassPath ) ); | ddCreatorTask.setClasspath( new Path( getProject(), execClassPath ) ); | ||||
| if( ddCreatorTask.executeJava() != 0 ) | if( ddCreatorTask.executeJava() != 0 ) | ||||
| @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Build EJB support classes using Weblogic's ejbc tool from a directory | * Build EJB support classes using Weblogic's ejbc tool from a directory | ||||
| @@ -181,7 +182,7 @@ public class Ejbc extends MatchingTask | |||||
| args += " " + files[ i ]; | args += " " + files[ i ]; | ||||
| } | } | ||||
| Commandline.Argument arguments = helperTask.createArg(); | |||||
| Argument arguments = helperTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| helperTask.setClasspath( new Path( getProject(), execClassPath ) ); | helperTask.setClasspath( new Path( getProject(), execClassPath ) ); | ||||
| if( helperTask.executeJava() != 0 ) | if( helperTask.executeJava() != 0 ) | ||||
| @@ -25,6 +25,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Websphere deployment tool that augments the ejbjar task. | * Websphere deployment tool that augments the ejbjar task. | ||||
| @@ -982,7 +983,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool | |||||
| // Set the Java class name | // Set the Java class name | ||||
| javaTask.setClassname( "com.ibm.etools.ejbdeploy.EJBDeploy" ); | javaTask.setClassname( "com.ibm.etools.ejbdeploy.EJBDeploy" ); | ||||
| Commandline.Argument arguments = javaTask.createArg(); | |||||
| Argument arguments = javaTask.createArg(); | |||||
| arguments.setLine( args ); | arguments.setLine( args ); | ||||
| Path classpath = wasClasspath; | Path classpath = wasClasspath; | ||||
| if( classpath == null ) | if( classpath == null ) | ||||
| @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Taskdef for the JJTree compiler compiler. | * Taskdef for the JJTree compiler compiler. | ||||
| @@ -180,7 +181,7 @@ public class JJTree extends Task | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| final Commandline.Argument arg = cmdl.createVmArgument(); | |||||
| final Argument arg = cmdl.createVmArgument(); | |||||
| arg.setValue( "-mx140M" ); | arg.setValue( "-mx140M" ); | ||||
| arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Taskdef for the JavaCC compiler compiler. | * Taskdef for the JavaCC compiler compiler. | ||||
| @@ -230,7 +231,7 @@ public class JavaCC extends Task | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| final Commandline.Argument arg = cmdl.createVmArgument(); | |||||
| final Argument arg = cmdl.createVmArgument(); | |||||
| arg.setValue( "-mx140M" ); | arg.setValue( "-mx140M" ); | ||||
| arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| @@ -23,6 +23,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.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.Argument; | |||||
| /** | /** | ||||
| * Ant task to run JDepend tests. <p> | * Ant task to run JDepend tests. <p> | ||||
| @@ -219,7 +220,7 @@ public class JDependTask extends Task | |||||
| * the JVM. | * the JVM. | ||||
| * @see #setFork(boolean) | * @see #setFork(boolean) | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg( CommandlineJava commandline ) | |||||
| public Argument createJvmarg( CommandlineJava commandline ) | |||||
| { | { | ||||
| return commandline.createVmArgument(); | return commandline.createVmArgument(); | ||||
| } | } | ||||
| @@ -31,6 +31,7 @@ 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; | import org.apache.tools.ant.types.EnvironmentVariable; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Ant task to run JUnit tests. <p> | * Ant task to run JUnit tests. <p> | ||||
| @@ -367,7 +368,7 @@ public class JUnitTask extends Task | |||||
| * the JVM. | * the JVM. | ||||
| * @see #setFork(boolean) | * @see #setFork(boolean) | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return commandline.createVmArgument(); | return commandline.createVmArgument(); | ||||
| } | } | ||||
| @@ -25,6 +25,7 @@ import org.apache.tools.ant.types.Commandline; | |||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Somewhat abstract framework to be used for other metama 2.0 tasks. This | * Somewhat abstract framework to be used for other metama 2.0 tasks. This | ||||
| @@ -169,7 +170,7 @@ public abstract class AbstractMetamataTask extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdl.createVmArgument(); | return cmdl.createVmArgument(); | ||||
| } | } | ||||
| @@ -226,7 +227,7 @@ public abstract class AbstractMetamataTask extends Task | |||||
| classPath.createPathElement().setLocation( jar ); | classPath.createPathElement().setLocation( jar ); | ||||
| // set the metamata.home property | // set the metamata.home property | ||||
| final Commandline.Argument vmArgs = cmdl.createVmArgument(); | |||||
| final Argument vmArgs = cmdl.createVmArgument(); | |||||
| vmArgs.setValue( "-Dmetamata.home=" + metamataHome.getAbsolutePath() ); | vmArgs.setValue( "-Dmetamata.home=" + metamataHome.getAbsolutePath() ); | ||||
| // retrieve all the files we want to scan | // retrieve all the files we want to scan | ||||
| @@ -237,7 +238,7 @@ public abstract class AbstractMetamataTask extends Task | |||||
| ArrayList options = getOptions(); | ArrayList options = getOptions(); | ||||
| optionsFile = createTmpFile(); | optionsFile = createTmpFile(); | ||||
| generateOptionsFile( optionsFile, options ); | generateOptionsFile( optionsFile, options ); | ||||
| Commandline.Argument args = cmdl.createArgument(); | |||||
| Argument args = cmdl.createArgument(); | |||||
| args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | ||||
| } | } | ||||
| @@ -22,6 +22,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Simple Metamata MParse task based on the original written by <a | * Simple Metamata MParse task based on the original written by <a | ||||
| @@ -160,7 +161,7 @@ public class MParse extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdl.createVmArgument(); | return cmdl.createVmArgument(); | ||||
| } | } | ||||
| @@ -218,14 +219,14 @@ public class MParse extends Task | |||||
| } | } | ||||
| // set the metamata.home property | // set the metamata.home property | ||||
| final Commandline.Argument vmArgs = cmdl.createVmArgument(); | |||||
| final Argument vmArgs = cmdl.createVmArgument(); | |||||
| vmArgs.setValue( "-Dmetamata.home=" + metahome.getAbsolutePath() ); | vmArgs.setValue( "-Dmetamata.home=" + metahome.getAbsolutePath() ); | ||||
| // write all the options to a temp file and use it ro run the process | // write all the options to a temp file and use it ro run the process | ||||
| String[] options = getOptions(); | String[] options = getOptions(); | ||||
| optionsFile = createTmpFile(); | optionsFile = createTmpFile(); | ||||
| generateOptionsFile( optionsFile, options ); | generateOptionsFile( optionsFile, options ); | ||||
| Commandline.Argument args = cmdl.createArgument(); | |||||
| Argument args = cmdl.createArgument(); | |||||
| args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); | ||||
| } | } | ||||
| @@ -25,6 +25,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.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Argument; | |||||
| /** | /** | ||||
| * Convenient task to run Sitraka JProbe Coverage from Ant. Options are pretty | * Convenient task to run Sitraka JProbe Coverage from Ant. Options are pretty | ||||
| @@ -217,7 +218,7 @@ public class Coverage extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createArg() | |||||
| public Argument createArg() | |||||
| { | { | ||||
| return cmdlJava.createArgument(); | return cmdlJava.createArgument(); | ||||
| } | } | ||||
| @@ -244,7 +245,7 @@ public class Coverage extends Task | |||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public Commandline.Argument createJvmarg() | |||||
| public Argument createJvmarg() | |||||
| { | { | ||||
| return cmdlJava.createVmArgument(); | return cmdlJava.createVmArgument(); | ||||
| } | } | ||||
| @@ -0,0 +1,72 @@ | |||||
| /* | |||||
| * 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; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | |||||
| * Used for nested xml command line definitions. | |||||
| */ | |||||
| public class Argument | |||||
| { | |||||
| private String[] m_parts; | |||||
| /** | |||||
| * Sets a single commandline argument to the absolute filename of the | |||||
| * given file. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setFile( final File value ) | |||||
| { | |||||
| m_parts = new String[]{value.getAbsolutePath()}; | |||||
| } | |||||
| /** | |||||
| * Line to split into several commandline arguments. | |||||
| * | |||||
| * @param line line to split into several commandline arguments | |||||
| */ | |||||
| public void setLine( final String line ) | |||||
| throws TaskException | |||||
| { | |||||
| m_parts = Commandline.translateCommandline( line ); | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument and treats it like a PATH - | |||||
| * ensures the right separator for the local platform is used. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setPath( final Path value ) | |||||
| { | |||||
| m_parts = new String[]{value.toString()}; | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setValue( final String value ) | |||||
| { | |||||
| m_parts = new String[]{value}; | |||||
| } | |||||
| /** | |||||
| * Returns the parts this Argument consists of. | |||||
| * | |||||
| * @return The Parts value | |||||
| */ | |||||
| public String[] getParts() | |||||
| { | |||||
| return m_parts; | |||||
| } | |||||
| } | |||||
| @@ -35,13 +35,12 @@ import org.apache.myrmidon.api.TaskException; | |||||
| public class Commandline | public class Commandline | ||||
| implements Cloneable | implements Cloneable | ||||
| { | { | ||||
| private ArrayList m_arguments = new ArrayList(); | |||||
| protected final ArrayList m_arguments = new ArrayList(); | |||||
| private String m_executable; | private String m_executable; | ||||
| public Commandline( String to_process ) | public Commandline( String to_process ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| super(); | |||||
| String[] tmp = translateCommandline( to_process ); | String[] tmp = translateCommandline( to_process ); | ||||
| if( tmp != null && tmp.length > 0 ) | if( tmp != null && tmp.length > 0 ) | ||||
| { | { | ||||
| @@ -206,11 +205,11 @@ public class Commandline | |||||
| * | * | ||||
| * @param executable The new Executable value | * @param executable The new Executable value | ||||
| */ | */ | ||||
| public void setExecutable( String executable ) | |||||
| public void setExecutable( final String executable ) | |||||
| { | { | ||||
| if( executable == null || executable.length() == 0 ) | if( executable == null || executable.length() == 0 ) | ||||
| return; | return; | ||||
| this.m_executable = executable.replace( '/', File.separatorChar ) | |||||
| m_executable = executable.replace( '/', File.separatorChar ) | |||||
| .replace( '\\', File.separatorChar ); | .replace( '\\', File.separatorChar ); | ||||
| } | } | ||||
| @@ -222,11 +221,12 @@ public class Commandline | |||||
| */ | */ | ||||
| public String[] getArguments() | public String[] getArguments() | ||||
| { | { | ||||
| ArrayList result = new ArrayList( m_arguments.size() * 2 ); | |||||
| for( int i = 0; i < m_arguments.size(); i++ ) | |||||
| final int size = m_arguments.size(); | |||||
| final ArrayList result = new ArrayList( size * 2 ); | |||||
| for( int i = 0; i < size; i++ ) | |||||
| { | { | ||||
| Argument arg = (Argument)m_arguments.get( i ); | |||||
| String[] s = arg.getParts(); | |||||
| final Argument arg = (Argument)m_arguments.get( i ); | |||||
| final String[] s = arg.getParts(); | |||||
| for( int j = 0; j < s.length; j++ ) | for( int j = 0; j < s.length; j++ ) | ||||
| { | { | ||||
| result.add( s[ j ] ); | result.add( s[ j ] ); | ||||
| @@ -246,7 +246,9 @@ public class Commandline | |||||
| { | { | ||||
| final String[] args = getArguments(); | final String[] args = getArguments(); | ||||
| if( m_executable == null ) | if( m_executable == null ) | ||||
| { | |||||
| return args; | return args; | ||||
| } | |||||
| final String[] result = new String[ args.length + 1 ]; | final String[] result = new String[ args.length + 1 ]; | ||||
| result[ 0 ] = m_executable; | result[ 0 ] = m_executable; | ||||
| System.arraycopy( args, 0, result, 1, args.length ); | System.arraycopy( args, 0, result, 1, args.length ); | ||||
| @@ -315,7 +317,7 @@ public class Commandline | |||||
| */ | */ | ||||
| public Marker createMarker() | public Marker createMarker() | ||||
| { | { | ||||
| return new Marker( m_arguments.size() ); | |||||
| return new Marker( this, m_arguments.size() ); | |||||
| } | } | ||||
| public int size() | public int size() | ||||
| @@ -328,109 +330,4 @@ public class Commandline | |||||
| return toString( getCommandline() ); | return toString( getCommandline() ); | ||||
| } | } | ||||
| /** | |||||
| * Used for nested xml command line definitions. | |||||
| * | |||||
| * @author RT | |||||
| */ | |||||
| public static class Argument | |||||
| { | |||||
| private String[] parts; | |||||
| /** | |||||
| * Sets a single commandline argument to the absolute filename of the | |||||
| * given file. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setFile( File value ) | |||||
| { | |||||
| parts = new String[]{value.getAbsolutePath()}; | |||||
| } | |||||
| /** | |||||
| * Line to split into several commandline arguments. | |||||
| * | |||||
| * @param line line to split into several commandline arguments | |||||
| */ | |||||
| public void setLine( String line ) | |||||
| throws TaskException | |||||
| { | |||||
| parts = translateCommandline( line ); | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument and treats it like a PATH - | |||||
| * ensures the right separator for the local platform is used. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setPath( Path value ) | |||||
| { | |||||
| parts = new String[]{value.toString()}; | |||||
| } | |||||
| /** | |||||
| * Sets a single commandline argument. | |||||
| * | |||||
| * @param value a single commandline argument. | |||||
| */ | |||||
| public void setValue( String value ) | |||||
| { | |||||
| parts = new String[]{value}; | |||||
| } | |||||
| /** | |||||
| * Returns the parts this Argument consists of. | |||||
| * | |||||
| * @return The Parts value | |||||
| */ | |||||
| public String[] getParts() | |||||
| { | |||||
| return parts; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Class to keep track of the position of an Argument. | |||||
| * | |||||
| * @author RT | |||||
| */ | |||||
| // <p>This class is there to support the srcfile and targetfile | |||||
| // elements of <execon> and <transform> - don't know | |||||
| // whether there might be additional use cases.</p> --SB | |||||
| public class Marker | |||||
| { | |||||
| private int realPos = -1; | |||||
| private int position; | |||||
| Marker( int position ) | |||||
| { | |||||
| this.position = position; | |||||
| } | |||||
| /** | |||||
| * Return the number of arguments that preceeded this marker. <p> | |||||
| * | |||||
| * The name of the executable - if set - is counted as the very first | |||||
| * argument.</p> | |||||
| * | |||||
| * @return The Position value | |||||
| */ | |||||
| public int getPosition() | |||||
| { | |||||
| if( realPos == -1 ) | |||||
| { | |||||
| realPos = ( m_executable == null ? 0 : 1 ); | |||||
| for( int i = 0; i < position; i++ ) | |||||
| { | |||||
| Argument arg = (Argument)m_arguments.get( i ); | |||||
| realPos += arg.getParts().length; | |||||
| } | |||||
| } | |||||
| return realPos; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -218,7 +218,7 @@ public class CommandlineJava implements Cloneable | |||||
| return c; | return c; | ||||
| } | } | ||||
| public Commandline.Argument createArgument() | |||||
| public Argument createArgument() | |||||
| { | { | ||||
| return javaCommand.createArgument(); | return javaCommand.createArgument(); | ||||
| } | } | ||||
| @@ -232,7 +232,7 @@ public class CommandlineJava implements Cloneable | |||||
| return classpath; | return classpath; | ||||
| } | } | ||||
| public Commandline.Argument createVmArgument() | |||||
| public Argument createVmArgument() | |||||
| { | { | ||||
| return vmCommand.createArgument(); | return vmCommand.createArgument(); | ||||
| } | } | ||||
| @@ -38,5 +38,4 @@ public class EnvironmentData | |||||
| { | { | ||||
| m_variables.add( var ); | m_variables.add( var ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,53 @@ | |||||
| /* | |||||
| * 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.util.ArrayList; | |||||
| /** | |||||
| * Class to keep track of the position of an Argument. | |||||
| * | |||||
| * <p>This class is there to support the srcfile and targetfile | |||||
| * elements of <execon> and <transform> - don't know | |||||
| * whether there might be additional use cases.</p> --SB | |||||
| */ | |||||
| public class Marker | |||||
| { | |||||
| private int m_realPos = -1; | |||||
| private int m_position; | |||||
| private Commandline m_commandline; | |||||
| Marker( Commandline commandline, int position ) | |||||
| { | |||||
| m_commandline = commandline; | |||||
| m_position = position; | |||||
| } | |||||
| /** | |||||
| * Return the number of arguments that preceeded this marker. <p> | |||||
| * | |||||
| * The name of the executable - if set - is counted as the very first | |||||
| * argument.</p> | |||||
| * | |||||
| * @return The Position value | |||||
| */ | |||||
| public int getPosition() | |||||
| { | |||||
| if( m_realPos == -1 ) | |||||
| { | |||||
| m_realPos = ( m_commandline.getExecutable() == null ? 0 : 1 ); | |||||
| final ArrayList arguments = m_commandline.m_arguments; | |||||
| for( int i = 0; i < m_position; i++ ) | |||||
| { | |||||
| final Argument arg = (Argument)arguments.get( i ); | |||||
| m_realPos += arg.getParts().length; | |||||
| } | |||||
| } | |||||
| return m_realPos; | |||||
| } | |||||
| } | |||||