Browse Source

Made Execute2 only take Commandlin objects rather than an arrya of strings

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270932 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
ad91082694
56 changed files with 156 additions and 144 deletions
  1. +1
    -1
      proposal/myrmidon/src/java/org/apache/antlib/cvslib/Cvs.java
  2. +1
    -1
      proposal/myrmidon/src/java/org/apache/antlib/nativelib/Exec.java
  3. +1
    -1
      proposal/myrmidon/src/java/org/apache/antlib/security/GenerateKey.java
  4. +1
    -1
      proposal/myrmidon/src/java/org/apache/antlib/security/SignJar.java
  5. +4
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java
  6. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java
  7. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  8. +7
    -9
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute2.java
  9. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java
  10. +3
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  11. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  12. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
  13. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
  14. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
  15. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java
  16. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
  17. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java
  18. +8
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
  19. +3
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
  20. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  21. +3
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java
  22. +5
    -12
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java
  23. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java
  24. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
  25. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java
  26. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java
  27. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java
  28. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  29. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Rpm.java
  30. +21
    -16
      proposal/myrmidon/src/main/org/apache/tools/ant/types/Commandline.java
  31. +4
    -4
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java
  32. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Patch.java
  33. +2
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  34. +7
    -9
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/Execute2.java
  35. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java
  36. +3
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  37. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Cab.java
  38. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
  39. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
  40. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
  41. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java
  42. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
  43. +2
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java
  44. +8
    -6
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
  45. +3
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
  46. +2
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  47. +3
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java
  48. +5
    -12
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java
  49. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java
  50. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
  51. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java
  52. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java
  53. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java
  54. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  55. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Rpm.java
  56. +21
    -16
      proposal/myrmidon/src/todo/org/apache/tools/ant/types/Commandline.java

+ 1
- 1
proposal/myrmidon/src/java/org/apache/antlib/cvslib/Cvs.java View File

@@ -153,7 +153,7 @@ public class Cvs
} }
exe.setWorkingDirectory( m_dest ); exe.setWorkingDirectory( m_dest );


exe.setCommandline( command.getCommandline() );
exe.setCommandline( command );
exe.setEnvironment( env ); exe.setEnvironment( env );
try try
{ {


+ 1
- 1
proposal/myrmidon/src/java/org/apache/antlib/nativelib/Exec.java View File

@@ -176,7 +176,7 @@ public class Exec
exe.setWorkingDirectory( m_dir ); exe.setWorkingDirectory( m_dir );
exe.setNewenvironment( m_newEnvironment ); exe.setNewenvironment( m_newEnvironment );
exe.setEnvironment( environment ); exe.setEnvironment( environment );
exe.setCommandline( m_command.getCommandline() );
exe.setCommandline( m_command );
return exe; return exe;
} }




+ 1
- 1
proposal/myrmidon/src/java/org/apache/antlib/security/GenerateKey.java View File

