of Commandline to use ArgumentList instead. * Execute now extends Commandline. - Removed Execute.getCommandline(). - Moved Commandline.getCommandline() down to Execute, and made private. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272274 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -13,7 +13,6 @@ import org.apache.avalon.excalibur.i18n.Resources; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| /** | |||
| * Task as a layer on top of patch. Patch applies a diff file to an original. | |||
| @@ -105,8 +104,7 @@ public class Patch | |||
| { | |||
| validate(); | |||
| final Execute exe = new Execute(); | |||
| buildCommand( exe.getCommandline() ); | |||
| final Execute exe = buildCommand(); | |||
| exe.execute( getContext() ); | |||
| } | |||
| @@ -132,8 +130,9 @@ public class Patch | |||
| } | |||
| } | |||
| private void buildCommand( final Commandline cmd ) | |||
| private Execute buildCommand( ) | |||
| { | |||
| final Execute cmd = new Execute(); | |||
| cmd.setExecutable( "patch" ); | |||
| if( m_backups ) | |||
| { | |||
| @@ -167,5 +166,6 @@ public class Patch | |||
| { | |||
| cmd.addArgument( m_originalFile ); | |||
| } | |||
| return cmd; | |||
| } | |||
| } | |||
| @@ -185,9 +185,11 @@ public class ChangeLog | |||
| userList.put( user.getUserID(), user.getDisplayname() ); | |||
| } | |||
| final Commandline command = new Commandline(); | |||
| command.setExecutable( "cvs" ); | |||
| command.addArgument( "log" ); | |||
| final Execute exe = new Execute(); | |||
| exe.setWorkingDirectory( m_dir ); | |||
| exe.setExecutable( "cvs" ); | |||
| exe.addArgument( "log" ); | |||
| if( null != m_start ) | |||
| { | |||
| @@ -196,7 +198,7 @@ public class ChangeLog | |||
| // We want something of the form: -d ">=YYYY-MM-dd" | |||
| final String dateRange = "-d >=" + outputDate.format( m_start ); | |||
| command.addArgument( dateRange ); | |||
| exe.addArgument( dateRange ); | |||
| } | |||
| // Check if list of files to check has been specified | |||
| @@ -220,9 +222,6 @@ public class ChangeLog | |||
| */ | |||
| final ChangeLogParser parser = new ChangeLogParser( userList, getContext() ); | |||
| final Execute exe = new Execute(); | |||
| exe.setWorkingDirectory( m_dir ); | |||
| exe.setCommandline( command ); | |||
| exe.setExecOutputHandler( parser ); | |||
| exe.execute( getContext() ); | |||
| @@ -143,13 +143,11 @@ public class Cvs | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| final Commandline command = buildCommandline(); | |||
| final Execute exe = new Execute(); | |||
| buildCommandline( exe ); | |||
| final Properties env = buildEnvironment(); | |||
| final Execute exe = new Execute(); | |||
| exe.setWorkingDirectory( m_dest ); | |||
| exe.setCommandline( command ); | |||
| exe.setEnvironment( env ); | |||
| exe.execute( getContext() ); | |||
| } | |||
| @@ -174,10 +172,8 @@ public class Cvs | |||
| return env; | |||
| } | |||
| private Commandline buildCommandline() throws TaskException | |||
| private void buildCommandline( final Commandline command ) throws TaskException | |||
| { | |||
| final Commandline command = new Commandline(); | |||
| command.setExecutable( "cvs" ); | |||
| if( m_cvsRoot != null ) | |||
| { | |||
| @@ -213,7 +209,6 @@ public class Cvs | |||
| { | |||
| command.addArguments( FileUtils.translateCommandline( m_module ) ); | |||
| } | |||
| return command; | |||
| } | |||
| private String getNonEmptyString( final String value ) | |||
| @@ -11,8 +11,8 @@ import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.tools.todo.taskdefs.MatchingTask; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| /** | |||
| @@ -504,29 +504,28 @@ public class CSharp | |||
| } | |||
| final Execute exe = new Execute(); | |||
| final Commandline cmd = exe.getCommandline(); | |||
| cmd.setExecutable( EXE_NAME ); | |||
| addArgument( cmd, "/nologo" ); | |||
| addArgument( cmd, getAdditionalModulesParameter() ); | |||
| addArgument( cmd, getDefinitionsParameter() ); | |||
| addArgument( cmd, getDebugParameter() ); | |||
| addArgument( cmd, getDocFileParameter() ); | |||
| addArgument( cmd, getIncrementalParameter() ); | |||
| addArgument( cmd, getMainClassParameter() ); | |||
| addArgument( cmd, getOptimizeParameter() ); | |||
| addArgument( cmd, getReferencesParameter() ); | |||
| addArgument( cmd, getTargetTypeParameter() ); | |||
| addArgument( cmd, getUnsafeParameter() ); | |||
| addArgument( cmd, getWarnLevelParameter() ); | |||
| addArgument( cmd, getWin32IconParameter() ); | |||
| addArgument( cmd, getOutputFileParameter() ); | |||
| addArgument( cmd, getIncludeDefaultReferencesParameter() ); | |||
| addArgument( cmd, getDefaultReferenceParameter() ); | |||
| addArgument( cmd, getWin32ResParameter() ); | |||
| addArgument( cmd, getUtf8OutpuParameter() ); | |||
| addArgument( cmd, getFullPathsParameter() ); | |||
| addArgument( cmd, getExtraOptionsParameter() ); | |||
| exe.setExecutable( EXE_NAME ); | |||
| addArgument( exe, "/nologo" ); | |||
| addArgument( exe, getAdditionalModulesParameter() ); | |||
| addArgument( exe, getDefinitionsParameter() ); | |||
| addArgument( exe, getDebugParameter() ); | |||
| addArgument( exe, getDocFileParameter() ); | |||
| addArgument( exe, getIncrementalParameter() ); | |||
| addArgument( exe, getMainClassParameter() ); | |||
| addArgument( exe, getOptimizeParameter() ); | |||
| addArgument( exe, getReferencesParameter() ); | |||
| addArgument( exe, getTargetTypeParameter() ); | |||
| addArgument( exe, getUnsafeParameter() ); | |||
| addArgument( exe, getWarnLevelParameter() ); | |||
| addArgument( exe, getWin32IconParameter() ); | |||
| addArgument( exe, getOutputFileParameter() ); | |||
| addArgument( exe, getIncludeDefaultReferencesParameter() ); | |||
| addArgument( exe, getDefaultReferenceParameter() ); | |||
| addArgument( exe, getWin32ResParameter() ); | |||
| addArgument( exe, getUtf8OutpuParameter() ); | |||
| addArgument( exe, getFullPathsParameter() ); | |||
| addArgument( exe, getExtraOptionsParameter() ); | |||
| //get dependencies list. | |||
| final DirectoryScanner scanner = super.getDirectoryScanner( m_srcDir ); | |||
| @@ -539,14 +538,14 @@ public class CSharp | |||
| for( int i = 0; i < dependencies.length; i++ ) | |||
| { | |||
| final String targetFile = baseDir + File.separator + dependencies[ i ]; | |||
| addArgument( cmd, targetFile ); | |||
| addArgument( exe, targetFile ); | |||
| } | |||
| //now run the command of exe + settings + files | |||
| exe.execute( getContext() ); | |||
| } | |||
| private void addArgument( final Commandline cmd, final String argument ) | |||
| private void addArgument( final ArgumentList cmd, final String argument ) | |||
| { | |||
| if( null != argument && 0 != argument.length() ) | |||
| { | |||
| @@ -11,7 +11,7 @@ import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.tools.todo.taskdefs.MatchingTask; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| /** | |||
| @@ -248,21 +248,20 @@ public class Ilasm | |||
| throws TaskException | |||
| { | |||
| final Execute exe = new Execute(); | |||
| final Commandline cmd = exe.getCommandline(); | |||
| cmd.setExecutable( EXE_NAME ); | |||
| addArgument( cmd, getDebugParameter() ); | |||
| addArgument( cmd, getTargetTypeParameter() ); | |||
| addArgument( cmd, getListingParameter() ); | |||
| addArgument( cmd, getOutputFileParameter() ); | |||
| addArgument( cmd, getResourceFileParameter() ); | |||
| addArgument( cmd, getVerboseParameter() ); | |||
| addArgument( cmd, getKeyfileParameter() ); | |||
| addArgument( cmd, getExtraOptionsParameter() ); | |||
| addArgument( cmd, targetFile ); | |||
| exe.setExecutable( EXE_NAME ); | |||
| addArgument( exe, getDebugParameter() ); | |||
| addArgument( exe, getTargetTypeParameter() ); | |||
| addArgument( exe, getListingParameter() ); | |||
| addArgument( exe, getOutputFileParameter() ); | |||
| addArgument( exe, getResourceFileParameter() ); | |||
| addArgument( exe, getVerboseParameter() ); | |||
| addArgument( exe, getKeyfileParameter() ); | |||
| addArgument( exe, getExtraOptionsParameter() ); | |||
| addArgument( exe, targetFile ); | |||
| exe.execute( getContext() ); | |||
| } | |||
| private void addArgument( final Commandline cmd, final String argument ) | |||
| private void addArgument( final ArgumentList cmd, final String argument ) | |||
| { | |||
| if( null != argument && 0 != argument.length() ) | |||
| { | |||
| @@ -7,12 +7,12 @@ | |||
| */ | |||
| package org.apache.antlib.java; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import java.io.File; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * An adaptor for the in-process Javac compiler. | |||
| @@ -32,7 +32,7 @@ public class JavacAdaptor | |||
| protected void compile( final File[] compileList ) | |||
| throws TaskException | |||
| { | |||
| final Commandline cmd = new Commandline(); | |||
| final ArgumentList cmd = new ArgumentList(); | |||
| setupModernJavacCommand( cmd, compileList ); | |||
| final String[] args = cmd.getArguments(); | |||
| @@ -73,7 +73,7 @@ public class JavacAdaptor | |||
| /** | |||
| * Builds the command-line to invoke the compiler with. | |||
| */ | |||
| private void setupModernJavacCommand( final Commandline cmd, | |||
| private void setupModernJavacCommand( final ArgumentList cmd, | |||
| final File[] files ) | |||
| throws TaskException | |||
| { | |||
| @@ -13,7 +13,6 @@ import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.myrmidon.framework.java.JavaRuntimeClassPath; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| /** | |||
| * An adaptor for the jikes compiler. | |||
| @@ -38,7 +37,7 @@ public class JikesAdaptor | |||
| protected void buildCommandLine( final Execute exe, final File tempFile ) | |||
| throws TaskException | |||
| { | |||
| Path classpath = new Path(); | |||
| final Path classpath = new Path(); | |||
| // Add the destination directory | |||
| classpath.addLocation( getDestDir() ); | |||
| @@ -57,28 +56,27 @@ public class JikesAdaptor | |||
| classpath.add( new JavaRuntimeClassPath() ); | |||
| // Build the command line | |||
| final Commandline cmd = exe.getCommandline(); | |||
| cmd.setExecutable( "jikes" ); | |||
| exe.setExecutable( "jikes" ); | |||
| if( isDeprecation() ) | |||
| { | |||
| cmd.addArgument( "-deprecation" ); | |||
| exe.addArgument( "-deprecation" ); | |||
| } | |||
| if( isDebug() ) | |||
| { | |||
| cmd.addArgument( "-g" ); | |||
| exe.addArgument( "-g" ); | |||
| } | |||
| cmd.addArgument( "-d" ); | |||
| cmd.addArgument( getDestDir() ); | |||
| exe.addArgument( "-d" ); | |||
| exe.addArgument( getDestDir() ); | |||
| cmd.addArgument( "-classpath" ); | |||
| cmd.addArgument( FileListUtil.formatPath( classpath, getContext() ) ); | |||
| exe.addArgument( "-classpath" ); | |||
| exe.addArgument( FileListUtil.formatPath( classpath, getContext() ) ); | |||
| // TODO - make this configurable | |||
| cmd.addArgument( "+E" ); | |||
| exe.addArgument( "+E" ); | |||
| cmd.addArgument( "@" + tempFile.getAbsolutePath() ); | |||
| exe.addArgument( "@" + tempFile.getAbsolutePath() ); | |||
| } | |||
| } | |||
| @@ -14,7 +14,6 @@ import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.tools.todo.types.Argument; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.EnvironmentData; | |||
| import org.apache.tools.todo.types.EnvironmentVariable; | |||
| @@ -32,11 +31,8 @@ import org.apache.tools.todo.types.EnvironmentVariable; | |||
| public class Exec | |||
| extends AbstractTask | |||
| { | |||
| private long m_timeout; | |||
| private EnvironmentData m_env = new EnvironmentData(); | |||
| private Commandline m_command = new Commandline(); | |||
| private boolean m_newEnvironment; | |||
| private File m_dir; | |||
| private final Execute m_exe = new Execute(); | |||
| private final EnvironmentData m_env = new EnvironmentData(); | |||
| private String m_os; | |||
| /** | |||
| @@ -45,7 +41,7 @@ public class Exec | |||
| public void setDir( final File dir ) | |||
| throws TaskException | |||
| { | |||
| m_dir = dir; | |||
| m_exe.setWorkingDirectory( dir ); | |||
| } | |||
| /** | |||
| @@ -54,7 +50,7 @@ public class Exec | |||
| public void setExecutable( final String value ) | |||
| throws TaskException | |||
| { | |||
| m_command.setExecutable( value ); | |||
| m_exe.setExecutable( value ); | |||
| } | |||
| /** | |||
| @@ -62,7 +58,7 @@ public class Exec | |||
| */ | |||
| public void setNewenvironment( final boolean newEnvironment ) | |||
| { | |||
| m_newEnvironment = newEnvironment; | |||
| m_exe.setNewenvironment( newEnvironment ); | |||
| } | |||
| /** | |||
| @@ -78,7 +74,7 @@ public class Exec | |||
| */ | |||
| public void setTimeout( final long timeout ) | |||
| { | |||
| m_timeout = timeout; | |||
| m_exe.setTimeout( timeout ); | |||
| } | |||
| /** | |||
| @@ -94,7 +90,7 @@ public class Exec | |||
| */ | |||
| public void addArg( final Argument argument ) | |||
| { | |||
| m_command.addArgument( argument ); | |||
| m_exe.addArgument( argument ); | |||
| } | |||
| public void execute() | |||
| @@ -105,22 +101,12 @@ public class Exec | |||
| return; | |||
| } | |||
| // execute the command | |||
| final Execute exe = createExecute(); | |||
| exe.execute( getContext() ); | |||
| } | |||
| private Execute createExecute() | |||
| throws TaskException | |||
| { | |||
| // Setup environment vars | |||
| final Properties environment = m_env.getVariables(); | |||
| m_exe.setEnvironment( environment ); | |||
| final Execute exe = new Execute(); | |||
| exe.setTimeout( m_timeout ); | |||
| exe.setWorkingDirectory( m_dir ); | |||
| exe.setNewenvironment( m_newEnvironment ); | |||
| exe.setEnvironment( environment ); | |||
| exe.setCommandline( m_command ); | |||
| return exe; | |||
| // execute the command | |||
| m_exe.execute( getContext() ); | |||
| } | |||
| } | |||
| @@ -118,15 +118,13 @@ public class GenerateKey | |||
| final String message = "Generating Key for " + m_alias; | |||
| getContext().info( message ); | |||
| final Commandline cmd = createCommand(); | |||
| final Execute exe = new Execute(); | |||
| exe.setCommandline( cmd ); | |||
| final Execute exe = createCommand(); | |||
| exe.execute( getContext() ); | |||
| } | |||
| private Commandline createCommand() | |||
| private Execute createCommand() | |||
| { | |||
| final Commandline cmd = new Commandline(); | |||
| final Execute cmd = new Execute(); | |||
| cmd.setExecutable( "keytool" ); | |||
| cmd.addArgument( "-genkey " ); | |||
| @@ -202,6 +200,7 @@ public class GenerateKey | |||
| cmd.addArgument( "-validity" ); | |||
| cmd.addArgument( "" + m_validity ); | |||
| } | |||
| return cmd; | |||
| } | |||
| @@ -17,7 +17,6 @@ import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.myrmidon.framework.FileSet; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.tools.todo.types.ScannerUtil; | |||
| @@ -293,21 +292,20 @@ public class SignJar | |||
| final String message = "Signing Jar : " + jarSource.getAbsolutePath(); | |||
| getContext().info( message ); | |||
| final Commandline cmd = buildCommand( jarTarget, jarSource ); | |||
| final Execute exe = new Execute(); | |||
| exe.setCommandline( cmd ); | |||
| final Execute exe = buildCommand( jarTarget, jarSource ); | |||
| exe.execute( getContext() ); | |||
| } | |||
| private Commandline buildCommand( final File jarTarget, final File jarSource ) | |||
| private Execute buildCommand( final File jarTarget, | |||
| final File jarSource ) | |||
| { | |||
| final Commandline cmd = new Commandline(); | |||
| final Execute cmd = new Execute(); | |||
| cmd.setExecutable( "jarsigner" ); | |||
| if( null != m_keystore ) | |||
| { | |||
| cmd.addArgument( "-keystore" ); | |||
| cmd.addArgument( m_keystore.toString() ); | |||
| cmd.addArgument( m_keystore ); | |||
| } | |||
| if( null != m_storepass ) | |||
| @@ -331,13 +329,13 @@ public class SignJar | |||
| if( null != m_sigfile ) | |||
| { | |||
| cmd.addArgument( "-sigfile" ); | |||
| cmd.addArgument( m_sigfile.toString() ); | |||
| cmd.addArgument( m_sigfile ); | |||
| } | |||
| if( null != jarTarget ) | |||
| { | |||
| cmd.addArgument( "-signedjar" ); | |||
| cmd.addArgument( jarTarget.toString() ); | |||
| cmd.addArgument( jarTarget ); | |||
| } | |||
| if( m_verbose ) | |||
| @@ -355,9 +353,10 @@ public class SignJar | |||
| cmd.addArgument( "-sectionsonly" ); | |||
| } | |||
| cmd.addArgument( jarSource.toString() ); | |||
| cmd.addArgument( jarSource ); | |||
| cmd.addArgument( m_alias ); | |||
| return cmd; | |||
| } | |||
| } | |||
| @@ -32,11 +32,11 @@ import org.apache.tools.todo.util.FileUtils; | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public class Execute | |||
| extends Commandline | |||
| { | |||
| private static final Resources REZ | |||
| = ResourceManager.getPackageResources( Execute.class ); | |||
| private Commandline m_command; | |||
| private Properties m_environment = new Properties(); | |||
| private File m_workingDirectory; | |||
| private boolean m_newEnvironment; | |||
| @@ -76,19 +76,8 @@ public class Execute | |||
| */ | |||
| public void setCommandline( final Commandline command ) | |||
| { | |||
| m_command = command; | |||
| } | |||
| /** | |||
| * Returns the commandline of the process to launch. | |||
| */ | |||
| public Commandline getCommandline() | |||
| { | |||
| if( null == m_command ) | |||
| { | |||
| m_command = new Commandline(); | |||
| } | |||
| return m_command; | |||
| setExecutable( command.getExecutable() ); | |||
| addArguments( command ); | |||
| } | |||
| /** | |||
| @@ -177,7 +166,7 @@ public class Execute | |||
| } | |||
| catch( final Exception e ) | |||
| { | |||
| final String message = REZ.getString( "execute.failed.error", m_command.getExecutable() ); | |||
| final String message = REZ.getString( "execute.failed.error", getExecutable() ); | |||
| throw new TaskException( message, e ); | |||
| } | |||
| } | |||
| @@ -207,7 +196,7 @@ public class Execute | |||
| */ | |||
| private void validate() throws TaskException | |||
| { | |||
| if( null == m_command.getExecutable() ) | |||
| if( null == getExecutable() ) | |||
| { | |||
| final String message = REZ.getString( "execute.no-executable.error" ); | |||
| throw new TaskException( message ); | |||
| @@ -250,7 +239,7 @@ public class Execute | |||
| if( ! m_ignoreReturnCode && returnCode != m_returnCode ) | |||
| { | |||
| final String message = REZ.getString( "execute.bad-resultcode.error", | |||
| m_command.getExecutable(), | |||
| getExecutable(), | |||
| new Integer(returnCode) ); | |||
| throw new TaskException( message ); | |||
| } | |||
| @@ -265,7 +254,7 @@ public class Execute | |||
| throws ExecException | |||
| { | |||
| // Build the command line | |||
| final String[] command = m_command.getCommandline(); | |||
| final String[] command = getCommandLine(); | |||
| // Build the environment | |||
| final Properties newEnvironment = new Properties(); | |||
| @@ -286,4 +275,16 @@ public class Execute | |||
| newEnvironment, | |||
| workingDir ); | |||
| } | |||
| /** | |||
| * Builds the command line. | |||
| */ | |||
| private String[] getCommandLine() | |||
| { | |||
| final String[] args = getArguments(); | |||
| final String[] result = new String[ args.length + 1 ]; | |||
| result[ 0 ] = getExecutable().replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); | |||
| System.arraycopy( args, 0, result, 1, args.length ); | |||
| return result; | |||
| } | |||
| } | |||
| @@ -19,9 +19,9 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.EnvironmentData; | |||
| import org.apache.tools.todo.types.SysProperties; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| /** | |||
| @@ -46,8 +46,8 @@ public class ExecuteJava | |||
| private final Path m_classPath = new Path(); | |||
| private final EnvironmentData m_sysProperties = new EnvironmentData(); | |||
| private final Commandline m_args = new Commandline(); | |||
| private final Commandline m_vmArgs = new Commandline(); | |||
| private final ArgumentList m_args = new ArgumentList(); | |||
| private final ArgumentList m_vmArgs = new ArgumentList(); | |||
| private boolean m_fork; | |||
| private File m_workingDirectory; | |||
| private File m_jar; | |||
| @@ -150,7 +150,7 @@ public class ExecuteJava | |||
| * | |||
| * @return the application's arguments. Can be modified. | |||
| */ | |||
| public Commandline getArguments() | |||
| public ArgumentList getArguments() | |||
| { | |||
| return m_args; | |||
| } | |||
| @@ -161,7 +161,7 @@ public class ExecuteJava | |||
| * | |||
| * @return the JVM aguments. Can be modified. | |||
| */ | |||
| public Commandline getVmArguments() | |||
| public ArgumentList getVmArguments() | |||
| { | |||
| return m_vmArgs; | |||
| } | |||
| @@ -287,52 +287,51 @@ public class ExecuteJava | |||
| exe.setIgnoreReturnCode( m_ignoreReturnCode ); | |||
| // Setup the command line | |||
| final Commandline command = exe.getCommandline(); | |||
| // Executable name | |||
| if( m_jvm != null ) | |||
| { | |||
| command.setExecutable( m_jvm ); | |||
| exe.setExecutable( m_jvm ); | |||
| } | |||
| else | |||
| { | |||
| command.setExecutable( getJavaExecutableName() ); | |||
| exe.setExecutable( getJavaExecutableName() ); | |||
| } | |||
| // JVM arguments | |||
| command.addArguments( m_vmArgs ); | |||
| exe.addArguments( m_vmArgs ); | |||
| // Max memory size | |||
| if( m_maxMemory != null ) | |||
| { | |||
| command.addArgument( "-Xmx" + m_maxMemory ); | |||
| exe.addArgument( "-Xmx" + m_maxMemory ); | |||
| } | |||
| // System properties | |||
| final String[] props = SysProperties.getJavaVariables( m_sysProperties ); | |||
| command.addArguments( props ); | |||
| exe.addArguments( props ); | |||
| // Classpath | |||
| final String[] classpath = m_classPath.listFiles( context ); | |||
| if( classpath.length > 0 ) | |||
| { | |||
| command.addArgument( "-classpath" ); | |||
| command.addArgument( PathUtil.formatPath( classpath ) ); | |||
| exe.addArgument( "-classpath" ); | |||
| exe.addArgument( PathUtil.formatPath( classpath ) ); | |||
| } | |||
| // What to execute | |||
| if( m_jar != null ) | |||
| { | |||
| command.addArgument( "-jar" ); | |||
| command.addArgument( m_jar ); | |||
| exe.addArgument( "-jar" ); | |||
| exe.addArgument( m_jar ); | |||
| } | |||
| else | |||
| { | |||
| command.addArgument( m_className ); | |||
| exe.addArgument( m_className ); | |||
| } | |||
| // Java app arguments | |||
| command.addArguments( m_args ); | |||
| exe.addArguments( m_args ); | |||
| // Execute | |||
| return exe.execute( context ); | |||
| @@ -135,8 +135,7 @@ public class Cab | |||
| File listFile = createListFile( files ); | |||
| Execute exe = new Execute(); | |||
| exe.setWorkingDirectory( m_baseDir ); | |||
| final Commandline cmd = createCommand( listFile ); | |||
| exe.setCommandline( cmd ); | |||
| createCommand( exe, listFile ); | |||
| exe.execute( getContext() ); | |||
| listFile.delete(); | |||
| @@ -243,10 +242,9 @@ public class Cab | |||
| /** | |||
| * Create the cabarc command line to use. | |||
| */ | |||
| protected Commandline createCommand( final File listFile ) | |||
| protected void createCommand( final Commandline cmd, final File listFile ) | |||
| throws TaskException | |||
| { | |||
| final Commandline cmd = new Commandline(); | |||
| cmd.setExecutable( "cabarc" ); | |||
| cmd.addArgument( "-r" ); | |||
| cmd.addArgument( "-p" ); | |||
| @@ -265,8 +263,6 @@ public class Cab | |||
| cmd.addArgument( "n" ); | |||
| cmd.addArgument( m_cabFile ); | |||
| cmd.addArgument( "@" + listFile.getAbsolutePath() ); | |||
| return cmd; | |||
| } | |||
| /** | |||
| @@ -14,10 +14,10 @@ import java.util.StringTokenizer; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| /** | |||
| * Task to generate JNI header files using javah. This task can take the | |||
| @@ -207,7 +207,7 @@ public class Javah | |||
| * Logs the compilation parameters, adds the files to compile and logs the | |||
| * &qout;niceSourceList" | |||
| */ | |||
| private void logAndAddFilesToCompile( final Commandline cmd ) | |||
| private void logAndAddFilesToCompile( final ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| final String[] args = cmd.getArguments(); | |||
| @@ -251,10 +251,10 @@ public class Javah | |||
| /** | |||
| * Does the command line argument processing common to classic and modern. | |||
| */ | |||
| private Commandline setupJavahCommand() | |||
| private ArgumentList setupJavahCommand() | |||
| throws TaskException | |||
| { | |||
| final Commandline cmd = new Commandline(); | |||
| final ArgumentList cmd = new ArgumentList(); | |||
| if( m_destDir != null ) | |||
| { | |||
| @@ -316,7 +316,7 @@ public class Javah | |||
| private void doClassicCompile() | |||
| throws TaskException | |||
| { | |||
| Commandline cmd = setupJavahCommand(); | |||
| ArgumentList cmd = setupJavahCommand(); | |||
| // Use reflection to be able to build on all JDKs | |||
| /* | |||
| @@ -8,10 +8,8 @@ | |||
| package org.apache.tools.todo.taskdefs; | |||
| import java.io.File; | |||
| import org.apache.aut.nativelib.ExecManager; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| @@ -89,20 +87,18 @@ public class Rpm | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| final Commandline cmd = createCommand(); | |||
| final Execute exe = new Execute(); | |||
| final Execute exe = createCommand(); | |||
| exe.setWorkingDirectory( m_topDir ); | |||
| exe.setCommandline( cmd ); | |||
| final String message = "Building the RPM based on the " + m_specFile + " file"; | |||
| getContext().info( message ); | |||
| exe.execute( getContext() ); | |||
| } | |||
| private Commandline createCommand() | |||
| private Execute createCommand() | |||
| throws TaskException | |||
| { | |||
| final Commandline cmd = new Commandline(); | |||
| final Execute cmd = new Execute(); | |||
| cmd.setExecutable( "rpm" ); | |||
| if( m_topDir != null ) | |||
| { | |||
| @@ -126,6 +122,7 @@ public class Rpm | |||
| } | |||
| cmd.addArgument( "SPECS/" + m_specFile ); | |||
| return cmd; | |||
| } | |||
| } | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.todo.taskdefs.ccm; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Class common to all check commands (checkout, checkin,checkin default task); | |||
| @@ -127,7 +128,7 @@ public class CCMCheck extends Continuus | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void checkOptions( Commandline cmd ) | |||
| private void checkOptions( ArgumentList cmd ) | |||
| { | |||
| if( getComment() != null ) | |||
| { | |||
| @@ -143,7 +144,7 @@ public class CCMCheck extends Continuus | |||
| if( getFile() != null ) | |||
| { | |||
| cmd.addArgument( _file.getAbsolutePath() ); | |||
| cmd.addArgument( _file ); | |||
| }// end of if () | |||
| } | |||
| } | |||
| @@ -12,6 +12,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task allows to create new ccm task and set it as the default | |||
| @@ -135,7 +136,7 @@ public class CCMCreateTask | |||
| public void execute() | |||
| throws TaskException | |||
| { | |||
| final Commandline commandLine = determineTask(); | |||
| final ArgumentList commandLine = determineTask(); | |||
| if( null == m_task ) | |||
| { | |||
| final String message = "Error determining task"; | |||
| @@ -150,7 +151,7 @@ public class CCMCreateTask | |||
| run( cmd, null ); | |||
| } | |||
| private Commandline determineTask() | |||
| private ArgumentList determineTask() | |||
| throws TaskException | |||
| { | |||
| final Commandline commandLine = new Commandline(); | |||
| @@ -169,7 +170,7 @@ public class CCMCreateTask | |||
| /** | |||
| * Check the command line options. | |||
| */ | |||
| private void checkOptions( final Commandline cmd ) | |||
| private void checkOptions( final ArgumentList cmd ) | |||
| { | |||
| if( m_comment != null ) | |||
| { | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.todo.taskdefs.ccm; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task allows to reconfigure a project, recurcively or not | |||
| @@ -91,7 +92,7 @@ public class CCMReconfigure | |||
| /** | |||
| * Build the command line options. | |||
| */ | |||
| private void checkOptions( final Commandline cmd ) | |||
| private void checkOptions( final ArgumentList cmd ) | |||
| { | |||
| if( m_recurse == true ) | |||
| { | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.todo.taskdefs.clearcase; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform Checkin command to ClearCase. <p> | |||
| @@ -347,7 +348,7 @@ public class CCCheckin extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getCommentCommand( Commandline cmd ) | |||
| private void getCommentCommand( ArgumentList cmd ) | |||
| { | |||
| if( getComment() != null ) | |||
| { | |||
| @@ -367,7 +368,7 @@ public class CCCheckin extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getCommentFileCommand( Commandline cmd ) | |||
| private void getCommentFileCommand( ArgumentList cmd ) | |||
| { | |||
| if( getCommentFile() != null ) | |||
| { | |||
| @@ -387,7 +388,7 @@ public class CCCheckin extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void checkOptions( Commandline cmd ) | |||
| private void checkOptions( ArgumentList cmd ) | |||
| { | |||
| if( getComment() != null ) | |||
| { | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.todo.taskdefs.clearcase; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform Checkout command to ClearCase. <p> | |||
| @@ -435,7 +436,7 @@ public class CCCheckout extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getBranchCommand( Commandline cmd ) | |||
| private void getBranchCommand( ArgumentList cmd ) | |||
| { | |||
| if( getBranch() != null ) | |||
| { | |||
| @@ -455,7 +456,7 @@ public class CCCheckout extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getCommentCommand( Commandline cmd ) | |||
| private void getCommentCommand( ArgumentList cmd ) | |||
| { | |||
| if( getComment() != null ) | |||
| { | |||
| @@ -475,7 +476,7 @@ public class CCCheckout extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getCommentFileCommand( Commandline cmd ) | |||
| private void getCommentFileCommand( ArgumentList cmd ) | |||
| { | |||
| if( getCommentFile() != null ) | |||
| { | |||
| @@ -495,7 +496,7 @@ public class CCCheckout extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getOutCommand( Commandline cmd ) | |||
| private void getOutCommand( ArgumentList cmd ) | |||
| { | |||
| if( getOut() != null ) | |||
| { | |||
| @@ -515,7 +516,7 @@ public class CCCheckout extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void checkOptions( Commandline cmd ) | |||
| private void checkOptions( ArgumentList cmd ) | |||
| { | |||
| // ClearCase items | |||
| if( getReserved() ) | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.todo.taskdefs.clearcase; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform UnCheckout command to ClearCase. <p> | |||
| @@ -139,7 +140,7 @@ public class CCUnCheckout extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void checkOptions( Commandline cmd ) | |||
| private void checkOptions( ArgumentList cmd ) | |||
| { | |||
| // ClearCase items | |||
| if( getKeepCopy() ) | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.todo.taskdefs.clearcase; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform an Update command to ClearCase. <p> | |||
| @@ -349,7 +350,7 @@ public class CCUpdate extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getLogCommand( Commandline cmd ) | |||
| private void getLogCommand( ArgumentList cmd ) | |||
| { | |||
| if( getLog() == null ) | |||
| { | |||
| @@ -373,7 +374,7 @@ public class CCUpdate extends ClearCase | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void checkOptions( Commandline cmd ) | |||
| private void checkOptions( ArgumentList cmd ) | |||
| { | |||
| // ClearCase items | |||
| if( getGraphical() ) | |||
| @@ -18,6 +18,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.myrmidon.framework.FileSet; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| @@ -99,7 +100,7 @@ public abstract class DefaultCompilerAdapter | |||
| return m_attributes; | |||
| } | |||
| protected Commandline setupJavacCommand() | |||
| protected ArgumentList setupJavacCommand() | |||
| throws TaskException | |||
| { | |||
| return setupJavacCommand( false ); | |||
| @@ -112,10 +113,10 @@ public abstract class DefaultCompilerAdapter | |||
| * @param debugLevelCheck Description of Parameter | |||
| * @return Description of the Returned Value | |||
| */ | |||
| protected Commandline setupJavacCommand( boolean debugLevelCheck ) | |||
| protected ArgumentList setupJavacCommand( boolean debugLevelCheck ) | |||
| throws TaskException | |||
| { | |||
| Commandline cmd = new Commandline(); | |||
| ArgumentList cmd = new ArgumentList(); | |||
| setupJavacCommandlineSwitches( cmd, debugLevelCheck ); | |||
| logFilesToCompile( cmd ); | |||
| addFilesToCompile( cmd ); | |||
| @@ -130,7 +131,7 @@ public abstract class DefaultCompilerAdapter | |||
| * @param useDebugLevel Description of Parameter | |||
| * @return Description of the Returned Value | |||
| */ | |||
| protected Commandline setupJavacCommandlineSwitches( Commandline cmd, | |||
| protected ArgumentList setupJavacCommandlineSwitches( ArgumentList cmd, | |||
| boolean useDebugLevel ) | |||
| throws TaskException | |||
| { | |||
| @@ -253,10 +254,10 @@ public abstract class DefaultCompilerAdapter | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| protected Commandline setupModernJavacCommand() | |||
| protected ArgumentList setupModernJavacCommand() | |||
| throws TaskException | |||
| { | |||
| Commandline cmd = new Commandline(); | |||
| ArgumentList cmd = new ArgumentList(); | |||
| setupModernJavacCommandlineSwitches( cmd ); | |||
| logFilesToCompile( cmd ); | |||
| @@ -271,7 +272,7 @@ public abstract class DefaultCompilerAdapter | |||
| * @param cmd Description of Parameter | |||
| * @return Description of the Returned Value | |||
| */ | |||
| protected Commandline setupModernJavacCommandlineSwitches( Commandline cmd ) | |||
| protected ArgumentList setupModernJavacCommandlineSwitches( ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| setupJavacCommandlineSwitches( cmd, true ); | |||
| @@ -309,7 +310,7 @@ public abstract class DefaultCompilerAdapter | |||
| * | |||
| * @param cmd The feature to be added to the CurrentCompilerArgs attribute | |||
| */ | |||
| protected void addCurrentCompilerArgs( Commandline cmd ) | |||
| protected void addCurrentCompilerArgs( ArgumentList cmd ) | |||
| { | |||
| cmd.addArguments( getJavac().getCurrentCompilerArgs() ); | |||
| } | |||
| @@ -382,7 +383,7 @@ public abstract class DefaultCompilerAdapter | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| protected void logFilesToCompile( final Commandline cmd ) | |||
| protected void logFilesToCompile( final ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| final String[] cmdline = cmd.getArguments(); | |||
| @@ -409,7 +410,7 @@ public abstract class DefaultCompilerAdapter | |||
| /** | |||
| * Adds the files to compile to a command-line | |||
| */ | |||
| protected void addFilesToCompile( final Commandline cmd ) | |||
| protected void addFilesToCompile( final ArgumentList cmd ) | |||
| { | |||
| for( int i = 0; i < m_compileList.length; i++ ) | |||
| { | |||
| @@ -13,6 +13,7 @@ import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter; | |||
| /** | |||
| @@ -32,7 +33,7 @@ public class Javac12 extends DefaultCompilerAdapter | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Using classic compiler" ); | |||
| Commandline cmd = setupJavacCommand( true ); | |||
| ArgumentList cmd = setupJavacCommand( true ); | |||
| try | |||
| { | |||
| @@ -11,6 +11,7 @@ import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter; | |||
| /** | |||
| @@ -35,7 +36,7 @@ public class Javac13 extends DefaultCompilerAdapter | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Using modern compiler" ); | |||
| Commandline cmd = setupModernJavacCommand(); | |||
| ArgumentList cmd = setupModernJavacCommand(); | |||
| // Use reflection to be able to build on all JDKs >= 1.1: | |||
| try | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.todo.taskdefs.javac; | |||
| import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| @@ -26,7 +27,7 @@ public class Kjc extends DefaultCompilerAdapter | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Using kjc compiler" ); | |||
| Commandline cmd = setupKjcCommand(); | |||
| ArgumentList cmd = setupKjcCommand(); | |||
| try | |||
| { | |||
| @@ -63,10 +64,10 @@ public class Kjc extends DefaultCompilerAdapter | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| protected Commandline setupKjcCommand() | |||
| protected ArgumentList setupKjcCommand() | |||
| throws TaskException | |||
| { | |||
| Commandline cmd = new Commandline(); | |||
| ArgumentList cmd = new Commandline(); | |||
| // generate classpath, because kjc does't support sourcepath. | |||
| Path classpath = new Path(); | |||
| @@ -27,6 +27,7 @@ import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.tools.todo.types.ScannerUtil; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * This task makes it easy to generate Javadoc documentation for a collection of | |||
| @@ -65,7 +66,7 @@ public class Javadoc | |||
| extends AbstractTask | |||
| implements ExecOutputHandler | |||
| { | |||
| private Commandline m_command = new Commandline(); | |||
| private ArgumentList m_command = new ArgumentList(); | |||
| private Path m_sourcePath; | |||
| private File m_destDir; | |||
| @@ -882,7 +883,7 @@ public class Javadoc | |||
| * @param packages Description of Parameter | |||
| * @param excludePackages Description of Parameter | |||
| */ | |||
| private void evaluatePackages( Commandline toExecute, Path sourcePath, | |||
| private void evaluatePackages( ArgumentList toExecute, Path sourcePath, | |||
| ArrayList packages, ArrayList excludePackages ) | |||
| throws TaskException | |||
| { | |||
| @@ -14,6 +14,7 @@ import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.taskdefs.jsp.JspC; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| /** | |||
| @@ -61,7 +62,7 @@ public abstract class DefaultCompilerAdapter | |||
| */ | |||
| protected void logAndAddFilesToCompile( JspC jspc, | |||
| ArrayList compileList, | |||
| Commandline cmd ) | |||
| ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| final String[] args = cmd.getArguments(); | |||
| @@ -8,12 +8,10 @@ | |||
| package org.apache.tools.todo.taskdefs.jsp.compilers; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.antlib.java.JavaTask; | |||
| import org.apache.tools.todo.taskdefs.jsp.JspC; | |||
| import org.apache.tools.todo.types.Argument; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * The implementation of the jasper compiler. This is a cut-and-paste of the | |||
| @@ -50,7 +48,7 @@ public class JasperC | |||
| /* | |||
| * ------------------------------------------------------------ | |||
| */ | |||
| private void setupJasperCommand( final Commandline cmd ) | |||
| private void setupJasperCommand( final ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| JspC jspc = getJspc(); | |||
| @@ -27,6 +27,7 @@ import org.apache.tools.todo.types.EnumeratedAttribute; | |||
| import org.apache.tools.todo.types.EnvironmentData; | |||
| import org.apache.tools.todo.types.EnvironmentVariable; | |||
| import org.apache.tools.todo.types.SysProperties; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Ant task to run JUnit tests. <p> | |||
| @@ -112,7 +113,7 @@ public class JUnitTask extends AbstractTask | |||
| private String maxMem; | |||
| private EnvironmentData sysProperties = new EnvironmentData(); | |||
| private Path classPath = new Path(); | |||
| private Commandline vmArgs = new Commandline(); | |||
| private ArgumentList vmArgs = new Commandline(); | |||
| /** | |||
| * The directory to invoke the VM in. Ignored if no JVM is forked. | |||
| @@ -13,10 +13,10 @@ import java.util.Random; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.FileNameMapper; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.myrmidon.framework.file.FileListUtil; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| /** | |||
| * This is the default implementation for the RmicAdapter interface. Currently, | |||
| @@ -88,7 +88,7 @@ public abstract class DefaultRmicAdapter | |||
| * | |||
| * @return Description of the Returned Value | |||
| */ | |||
| protected Commandline setupRmicCommand() | |||
| protected ArgumentList setupRmicCommand() | |||
| throws TaskException | |||
| { | |||
| return setupRmicCommand( null ); | |||
| @@ -100,10 +100,10 @@ public abstract class DefaultRmicAdapter | |||
| * @param options additional parameters needed by a specific implementation. | |||
| * @return Description of the Returned Value | |||
| */ | |||
| protected Commandline setupRmicCommand( String[] options ) | |||
| protected ArgumentList setupRmicCommand( String[] options ) | |||
| throws TaskException | |||
| { | |||
| Commandline cmd = new Commandline(); | |||
| ArgumentList cmd = new ArgumentList(); | |||
| if( options != null ) | |||
| { | |||
| @@ -220,7 +220,7 @@ public abstract class DefaultRmicAdapter | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| protected void logAndAddFilesToCompile( final Commandline cmd ) | |||
| protected void logAndAddFilesToCompile( final ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| ArrayList compileList = attributes.getCompileList(); | |||
| @@ -12,6 +12,7 @@ import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.taskdefs.rmic.DefaultRmicAdapter; | |||
| /** | |||
| @@ -26,7 +27,7 @@ public class KaffeRmic extends DefaultRmicAdapter | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Using Kaffe rmic" ); | |||
| Commandline cmd = setupRmicCommand(); | |||
| ArgumentList cmd = setupRmicCommand(); | |||
| try | |||
| { | |||
| @@ -14,6 +14,7 @@ import java.lang.reflect.Method; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.taskdefs.rmic.DefaultRmicAdapter; | |||
| /** | |||
| @@ -28,7 +29,7 @@ public class SunRmic extends DefaultRmicAdapter | |||
| throws TaskException | |||
| { | |||
| getTaskContext().debug( "Using SUN rmic compiler" ); | |||
| Commandline cmd = setupRmicCommand(); | |||
| ArgumentList cmd = setupRmicCommand(); | |||
| // Create an instance of the rmic, redirecting output to | |||
| // the project log | |||
| @@ -12,6 +12,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.framework.java.ExecuteJava; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.taskdefs.rmic.DefaultRmicAdapter; | |||
| /** | |||
| @@ -49,7 +50,7 @@ public class WLRmic extends DefaultRmicAdapter | |||
| final ExecuteJava exe = new ExecuteJava(); | |||
| exe.setClassName( "weblogic.rmic" ); | |||
| final Commandline cmd = setupRmicCommand( new String[]{"-noexit"} ); | |||
| final ArgumentList cmd = setupRmicCommand( new String[]{"-noexit"} ); | |||
| exe.getArguments().addArguments( cmd ); | |||
| exe.execute( getTaskContext() ); | |||
| @@ -19,6 +19,7 @@ import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.myrmidon.framework.FileSet; | |||
| import org.apache.tools.todo.types.Argument; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| import org.apache.aut.nativelib.PathUtil; | |||
| @@ -57,9 +58,9 @@ public class Coverage | |||
| private String m_vm; | |||
| private File m_workingDir; | |||
| private String m_className; | |||
| private Commandline m_args = new Commandline(); | |||
| private ArgumentList m_args = new ArgumentList(); | |||
| private Path m_classpath = new Path(); | |||
| private Commandline m_vmArgs = new Commandline(); | |||
| private ArgumentList m_vmArgs = new ArgumentList(); | |||
| /** | |||
| * classname to run as standalone or runner for filesets | |||
| @@ -241,12 +242,10 @@ public class Coverage | |||
| { | |||
| // we need to run Coverage from his directory due to dll/jar issues | |||
| final Execute exe = new Execute(); | |||
| final Commandline cmdl = exe.getCommandline(); | |||
| cmdl.setExecutable( new File( m_home, "jplauncher" ).getAbsolutePath() ); | |||
| cmdl.addArgument( "-jp_input=" + paramfile.getAbsolutePath() ); | |||
| exe.setExecutable( new File( m_home, "jplauncher" ).getAbsolutePath() ); | |||
| exe.addArgument( "-jp_input=" + paramfile.getAbsolutePath() ); | |||
| // use the custom handler for stdin issues | |||
| exe.setCommandline( cmdl ); | |||
| exe.execute( getContext() ); | |||
| } | |||
| finally | |||
| @@ -269,7 +268,7 @@ public class Coverage | |||
| protected String[] getParameters() | |||
| throws TaskException | |||
| { | |||
| Commandline params = new Commandline(); | |||
| ArgumentList params = new ArgumentList(); | |||
| params.addArgument( "-jp_function=coverage" ); | |||
| if( m_vm != null ) | |||
| { | |||
| @@ -59,8 +59,8 @@ public class StyleBook | |||
| validate(); | |||
| addArg( new Argument( "targetDirectory=" + m_targetDirectory ) ); | |||
| addArg( new Argument( m_book.toString() ) ); | |||
| addArg( new Argument( m_skinDirectory.toString() ) ); | |||
| addArg( new Argument( m_book ) ); | |||
| addArg( new Argument( m_skinDirectory ) ); | |||
| if( null != m_loaderConfig ) | |||
| { | |||
| addArg( new Argument( "loaderConfig=" + m_loaderConfig ) ); | |||
| @@ -9,13 +9,11 @@ package org.apache.tools.todo.taskdefs.text; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskContext; | |||
| import org.apache.myrmidon.framework.FileNameMapper; | |||
| import org.apache.tools.todo.taskdefs.MatchingTask; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.DirectoryScanner; | |||
| import org.apache.tools.todo.types.SourceFileScanner; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.tools.todo.util.mappers.IdentityMapper; | |||
| /** | |||
| @@ -180,7 +178,7 @@ public class Native2Ascii | |||
| + " would overwrite its self" ); | |||
| } | |||
| final Commandline cmd = buildCommand( srcFile, destFile ); | |||
| final ArgumentList cmd = buildCommand( srcFile, destFile ); | |||
| // Make intermediate directories if needed | |||
| // XXX JDK 1.1 dosen't have File.getParentFile, | |||
| @@ -201,10 +199,10 @@ public class Native2Ascii | |||
| } | |||
| } | |||
| private Commandline buildCommand( final File srcFile, | |||
| private ArgumentList buildCommand( final File srcFile, | |||
| final File destFile ) | |||
| { | |||
| final Commandline cmd = new Commandline();// Command line to run | |||
| final ArgumentList cmd = new ArgumentList();// Command line to run | |||
| // Set up the basic args (this could be done once, but | |||
| // it's cleaner here) | |||
| if( m_reverse ) | |||
| @@ -14,6 +14,7 @@ import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Execute; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * A base class for creating tasks for executing commands on Visual SourceSafe. | |||
| @@ -179,7 +180,7 @@ public abstract class MSVSS | |||
| /** | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| public void getLoginCommand( Commandline cmd ) | |||
| public void getLoginCommand( ArgumentList cmd ) | |||
| { | |||
| if( m_vssLogin == null ) | |||
| { | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.todo.taskdefs.vss; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform CheckIn commands to Microsoft Visual Source Safe. | |||
| @@ -83,7 +84,7 @@ public class MSVSSCHECKIN | |||
| * Checks the value set for the autoResponse. if it equals "Y" then we | |||
| * return -I-Y if it equals "N" then we return -I-N otherwise we return -I | |||
| */ | |||
| public void getAutoresponse( final Commandline cmd ) | |||
| public void getAutoresponse( final ArgumentList cmd ) | |||
| { | |||
| if( null == m_autoResponse ) | |||
| { | |||
| @@ -109,7 +110,7 @@ public class MSVSSCHECKIN | |||
| * | |||
| * The localpath is created if it didn't exist | |||
| */ | |||
| private void getLocalpathCommand( final Commandline cmd ) | |||
| private void getLocalpathCommand( final ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| if( m_localPath == null ) | |||
| @@ -134,7 +135,7 @@ public class MSVSSCHECKIN | |||
| cmd.addArgument( FLAG_OVERRIDE_WORKING_DIR + m_localPath ); | |||
| } | |||
| private void getRecursiveCommand( final Commandline cmd ) | |||
| private void getRecursiveCommand( final ArgumentList cmd ) | |||
| { | |||
| if( !m_recursive ) | |||
| { | |||
| @@ -146,7 +147,7 @@ public class MSVSSCHECKIN | |||
| } | |||
| } | |||
| private void getWritableCommand( final Commandline cmd ) | |||
| private void getWritableCommand( final ArgumentList cmd ) | |||
| { | |||
| if( !m_writable ) | |||
| { | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.todo.taskdefs.vss; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform CheckOut commands to Microsoft Visual Source Safe. | |||
| @@ -118,7 +119,7 @@ public class MSVSSCHECKOUT | |||
| * Checks the value set for the autoResponse. if it equals "Y" then we | |||
| * return -I-Y if it equals "N" then we return -I-N otherwise we return -I | |||
| */ | |||
| public void getAutoresponse( final Commandline cmd ) | |||
| public void getAutoresponse( final ArgumentList cmd ) | |||
| { | |||
| if( m_autoResponse == null ) | |||
| { | |||
| @@ -144,7 +145,7 @@ public class MSVSSCHECKOUT | |||
| * | |||
| * The localpath is created if it didn't exist | |||
| */ | |||
| public void getLocalpathCommand( final Commandline cmd ) | |||
| public void getLocalpathCommand( final ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| // make sure m_LocalDir exists, create it if it doesn't | |||
| @@ -167,7 +168,7 @@ public class MSVSSCHECKOUT | |||
| cmd.addArgument( FLAG_OVERRIDE_WORKING_DIR + m_localPath ); | |||
| } | |||
| private void getRecursiveCommand( final Commandline cmd ) | |||
| private void getRecursiveCommand( final ArgumentList cmd ) | |||
| { | |||
| if( !m_recursive ) | |||
| { | |||
| @@ -183,7 +184,7 @@ public class MSVSSCHECKOUT | |||
| * Simple order of priority. Returns the first specified of version, date, | |||
| * label If none of these was specified returns "" | |||
| */ | |||
| private void getVersionCommand( final Commandline cmd ) | |||
| private void getVersionCommand( final ArgumentList cmd ) | |||
| { | |||
| if( null != m_version ) | |||
| { | |||
| @@ -10,6 +10,7 @@ package org.apache.tools.todo.taskdefs.vss; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| import org.apache.myrmidon.framework.file.Path; | |||
| /** | |||
| @@ -339,7 +340,7 @@ public class MSVSSGET extends MSVSS | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| public void getAutoresponse( Commandline cmd ) | |||
| public void getAutoresponse( ArgumentList cmd ) | |||
| { | |||
| if( m_AutoResponse == null ) | |||
| @@ -369,7 +370,7 @@ public class MSVSSGET extends MSVSS | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| public void getLocalpathCommand( Commandline cmd ) | |||
| public void getLocalpathCommand( ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| if( m_LocalPath == null ) | |||
| @@ -395,7 +396,7 @@ public class MSVSSGET extends MSVSS | |||
| } | |||
| } | |||
| public void getQuietCommand( Commandline cmd ) | |||
| public void getQuietCommand( ArgumentList cmd ) | |||
| { | |||
| if( m_Quiet ) | |||
| { | |||
| @@ -406,7 +407,7 @@ public class MSVSSGET extends MSVSS | |||
| /** | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| public void getRecursiveCommand( Commandline cmd ) | |||
| public void getRecursiveCommand( ArgumentList cmd ) | |||
| { | |||
| if( !m_Recursive ) | |||
| { | |||
| @@ -424,7 +425,7 @@ public class MSVSSGET extends MSVSS | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| public void getVersionCommand( Commandline cmd ) | |||
| public void getVersionCommand( ArgumentList cmd ) | |||
| { | |||
| if( m_Version != null ) | |||
| @@ -444,7 +445,7 @@ public class MSVSSGET extends MSVSS | |||
| /** | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| public void getWritableCommand( Commandline cmd ) | |||
| public void getWritableCommand( ArgumentList cmd ) | |||
| { | |||
| if( !m_Writable ) | |||
| { | |||
| @@ -17,6 +17,7 @@ import java.util.GregorianCalendar; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.EnumeratedAttribute; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform HISTORY commands to Microsoft Visual Source Safe. | |||
| @@ -277,7 +278,7 @@ public class MSVSSHISTORY extends MSVSS | |||
| * | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| private void getOutputCommand( Commandline cmd ) | |||
| private void getOutputCommand( ArgumentList cmd ) | |||
| { | |||
| if( m_OutputFileName != null ) | |||
| { | |||
| @@ -288,7 +289,7 @@ public class MSVSSHISTORY extends MSVSS | |||
| /** | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| private void getRecursiveCommand( Commandline cmd ) | |||
| private void getRecursiveCommand( ArgumentList cmd ) | |||
| { | |||
| if( !m_Recursive ) | |||
| { | |||
| @@ -305,7 +306,7 @@ public class MSVSSHISTORY extends MSVSS | |||
| * | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| private void getUserCommand( Commandline cmd ) | |||
| private void getUserCommand( ArgumentList cmd ) | |||
| { | |||
| if( m_User != null ) | |||
| { | |||
| @@ -319,7 +320,7 @@ public class MSVSSHISTORY extends MSVSS | |||
| * @param cmd the commandline the command is to be added to | |||
| * @exception TaskException Description of Exception | |||
| */ | |||
| private void getVersionDateCommand( Commandline cmd ) | |||
| private void getVersionDateCommand( ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| if( m_FromDate == null && m_ToDate == null && m_NumDays == Integer.MIN_VALUE ) | |||
| @@ -378,7 +379,7 @@ public class MSVSSHISTORY extends MSVSS | |||
| * @param cmd the commandline the command is to be added to | |||
| * @exception TaskException Description of Exception | |||
| */ | |||
| private void getVersionLabelCommand( Commandline cmd ) | |||
| private void getVersionLabelCommand( ArgumentList cmd ) | |||
| throws TaskException | |||
| { | |||
| if( m_FromLabel == null && m_ToLabel == null ) | |||
| @@ -9,6 +9,7 @@ package org.apache.tools.todo.taskdefs.vss; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.types.Commandline; | |||
| import org.apache.tools.todo.types.ArgumentList; | |||
| /** | |||
| * Task to perform LABEL commands to Microsoft Visual Source Safe. <p> | |||
| @@ -242,7 +243,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * | |||
| * @param cmd Description of Parameter | |||
| */ | |||
| public void getAutoresponse( Commandline cmd ) | |||
| public void getAutoresponse( ArgumentList cmd ) | |||
| { | |||
| if( m_AutoResponse == null ) | |||
| @@ -290,7 +291,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| public void getLabelCommand( Commandline cmd ) | |||
| public void getLabelCommand( ArgumentList cmd ) | |||
| { | |||
| if( m_Label != null ) | |||
| { | |||
| @@ -303,7 +304,7 @@ public class MSVSSLABEL extends MSVSS | |||
| * | |||
| * @param cmd the commandline the command is to be added to | |||
| */ | |||
| public void getVersionCommand( Commandline cmd ) | |||
| public void getVersionCommand( ArgumentList cmd ) | |||
| { | |||
| if( m_Version != null ) | |||
| { | |||
| @@ -0,0 +1,85 @@ | |||
| /* | |||
| * 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.todo.types; | |||
| import java.util.ArrayList; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| /** | |||
| * A utility class to use to assemble a list of command-line arguments. | |||
| * | |||
| * @author thomas.haas@softwired-inc.com | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||
| * @version $Revision$ $Date$ | |||
| */ | |||
| public class ArgumentList | |||
| { | |||
| protected final ArrayList m_arguments = new ArrayList(); | |||
| /** | |||
| * Returns all arguments defined by <code>addLine</code>, <code>addValue</code> | |||
| * or the argument object. | |||
| * | |||
| * @return The Arguments value | |||
| */ | |||
| public String[] getArguments() | |||
| { | |||
| final int size = m_arguments.size(); | |||
| final ArrayList result = new ArrayList( size * 2 ); | |||
| for( int i = 0; i < size; i++ ) | |||
| { | |||
| final Argument arg = (Argument)m_arguments.get( i ); | |||
| final String[] s = arg.getParts(); | |||
| for( int j = 0; j < s.length; j++ ) | |||
| { | |||
| result.add( s[ j ] ); | |||
| } | |||
| } | |||
| final String[] res = new String[ result.size() ]; | |||
| return (String[])result.toArray( res ); | |||
| } | |||
| public void addArguments( final String[] args ) | |||
| { | |||
| for( int i = 0; i < args.length; i++ ) | |||
| { | |||
| addArgument( args[ i ] ); | |||
| } | |||
| } | |||
| public void addArguments( final ArgumentList args ) | |||
| { | |||
| addArguments( args.getArguments() ); | |||
| } | |||
| public void addArgument( final File argument ) | |||
| { | |||
| addArgument( new Argument( argument ) ); | |||
| } | |||
| public void addArgument( final String argument ) | |||
| { | |||
| addArgument( new Argument( argument ) ); | |||
| } | |||
| public void addArgument( final Argument argument ) | |||
| { | |||
| m_arguments.add( argument ); | |||
| } | |||
| public void addLine( final String line ) | |||
| throws TaskException | |||
| { | |||
| final String[] parts = FileUtils.translateCommandline( line ); | |||
| addArguments( parts ); | |||
| } | |||
| } | |||
| @@ -7,12 +7,7 @@ | |||
| */ | |||
| package org.apache.tools.todo.types; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.excalibur.util.StringUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.todo.util.FileUtils; | |||
| import org.apache.tools.todo.types.Argument; | |||
| /** | |||
| * Commandline objects help handling command lines specifying processes to | |||
| @@ -35,121 +30,20 @@ import org.apache.tools.todo.types.Argument; | |||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
| */ | |||
| public class Commandline | |||
| extends ArgumentList | |||
| { | |||
| protected final ArrayList m_arguments = new ArrayList(); | |||
| private String m_executable; | |||
| public Commandline() | |||
| { | |||
| } | |||
| public Commandline( final String[] command ) | |||
| { | |||
| if( 0 == command.length ) | |||
| { | |||
| throw new IllegalArgumentException( "command" ); | |||
| } | |||
| m_executable = command[ 0 ]; | |||
| for( int i = 1; i < command.length; i++ ) | |||
| { | |||
| addArgument( command[ i ] ); | |||
| } | |||
| } | |||
| /** | |||
| * Sets the executable to run. | |||
| */ | |||
| public void setExecutable( final String executable ) | |||
| { | |||
| if( executable == null || executable.length() == 0 ) | |||
| { | |||
| return; | |||
| } | |||
| m_executable = executable.replace( '/', File.separatorChar ) | |||
| .replace( '\\', File.separatorChar ); | |||
| } | |||
| /** | |||
| * Returns all arguments defined by <code>addLine</code>, <code>addValue</code> | |||
| * or the argument object. | |||
| * | |||
| * @return The Arguments value | |||
| */ | |||
| public String[] getArguments() | |||
| { | |||
| final int size = m_arguments.size(); | |||
| final ArrayList result = new ArrayList( size * 2 ); | |||
| for( int i = 0; i < size; i++ ) | |||
| { | |||
| final Argument arg = (Argument)m_arguments.get( i ); | |||
| final String[] s = arg.getParts(); | |||
| for( int j = 0; j < s.length; j++ ) | |||
| { | |||
| result.add( s[ j ] ); | |||
| } | |||
| } | |||
| final String[] res = new String[ result.size() ]; | |||
| return (String[])result.toArray( res ); | |||
| } | |||
| /** | |||
| * Returns the executable and all defined arguments. | |||
| */ | |||
| public String[] getCommandline() | |||
| { | |||
| final String[] args = getArguments(); | |||
| if( m_executable == null ) | |||
| { | |||
| return args; | |||
| } | |||
| final String[] result = new String[ args.length + 1 ]; | |||
| result[ 0 ] = m_executable; | |||
| System.arraycopy( args, 0, result, 1, args.length ); | |||
| return result; | |||
| m_executable = executable; | |||
| } | |||
| public String getExecutable() | |||
| { | |||
| return m_executable; | |||
| } | |||
| public void addArguments( final String[] args ) | |||
| { | |||
| for( int i = 0; i < args.length; i++ ) | |||
| { | |||
| addArgument( args[ i ] ); | |||
| } | |||
| } | |||
| public void addArguments( final Commandline cmdline ) | |||
| { | |||
| addArguments( cmdline.getArguments() ); | |||
| } | |||
| public void addArgument( final File argument ) | |||
| { | |||
| addArgument( new Argument( argument ) ); | |||
| } | |||
| public void addArgument( final String argument ) | |||
| { | |||
| addArgument( new Argument( argument ) ); | |||
| } | |||
| public void addArgument( final Argument argument ) | |||
| { | |||
| m_arguments.add( argument ); | |||
| } | |||
| public void addLine( final String line ) | |||
| throws TaskException | |||
| { | |||
| final String[] parts = FileUtils.translateCommandline( line ); | |||
| for( int i = 0; i < parts.length; i++ ) | |||
| { | |||
| addArgument( parts[ i ] ); | |||
| } | |||
| } | |||
| } | |||