git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270932 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -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 | ||||
| { | { | ||||
| @@ -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; | ||||
| } | } | ||||
| @@ -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(); | ||||
| @@ -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(); | ||||
| @@ -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(); | ||||
| @@ -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 | ||||
| { | { | ||||
| @@ -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 ) | ||||
| @@ -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 ); | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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(); | ||||
| @@ -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(); | ||||
| @@ -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 ) | ||||
| @@ -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 ) | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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() ); | ||||
| @@ -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 ) | ||||
| @@ -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 | ||||
| { | { | ||||
| @@ -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 ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -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 ); | ||||
| @@ -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 ); | ||||
| @@ -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() ) | ||||
| @@ -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 ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -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 | ||||
| { | { | ||||
| @@ -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 ); | ||||
| @@ -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 ! :-( | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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 ) | ||||
| @@ -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"; | ||||
| @@ -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 ) ); | ||||
| @@ -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(); | ||||
| @@ -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 | ||||
| { | { | ||||
| @@ -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 ) | ||||
| @@ -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 ); | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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(); | ||||
| @@ -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(); | ||||
| @@ -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 ) | ||||
| @@ -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 ) | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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() ); | ||||
| @@ -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 ) | ||||
| @@ -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 | ||||
| { | { | ||||
| @@ -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 ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -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 ); | ||||
| @@ -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 ); | ||||
| @@ -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() ) | ||||
| @@ -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 ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -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 | ||||
| { | { | ||||
| @@ -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 ); | ||||
| @@ -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 ! :-( | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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 ) | ||||
| { | { | ||||
| @@ -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 ) | ||||
| @@ -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"; | ||||
| @@ -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 ) ); | ||||