@@ -121,7 +121,7 @@ public class GenerateKey
final Commandline cmd = createCommand(); final Commandline cmd = createCommand();
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
try try
{ {
exe.execute(); exe.execute();


+ 1
- 1
proposal/myrmidon/src/java/org/apache/antlib/security/SignJar.java View File

@@ -295,7 +295,7 @@ public class SignJar
final Commandline cmd = buildCommand( jarTarget, jarSource ); final Commandline cmd = buildCommand( jarTarget, jarSource );
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
try try
{ {
exe.execute(); exe.execute();


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

@@ -11,11 +11,11 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.AbstractTask; import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.Argument;
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.EnvironmentVariable; import org.apache.tools.ant.types.EnvironmentVariable;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
@@ -159,7 +159,7 @@ public class Java
{ {
getLogger().debug( "Forking " + m_cmdl.toString() ); getLogger().debug( "Forking " + m_cmdl.toString() );


return run( m_cmdl.getCommandline() );
return run( new Commandline( m_cmdl.getCommandline() ) );
} }
else else
{ {
@@ -214,7 +214,7 @@ public class Java
/** /**
* Executes the given classname with the given arguments in a separate VM. * Executes the given classname with the given arguments in a separate VM.
*/ */
private int run( final String[] command )
private int run( final Commandline command )
throws TaskException throws TaskException
{ {
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();


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

@@ -113,7 +113,7 @@ public class Patch
setupLogger( exe ); setupLogger( exe );


final Commandline cmd = buildCommand(); final Commandline cmd = buildCommand();
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );


try try
{ {


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

@@ -363,7 +363,8 @@ public abstract class DefaultCompilerAdapter
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( m_baseDir ); exe.setWorkingDirectory( m_baseDir );
exe.setCommandline( commandArray );
final String[] commandline = commandArray;
exe.setCommandline( new Commandline( commandline ) );
return exe.execute(); return exe.execute();
} }
catch( IOException e ) catch( IOException e )


+ 7
- 9
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute2.java View File

@@ -19,6 +19,7 @@ import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.factorys.ExecManagerFactory; import org.apache.myrmidon.framework.factorys.ExecManagerFactory;
import org.apache.myrmidon.services.ServiceException; import org.apache.myrmidon.services.ServiceException;
import org.apache.tools.ant.types.Commandline;


/** /**
* Runs an external program. * Runs an external program.
@@ -28,18 +29,13 @@ import org.apache.myrmidon.services.ServiceException;
public class Execute2 public class Execute2
extends AbstractLogEnabled extends AbstractLogEnabled
{ {
private String[] m_command;
private Commandline m_command;
private Properties m_environment = new Properties(); private Properties m_environment = new Properties();
private File m_workingDirectory = new File( "." ); private File m_workingDirectory = new File( "." );
private boolean m_newEnvironment; private boolean m_newEnvironment;
private ExecOutputHandler m_handler; private ExecOutputHandler m_handler;
private long m_timeout; private long m_timeout;


/**
* Controls whether the VM is used to launch commands, where possible
*/
private boolean m_useVMLauncher = true;

public void setTimeout( final long timeout ) public void setTimeout( final long timeout )
{ {
m_timeout = timeout; m_timeout = timeout;
@@ -55,9 +51,9 @@ public class Execute2
* *
* @param commandline the commandline of the subprocess to launch * @param commandline the commandline of the subprocess to launch
*/ */
public void setCommandline( final String[] commandline )
public void setCommandline( final Commandline command )
{ {
m_command = commandline;
m_command = command;
} }


public void setEnvironment( final Properties environment ) public void setEnvironment( final Properties environment )
@@ -109,8 +105,10 @@ public class Execute2
final ExecManagerFactory factory = new ExecManagerFactory(); final ExecManagerFactory factory = new ExecManagerFactory();
final ExecManager manager = (ExecManager)factory.createService(); final ExecManager manager = (ExecManager)factory.createService();


final String[] command = m_command.getCommandline();

final ExecMetaData metaData = final ExecMetaData metaData =
new ExecMetaData( m_command, m_environment,
new ExecMetaData( command, m_environment,
m_workingDirectory, m_newEnvironment ); m_workingDirectory, m_newEnvironment );


return manager.execute( metaData, m_handler, m_timeout ); return manager.execute( metaData, m_handler, m_timeout );


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

@@ -824,7 +824,7 @@ public class Javadoc
exe.setWorkingDirectory( null ); exe.setWorkingDirectory( null );
try try
{ {
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
final int ret = exe.execute(); final int ret = exe.execute();
if( ret != 0 ) if( ret != 0 )
{ {


+ 3
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java View File

@@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.Argument;
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.Commandline;


/** /**
* ANTLR task. * ANTLR task.
@@ -129,7 +130,7 @@ public class ANTLR extends Task
if( fork ) if( fork )
{ {
getLogger().debug( "Forking " + commandline.toString() ); getLogger().debug( "Forking " + commandline.toString() );
int err = run( commandline.getCommandline() );
int err = run( commandline );
if( err == 1 ) if( err == 1 )
{ {
throw new TaskException( "ANTLR returned: " + err ); throw new TaskException( "ANTLR returned: " + err );
@@ -222,7 +223,7 @@ public class ANTLR extends Task
* @return Description of the Returned Value * @return Description of the Returned Value
* @exception TaskException Description of Exception * @exception TaskException Description of Exception
*/ */
private int run( String[] command )
private int run( final Commandline command )
throws TaskException throws TaskException
{ {
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();


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

@@ -138,7 +138,7 @@ public class Cab
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( m_baseDir ); exe.setWorkingDirectory( m_baseDir );
final Commandline cmd = createCommand( listFile ); final Commandline cmd = createCommand( listFile );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
exe.execute(); exe.execute();


listFile.delete(); listFile.delete();


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java View File

@@ -118,7 +118,7 @@ public abstract class Continuus
exe.setExecOutputHandler( handler ); exe.setExecOutputHandler( handler );
} }
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
return exe.execute(); return exe.execute();
} }
catch( final IOException ioe ) catch( final IOException ioe )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java View File

@@ -110,7 +110,7 @@ public abstract class ClearCase extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
return exe.execute(); return exe.execute();
} }
catch( IOException e ) catch( IOException e )


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java View File

@@ -151,7 +151,7 @@ public class NetCommand
//in verbose mode we always log stuff //in verbose mode we always log stuff
logVerbose( _commandLine.toString() ); logVerbose( _commandLine.toString() );
} }
_exe.setCommandline( _commandLine.getCommandline() );
_exe.setCommandline( _commandLine );
err = _exe.execute(); err = _exe.execute();
if( err != 0 ) if( err != 0 )
{ {


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

@@ -365,7 +365,7 @@ public class BorlandDeploymentTool
exe.setWorkingDirectory( getTask().getBaseDirectory() ); exe.setWorkingDirectory( getTask().getBaseDirectory() );


final Commandline cmd = buildCommandline( ithomes ); final Commandline cmd = buildCommandline( ithomes );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );


getLogger().debug( "Calling java2iiop" ); getLogger().debug( "Calling java2iiop" );
getLogger().debug( cmd.toString() ); getLogger().debug( cmd.toString() );


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

@@ -163,7 +163,7 @@ public class BorlandGenerateClient extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( new File( "." ) ); exe.setWorkingDirectory( new File( "." ) );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
exe.execute(); exe.execute();
} }
catch( Exception e ) catch( Exception e )


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

@@ -18,6 +18,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
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.PathUtil; import org.apache.tools.ant.types.PathUtil;
import org.apache.tools.ant.types.Commandline;


/** /**
* Taskdef for the JJTree compiler compiler. * Taskdef for the JJTree compiler compiler.
@@ -184,7 +185,7 @@ public class JJTree extends Task
setupLogger( exe ); setupLogger( exe );


getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( new Commandline( cmdl.getCommandline() ) );


try try
{ {


+ 8
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java View File

@@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
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.PathUtil; import org.apache.tools.ant.types.PathUtil;
import org.apache.tools.ant.types.Commandline;
import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.excalibur.util.StringUtil;


/** /**
@@ -234,27 +235,28 @@ public class JavaCC extends Task
cmdl.addVmArgument( "-mx140M" ); cmdl.addVmArgument( "-mx140M" );
cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() );


runCommand( cmdl.getCommandline() );
runCommand( cmdl );
} }


private void runCommand( final String[] cmdline )
private void runCommand( final CommandlineJava cmdline )
throws TaskException throws TaskException
{ {
try try
{ {
getLogger().debug( StringUtil.join( cmdline, " " ) );
getLogger().debug( cmdline.toString() );
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setCommandline( cmdline );
final String[] commandline = cmdline.getCommandline();
exe.setCommandline( new Commandline( commandline ) );
int retval = exe.execute(); int retval = exe.execute();
if( retval != 0 ) if( retval != 0 )
{ {
throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval );
throw new TaskException( cmdline + " failed with return code " + retval );
} }
} }
catch( final IOException ioe ) catch( final IOException ioe )
{ {
throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + ioe );
throw new TaskException( "Could not launch " + cmdline + ": " + ioe );
} }
} }




+ 3
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java View File

@@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;


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.Commandline;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;


/** /**
@@ -241,7 +242,8 @@ public class JDependTask
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );


exe.setCommandline( commandline.getCommandline() );
final String[] commandline1 = commandline.getCommandline();
exe.setCommandline( new Commandline( commandline1 ) );
if( m_dir != null ) if( m_dir != null )
{ {
exe.setWorkingDirectory( m_dir ); exe.setWorkingDirectory( m_dir );


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

@@ -30,6 +30,7 @@ import org.apache.tools.ant.types.EnvironmentVariable;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.SysProperties; import org.apache.tools.ant.types.SysProperties;
import org.apache.tools.ant.types.PathUtil; import org.apache.tools.ant.types.PathUtil;
import org.apache.tools.ant.types.Commandline;


/** /**
* Ant task to run JUnit tests. <p> * Ant task to run JUnit tests. <p>
@@ -647,7 +648,7 @@ public class JUnitTask extends Task


final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( new Commandline( cmd.getCommandline() ) );
if( dir != null ) if( dir != null )
{ {
exe.setWorkingDirectory( dir ); exe.setWorkingDirectory( dir );


+ 3
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java View File

@@ -24,6 +24,7 @@ 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.ScannerUtil; import org.apache.tools.ant.types.ScannerUtil;
import org.apache.tools.ant.types.Commandline;


/** /**
* 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
@@ -280,7 +281,8 @@ public abstract class AbstractMetamataTask
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( m_cmdl.toString() ); getLogger().debug( m_cmdl.toString() );
exe.setCommandline( m_cmdl.getCommandline() );
final String[] commandline = m_cmdl.getCommandline();
exe.setCommandline( new Commandline( commandline ) );
try try
{ {
if( 0 != exe.execute() ) if( 0 != exe.execute() )


+ 5
- 12
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java View File

@@ -19,6 +19,8 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.Argument;
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.Commandline;
import org.apache.avalon.excalibur.io.IOUtil;


/** /**
* Simple Metamata MParse task based on the original written by <a * Simple Metamata MParse task based on the original written by <a
@@ -287,7 +289,8 @@ public class MParse
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( m_cmdl.toString() ); getLogger().debug( m_cmdl.toString() );
exe.setCommandline( m_cmdl.getCommandline() );
final String[] commandline = m_cmdl.getCommandline();
exe.setCommandline( new Commandline( commandline ) );
try try
{ {
if( exe.execute() != 0 ) if( exe.execute() != 0 )
@@ -386,17 +389,7 @@ public class MParse
} }
finally finally
{ {
if( fw != null )
{
try
{
fw.close();
}
catch( IOException ignored )
{
}
}
IOUtil.shutdownWriter( fw );
} }
} }

} }

+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java View File

@@ -167,7 +167,7 @@ public abstract class P4Base


final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
exe.setExecOutputHandler( handler ); exe.setExecOutputHandler( handler );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );


try try
{ {


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java View File

@@ -193,7 +193,7 @@ public class Pvcs
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
result = exe.execute(); result = exe.execute();
checkResultCode( result, cmd ); checkResultCode( result, cmd );
} }
@@ -276,7 +276,7 @@ public class Pvcs
exe.setExecOutputHandler( this ); exe.setExecOutputHandler( this );
m_output = new FileOutputStream( tmp ); m_output = new FileOutputStream( tmp );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
final int result = exe.execute(); final int result = exe.execute();
checkResultCode( result, cmd ); checkResultCode( result, cmd );




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java View File

@@ -117,7 +117,7 @@ public class CovMerge extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( cmdl );


// JProbe process always return 0 so we will not be // JProbe process always return 0 so we will not be
// able to check for failure ! :-( // able to check for failure ! :-(


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java View File

@@ -249,7 +249,7 @@ public class CovReport extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( cmdl );
int exitValue = exe.execute(); int exitValue = exe.execute();
if( exitValue != 0 ) if( exitValue != 0 )
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java View File

@@ -253,7 +253,7 @@ public class Coverage
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( cmdl );
int exitValue = exe.execute(); int exitValue = exe.execute();
if( exitValue != 0 ) if( exitValue != 0 )
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java View File

@@ -217,7 +217,7 @@ public abstract class MSVSS extends Task
} }


exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
return exe.execute(); return exe.execute();
} }
catch( IOException e ) catch( IOException e )


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

@@ -98,7 +98,7 @@ public class Rpm
} }
exe.setWorkingDirectory( m_topDir ); exe.setWorkingDirectory( m_topDir );


exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
try try
{ {
final String message = "Building the RPM based on the " + m_specFile + " file"; final String message = "Building the RPM based on the " + m_specFile + " file";


+ 21
- 16
proposal/myrmidon/src/main/org/apache/tools/ant/types/Commandline.java View File

@@ -37,6 +37,24 @@ public class Commandline
protected final ArrayList m_arguments = new ArrayList(); protected final ArrayList m_arguments = new ArrayList();
private String m_executable; 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. * Sets the executable to run.
* *
@@ -98,27 +116,14 @@ public class Commandline
return m_executable; return m_executable;
} }


public void addArguments( String[] line )
public void addArguments( final String[] args )
{ {
for( int i = 0; i < line.length; i++ )
for( int i = 0; i < args.length; i++ )
{ {
addArgument( line[ i ] );
addArgument( args[ i ] );
} }
} }


/**
* Creates an argument object. Each commandline object has at most one
* instance of the argument class.
*
* @return the argument object.
*/
public Argument createArgument()
{
final Argument argument = new Argument();
m_arguments.add( argument );
return argument;
}

public void addArgument( final File argument ) public void addArgument( final File argument )
{ {
addArgument( new Argument( argument ) ); addArgument( new Argument( argument ) );


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

@@ -11,11 +11,11 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.AbstractTask; import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.Argument;
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.EnvironmentVariable; import org.apache.tools.ant.types.EnvironmentVariable;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
@@ -159,7 +159,7 @@ public class Java
{ {
getLogger().debug( "Forking " + m_cmdl.toString() ); getLogger().debug( "Forking " + m_cmdl.toString() );


return run( m_cmdl.getCommandline() );
return run( new Commandline( m_cmdl.getCommandline() ) );
} }
else else
{ {
@@ -214,7 +214,7 @@ public class Java
/** /**
* Executes the given classname with the given arguments in a separate VM. * Executes the given classname with the given arguments in a separate VM.
*/ */
private int run( final String[] command )
private int run( final Commandline command )
throws TaskException throws TaskException
{ {
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();


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

@@ -113,7 +113,7 @@ public class Patch
setupLogger( exe ); setupLogger( exe );


final Commandline cmd = buildCommand(); final Commandline cmd = buildCommand();
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );


try try
{ {


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

@@ -363,7 +363,8 @@ public abstract class DefaultCompilerAdapter
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( m_baseDir ); exe.setWorkingDirectory( m_baseDir );
exe.setCommandline( commandArray );
final String[] commandline = commandArray;
exe.setCommandline( new Commandline( commandline ) );
return exe.execute(); return exe.execute();
} }
catch( IOException e ) catch( IOException e )


+ 7
- 9
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/Execute2.java View File

@@ -19,6 +19,7 @@ import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.factorys.ExecManagerFactory; import org.apache.myrmidon.framework.factorys.ExecManagerFactory;
import org.apache.myrmidon.services.ServiceException; import org.apache.myrmidon.services.ServiceException;
import org.apache.tools.ant.types.Commandline;


/** /**
* Runs an external program. * Runs an external program.
@@ -28,18 +29,13 @@ import org.apache.myrmidon.services.ServiceException;
public class Execute2 public class Execute2
extends AbstractLogEnabled extends AbstractLogEnabled
{ {
private String[] m_command;
private Commandline m_command;
private Properties m_environment = new Properties(); private Properties m_environment = new Properties();
private File m_workingDirectory = new File( "." ); private File m_workingDirectory = new File( "." );
private boolean m_newEnvironment; private boolean m_newEnvironment;
private ExecOutputHandler m_handler; private ExecOutputHandler m_handler;
private long m_timeout; private long m_timeout;


/**
* Controls whether the VM is used to launch commands, where possible
*/
private boolean m_useVMLauncher = true;

public void setTimeout( final long timeout ) public void setTimeout( final long timeout )
{ {
m_timeout = timeout; m_timeout = timeout;
@@ -55,9 +51,9 @@ public class Execute2
* *
* @param commandline the commandline of the subprocess to launch * @param commandline the commandline of the subprocess to launch
*/ */
public void setCommandline( final String[] commandline )
public void setCommandline( final Commandline command )
{ {
m_command = commandline;
m_command = command;
} }


public void setEnvironment( final Properties environment ) public void setEnvironment( final Properties environment )
@@ -109,8 +105,10 @@ public class Execute2
final ExecManagerFactory factory = new ExecManagerFactory(); final ExecManagerFactory factory = new ExecManagerFactory();
final ExecManager manager = (ExecManager)factory.createService(); final ExecManager manager = (ExecManager)factory.createService();


final String[] command = m_command.getCommandline();

final ExecMetaData metaData = final ExecMetaData metaData =
new ExecMetaData( m_command, m_environment,
new ExecMetaData( command, m_environment,
m_workingDirectory, m_newEnvironment ); m_workingDirectory, m_newEnvironment );


return manager.execute( metaData, m_handler, m_timeout ); return manager.execute( metaData, m_handler, m_timeout );


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

@@ -824,7 +824,7 @@ public class Javadoc
exe.setWorkingDirectory( null ); exe.setWorkingDirectory( null );
try try
{ {
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
final int ret = exe.execute(); final int ret = exe.execute();
if( ret != 0 ) if( ret != 0 )
{ {


+ 3
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java View File

@@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.Argument;
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.Commandline;


/** /**
* ANTLR task. * ANTLR task.
@@ -129,7 +130,7 @@ public class ANTLR extends Task
if( fork ) if( fork )
{ {
getLogger().debug( "Forking " + commandline.toString() ); getLogger().debug( "Forking " + commandline.toString() );
int err = run( commandline.getCommandline() );
int err = run( commandline );
if( err == 1 ) if( err == 1 )
{ {
throw new TaskException( "ANTLR returned: " + err ); throw new TaskException( "ANTLR returned: " + err );
@@ -222,7 +223,7 @@ public class ANTLR extends Task
* @return Description of the Returned Value * @return Description of the Returned Value
* @exception TaskException Description of Exception * @exception TaskException Description of Exception
*/ */
private int run( String[] command )
private int run( final Commandline command )
throws TaskException throws TaskException
{ {
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();


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

@@ -138,7 +138,7 @@ public class Cab
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( m_baseDir ); exe.setWorkingDirectory( m_baseDir );
final Commandline cmd = createCommand( listFile ); final Commandline cmd = createCommand( listFile );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
exe.execute(); exe.execute();


listFile.delete(); listFile.delete();


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java View File

@@ -118,7 +118,7 @@ public abstract class Continuus
exe.setExecOutputHandler( handler ); exe.setExecOutputHandler( handler );
} }
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
return exe.execute(); return exe.execute();
} }
catch( final IOException ioe ) catch( final IOException ioe )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java View File

@@ -110,7 +110,7 @@ public abstract class ClearCase extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
return exe.execute(); return exe.execute();
} }
catch( IOException e ) catch( IOException e )


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java View File

@@ -151,7 +151,7 @@ public class NetCommand
//in verbose mode we always log stuff //in verbose mode we always log stuff
logVerbose( _commandLine.toString() ); logVerbose( _commandLine.toString() );
} }
_exe.setCommandline( _commandLine.getCommandline() );
_exe.setCommandline( _commandLine );
err = _exe.execute(); err = _exe.execute();
if( err != 0 ) if( err != 0 )
{ {


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

@@ -365,7 +365,7 @@ public class BorlandDeploymentTool
exe.setWorkingDirectory( getTask().getBaseDirectory() ); exe.setWorkingDirectory( getTask().getBaseDirectory() );


final Commandline cmd = buildCommandline( ithomes ); final Commandline cmd = buildCommandline( ithomes );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );


getLogger().debug( "Calling java2iiop" ); getLogger().debug( "Calling java2iiop" );
getLogger().debug( cmd.toString() ); getLogger().debug( cmd.toString() );


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

@@ -163,7 +163,7 @@ public class BorlandGenerateClient extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( new File( "." ) ); exe.setWorkingDirectory( new File( "." ) );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
exe.execute(); exe.execute();
} }
catch( Exception e ) catch( Exception e )


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

@@ -18,6 +18,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
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.PathUtil; import org.apache.tools.ant.types.PathUtil;
import org.apache.tools.ant.types.Commandline;


/** /**
* Taskdef for the JJTree compiler compiler. * Taskdef for the JJTree compiler compiler.
@@ -184,7 +185,7 @@ public class JJTree extends Task
setupLogger( exe ); setupLogger( exe );


getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( new Commandline( cmdl.getCommandline() ) );


try try
{ {


+ 8
- 6
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java View File

@@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
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.PathUtil; import org.apache.tools.ant.types.PathUtil;
import org.apache.tools.ant.types.Commandline;
import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.excalibur.util.StringUtil;


/** /**
@@ -234,27 +235,28 @@ public class JavaCC extends Task
cmdl.addVmArgument( "-mx140M" ); cmdl.addVmArgument( "-mx140M" );
cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() );


runCommand( cmdl.getCommandline() );
runCommand( cmdl );
} }


private void runCommand( final String[] cmdline )
private void runCommand( final CommandlineJava cmdline )
throws TaskException throws TaskException
{ {
try try
{ {
getLogger().debug( StringUtil.join( cmdline, " " ) );
getLogger().debug( cmdline.toString() );
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setCommandline( cmdline );
final String[] commandline = cmdline.getCommandline();
exe.setCommandline( new Commandline( commandline ) );
int retval = exe.execute(); int retval = exe.execute();
if( retval != 0 ) if( retval != 0 )
{ {
throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval );
throw new TaskException( cmdline + " failed with return code " + retval );
} }
} }
catch( final IOException ioe ) catch( final IOException ioe )
{ {
throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + ioe );
throw new TaskException( "Could not launch " + cmdline + ": " + ioe );
} }
} }




+ 3
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java View File

@@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;


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.Commandline;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;


/** /**
@@ -241,7 +242,8 @@ public class JDependTask
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );


exe.setCommandline( commandline.getCommandline() );
final String[] commandline1 = commandline.getCommandline();
exe.setCommandline( new Commandline( commandline1 ) );
if( m_dir != null ) if( m_dir != null )
{ {
exe.setWorkingDirectory( m_dir ); exe.setWorkingDirectory( m_dir );


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

@@ -30,6 +30,7 @@ import org.apache.tools.ant.types.EnvironmentVariable;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.SysProperties; import org.apache.tools.ant.types.SysProperties;
import org.apache.tools.ant.types.PathUtil; import org.apache.tools.ant.types.PathUtil;
import org.apache.tools.ant.types.Commandline;


/** /**
* Ant task to run JUnit tests. <p> * Ant task to run JUnit tests. <p>
@@ -647,7 +648,7 @@ public class JUnitTask extends Task


final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( new Commandline( cmd.getCommandline() ) );
if( dir != null ) if( dir != null )
{ {
exe.setWorkingDirectory( dir ); exe.setWorkingDirectory( dir );


+ 3
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java View File

@@ -24,6 +24,7 @@ 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.ScannerUtil; import org.apache.tools.ant.types.ScannerUtil;
import org.apache.tools.ant.types.Commandline;


/** /**
* 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
@@ -280,7 +281,8 @@ public abstract class AbstractMetamataTask
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( m_cmdl.toString() ); getLogger().debug( m_cmdl.toString() );
exe.setCommandline( m_cmdl.getCommandline() );
final String[] commandline = m_cmdl.getCommandline();
exe.setCommandline( new Commandline( commandline ) );
try try
{ {
if( 0 != exe.execute() ) if( 0 != exe.execute() )


+ 5
- 12
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java View File

@@ -19,6 +19,8 @@ import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.Argument;
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.Commandline;
import org.apache.avalon.excalibur.io.IOUtil;


/** /**
* Simple Metamata MParse task based on the original written by <a * Simple Metamata MParse task based on the original written by <a
@@ -287,7 +289,8 @@ public class MParse
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( m_cmdl.toString() ); getLogger().debug( m_cmdl.toString() );
exe.setCommandline( m_cmdl.getCommandline() );
final String[] commandline = m_cmdl.getCommandline();
exe.setCommandline( new Commandline( commandline ) );
try try
{ {
if( exe.execute() != 0 ) if( exe.execute() != 0 )
@@ -386,17 +389,7 @@ public class MParse
} }
finally finally
{ {
if( fw != null )
{
try
{
fw.close();
}
catch( IOException ignored )
{
}
}
IOUtil.shutdownWriter( fw );
} }
} }

} }

+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java View File

@@ -167,7 +167,7 @@ public abstract class P4Base


final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
exe.setExecOutputHandler( handler ); exe.setExecOutputHandler( handler );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );


try try
{ {


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java View File

@@ -193,7 +193,7 @@ public class Pvcs
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
result = exe.execute(); result = exe.execute();
checkResultCode( result, cmd ); checkResultCode( result, cmd );
} }
@@ -276,7 +276,7 @@ public class Pvcs
exe.setExecOutputHandler( this ); exe.setExecOutputHandler( this );
m_output = new FileOutputStream( tmp ); m_output = new FileOutputStream( tmp );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
final int result = exe.execute(); final int result = exe.execute();
checkResultCode( result, cmd ); checkResultCode( result, cmd );




+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java View File

@@ -117,7 +117,7 @@ public class CovMerge extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( cmdl );


// JProbe process always return 0 so we will not be // JProbe process always return 0 so we will not be
// able to check for failure ! :-( // able to check for failure ! :-(


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java View File

@@ -249,7 +249,7 @@ public class CovReport extends Task
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( cmdl );
int exitValue = exe.execute(); int exitValue = exe.execute();
if( exitValue != 0 ) if( exitValue != 0 )
{ {


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java View File

@@ -253,7 +253,7 @@ public class Coverage
final Execute2 exe = new Execute2(); final Execute2 exe = new Execute2();
setupLogger( exe ); setupLogger( exe );
getLogger().debug( cmdl.toString() ); getLogger().debug( cmdl.toString() );
exe.setCommandline( cmdl.getCommandline() );
exe.setCommandline( cmdl );
int exitValue = exe.execute(); int exitValue = exe.execute();
if( exitValue != 0 ) if( exitValue != 0 )
{ {


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java View File

@@ -217,7 +217,7 @@ public abstract class MSVSS extends Task
} }


exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
return exe.execute(); return exe.execute();
} }
catch( IOException e ) catch( IOException e )


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

@@ -98,7 +98,7 @@ public class Rpm
} }
exe.setWorkingDirectory( m_topDir ); exe.setWorkingDirectory( m_topDir );


exe.setCommandline( cmd.getCommandline() );
exe.setCommandline( cmd );
try try
{ {
final String message = "Building the RPM based on the " + m_specFile + " file"; final String message = "Building the RPM based on the " + m_specFile + " file";


+ 21
- 16
proposal/myrmidon/src/todo/org/apache/tools/ant/types/Commandline.java View File

@@ -37,6 +37,24 @@ public class Commandline
protected final ArrayList m_arguments = new ArrayList(); protected final ArrayList m_arguments = new ArrayList();
private String m_executable; 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. * Sets the executable to run.
* *
@@ -98,27 +116,14 @@ public class Commandline
return m_executable; return m_executable;
} }


public void addArguments( String[] line )
public void addArguments( final String[] args )
{ {
for( int i = 0; i < line.length; i++ )
for( int i = 0; i < args.length; i++ )
{ {
addArgument( line[ i ] );
addArgument( args[ i ] );
} }
} }


/**
* Creates an argument object. Each commandline object has at most one
* instance of the argument class.
*
* @return the argument object.
*/
public Argument createArgument()
{
final Argument argument = new Argument();
m_arguments.add( argument );
return argument;
}

public void addArgument( final File argument ) public void addArgument( final File argument )
{ {
addArgument( new Argument( argument ) ); addArgument( new Argument( argument ) );


Loading…
Cancel
Save