* Moved the general-purpose logging and validation code from Exec task to Execute. * Removed Execute's constructor, replaced with a TaskContext passed to Execute.execute(). * If no ExecOutputHandler is provided, Execute routes the process' stdout and stderr via TaskContext's log methods. * Removed a bunch of debug messages from tasks, as Execute now takes care of this. * Replaced a bunch of return code == 0 checks, with calls to Execute.setReturnCode( 0 ). git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271888 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -106,10 +106,9 @@ public class Patch | |||||
| { | { | ||||
| validate(); | validate(); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| buildCommand( exe.getCommandline() ); | buildCommand( exe.getCommandline() ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private void validate() | private void validate() | ||||
| @@ -147,8 +147,7 @@ public class Cvs | |||||
| final Commandline command = buildCommandline(); | final Commandline command = buildCommandline(); | ||||
| final Properties env = buildEnvironment(); | final Properties env = buildEnvironment(); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| if( m_dest == null ) | if( m_dest == null ) | ||||
| { | { | ||||
| m_dest = getBaseDirectory(); | m_dest = getBaseDirectory(); | ||||
| @@ -158,7 +157,7 @@ public class Cvs | |||||
| exe.setCommandline( command ); | exe.setCommandline( command ); | ||||
| exe.setEnvironment( env ); | exe.setEnvironment( env ); | ||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private Properties buildEnvironment() | private Properties buildEnvironment() | ||||
| @@ -506,8 +506,7 @@ public class CSharp | |||||
| m_srcDir = getBaseDirectory(); | m_srcDir = getBaseDirectory(); | ||||
| } | } | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| final Commandline cmd = exe.getCommandline(); | final Commandline cmd = exe.getCommandline(); | ||||
| @@ -549,7 +548,7 @@ public class CSharp | |||||
| } | } | ||||
| //now run the command of exe + settings + files | //now run the command of exe + settings + files | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private void addArgument( final Commandline cmd, final String argument ) | private void addArgument( final Commandline cmd, final String argument ) | ||||
| @@ -250,8 +250,7 @@ public class Ilasm | |||||
| public void executeOneFile( final String targetFile ) | public void executeOneFile( final String targetFile ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| final Commandline cmd = exe.getCommandline(); | final Commandline cmd = exe.getCommandline(); | ||||
| @@ -265,7 +264,7 @@ public class Ilasm | |||||
| addArgument( cmd, getKeyfileParameter() ); | addArgument( cmd, getKeyfileParameter() ); | ||||
| addArgument( cmd, getExtraOptionsParameter() ); | addArgument( cmd, getExtraOptionsParameter() ); | ||||
| addArgument( cmd, targetFile ); | addArgument( cmd, targetFile ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private void addArgument( final Commandline cmd, final String argument ) | private void addArgument( final Commandline cmd, final String argument ) | ||||
| @@ -9,13 +9,9 @@ package org.apache.antlib.nativelib; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.aut.nativelib.ExecManager; | |||||
| import org.apache.aut.nativelib.Os; | import org.apache.aut.nativelib.Os; | ||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.myrmidon.api.AbstractTask; | import org.apache.myrmidon.api.AbstractTask; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.myrmidon.framework.Execute; | import org.apache.myrmidon.framework.Execute; | ||||
| import org.apache.tools.todo.types.Argument; | import org.apache.tools.todo.types.Argument; | ||||
| import org.apache.tools.todo.types.Commandline; | import org.apache.tools.todo.types.Commandline; | ||||
| @@ -36,9 +32,6 @@ import org.apache.tools.todo.types.EnvironmentVariable; | |||||
| public class Exec | public class Exec | ||||
| extends AbstractTask | extends AbstractTask | ||||
| { | { | ||||
| private final static Resources REZ = | |||||
| ResourceManager.getPackageResources( Exec.class ); | |||||
| private long m_timeout; | private long m_timeout; | ||||
| private EnvironmentData m_env = new EnvironmentData(); | private EnvironmentData m_env = new EnvironmentData(); | ||||
| private Commandline m_command = new Commandline(); | private Commandline m_command = new Commandline(); | ||||
| @@ -107,28 +100,9 @@ public class Exec | |||||
| public void execute() | public void execute() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| validate(); | |||||
| if( null == m_os || Os.isFamily( m_os ) ) | |||||
| { | |||||
| final Execute exe = createExecute(); | |||||
| doExecute( exe ); | |||||
| } | |||||
| } | |||||
| private void doExecute( final Execute exe ) | |||||
| throws TaskException | |||||
| { | |||||
| exe.setReturnCode( 0 ); | |||||
| exe.execute(); | |||||
| } | |||||
| private void validate() | |||||
| throws TaskException | |||||
| { | |||||
| if( null == m_command.getExecutable() ) | |||||
| if( null != m_os && Os.isFamily( m_os ) ) | |||||
| { | { | ||||
| final String message = REZ.getString( "exec.no-executable.error" ); | |||||
| throw new TaskException( message ); | |||||
| return; | |||||
| } | } | ||||
| // default directory to the project's base directory | // default directory to the project's base directory | ||||
| @@ -136,19 +110,11 @@ public class Exec | |||||
| { | { | ||||
| m_dir = getBaseDirectory(); | m_dir = getBaseDirectory(); | ||||
| } | } | ||||
| else | |||||
| { | |||||
| if( !m_dir.exists() ) | |||||
| { | |||||
| final String message = REZ.getString( "exec.dir-noexist.error", m_dir ); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| else if( !m_dir.isDirectory() ) | |||||
| { | |||||
| final String message = REZ.getString( "exec.dir-notdir.error", m_dir ); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| } | |||||
| // execute the command | |||||
| final Execute exe = createExecute(); | |||||
| exe.setReturnCode( 0 ); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private Execute createExecute() | private Execute createExecute() | ||||
| @@ -156,10 +122,7 @@ public class Exec | |||||
| { | { | ||||
| final Properties environment = m_env.getVariables(); | final Properties environment = m_env.getVariables(); | ||||
| logExecDetails( environment ); | |||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setTimeout( m_timeout ); | exe.setTimeout( m_timeout ); | ||||
| exe.setWorkingDirectory( m_dir ); | exe.setWorkingDirectory( m_dir ); | ||||
| exe.setNewenvironment( m_newEnvironment ); | exe.setNewenvironment( m_newEnvironment ); | ||||
| @@ -167,12 +130,4 @@ public class Exec | |||||
| exe.setCommandline( m_command ); | exe.setCommandline( m_command ); | ||||
| return exe; | return exe; | ||||
| } | } | ||||
| private void logExecDetails( final Properties environment ) | |||||
| { | |||||
| // show the command | |||||
| getContext().debug( m_command.toString() ); | |||||
| final String message = REZ.getString( "exec.env-vars.notice", environment ); | |||||
| getContext().debug( message ); | |||||
| } | |||||
| } | } | ||||
| @@ -1,11 +1,3 @@ | |||||
| loadenv.no-prefix.error=No prefix specified for environment data. | loadenv.no-prefix.error=No prefix specified for environment data. | ||||
| loadenv.prefix.notice=Loading Environment with prefix {0}. | loadenv.prefix.notice=Loading Environment with prefix {0}. | ||||
| loadenv.ignoring-empty.warn=Key {0} in native OS environment is empty - ignoring key. | loadenv.ignoring-empty.warn=Key {0} in native OS environment is empty - ignoring key. | ||||
| exec.failed.error=Execute failed. (Reason: {0}). | |||||
| exec.bad-resultcode.error=Bad result code {0}. | |||||
| exec.no-executable.error=No executable specified. | |||||
| exec.dir-noexist.error=The directory you specified ({0}) does not exist. | |||||
| exec.dir-notdir.error=The directory you specified is not a directory. | |||||
| exec.env-vars.notice=Setting environment variables: {0}. | |||||
| exec.invalid-os.notice=This OS, {0} was not found in the specified list of valid OSes: {1}. | |||||
| @@ -121,11 +121,10 @@ public class GenerateKey | |||||
| getContext().info( message ); | getContext().info( message ); | ||||
| final Commandline cmd = createCommand(); | final Commandline cmd = createCommand(); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setWorkingDirectory( getBaseDirectory() ); | exe.setWorkingDirectory( getBaseDirectory() ); | ||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private Commandline createCommand() | private Commandline createCommand() | ||||
| @@ -296,10 +296,9 @@ public class SignJar | |||||
| getContext().info( message ); | getContext().info( message ); | ||||
| final Commandline cmd = buildCommand( jarTarget, jarSource ); | final Commandline cmd = buildCommand( jarTarget, jarSource ); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private Commandline buildCommand( final File jarTarget, final File jarSource ) | private Commandline buildCommand( final File jarTarget, final File jarSource ) | ||||
| @@ -10,15 +10,11 @@ package org.apache.myrmidon.api; | |||||
| /** | /** | ||||
| * This is the interface that tasks implement to be executed in Myrmidon runtime. | * This is the interface that tasks implement to be executed in Myrmidon runtime. | ||||
| * | * | ||||
| * Instances can also implement the Avalon LogEnabled method to receive a logger. | |||||
| * | |||||
| * Tasks can also choose to implement Avalon Configurable if they wish to directly | * Tasks can also choose to implement Avalon Configurable if they wish to directly | ||||
| * receive the Configuration data representing the task. If this interface is | * receive the Configuration data representing the task. If this interface is | ||||
| * not implemented then the container will be responsble for mapping configuration | * not implemented then the container will be responsble for mapping configuration | ||||
| * onto the task object. | * onto the task object. | ||||
| * | * | ||||
| * The Components passed in via ComponentManager are determined by container. | |||||
| * | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| * @ant:role shorthand="task" | * @ant:role shorthand="task" | ||||
| @@ -16,7 +16,7 @@ import org.apache.myrmidon.listeners.ProjectListener; | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| */ | */ | ||||
| public class ProjectListenerSupport | |||||
| class ProjectListenerSupport | |||||
| implements LogEvent | implements LogEvent | ||||
| { | { | ||||
| private ProjectListener[] m_listeners = new ProjectListener[ 0 ]; | private ProjectListener[] m_listeners = new ProjectListener[ 0 ]; | ||||
| @@ -8,14 +8,17 @@ | |||||
| package org.apache.myrmidon.framework; | package org.apache.myrmidon.framework; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | |||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.aut.nativelib.ExecException; | import org.apache.aut.nativelib.ExecException; | ||||
| import org.apache.aut.nativelib.ExecManager; | import org.apache.aut.nativelib.ExecManager; | ||||
| import org.apache.aut.nativelib.ExecMetaData; | import org.apache.aut.nativelib.ExecMetaData; | ||||
| import org.apache.aut.nativelib.ExecOutputHandler; | import org.apache.aut.nativelib.ExecOutputHandler; | ||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.todo.types.Commandline; | import org.apache.tools.todo.types.Commandline; | ||||
| import org.apache.tools.todo.util.FileUtils; | |||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| /** | /** | ||||
| * This is a utility class designed to make executing native | * This is a utility class designed to make executing native | ||||
| @@ -27,20 +30,17 @@ import org.apache.tools.todo.types.Commandline; | |||||
| */ | */ | ||||
| public class Execute | public class Execute | ||||
| { | { | ||||
| private final static Resources REZ | |||||
| = ResourceManager.getPackageResources( Execute.class ); | |||||
| private Commandline 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; | ||||
| private ExecManager m_execManager; | |||||
| private Integer m_returnCode; | private Integer m_returnCode; | ||||
| public Execute( final ExecManager execManager ) | |||||
| { | |||||
| m_execManager = execManager; | |||||
| } | |||||
| public void setTimeout( final long timeout ) | public void setTimeout( final long timeout ) | ||||
| { | { | ||||
| m_timeout = timeout; | m_timeout = timeout; | ||||
| @@ -108,59 +108,104 @@ public class Execute | |||||
| /** | /** | ||||
| * Runs a process defined by the command line and returns its exit status. | * Runs a process defined by the command line and returns its exit status. | ||||
| * | * | ||||
| * @return the exit status of the subprocess or <code>INVALID</code> | |||||
| * @return the exit status of the subprocess. | |||||
| */ | */ | ||||
| public int execute() | |||||
| public int execute( final TaskContext context ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final int returnCode = executeNativeProcess(); | |||||
| checkReturnCode( returnCode ); | |||||
| return returnCode; | |||||
| validate(); | |||||
| try | |||||
| { | |||||
| // Build an output handler | |||||
| final ExecOutputHandler handler = buildOutputHandler( context ); | |||||
| // Build the command meta-info | |||||
| final ExecManager execManager = (ExecManager)context.getService( ExecManager.class ); | |||||
| final ExecMetaData metaData = buildExecMetaData( execManager ); | |||||
| logExecDetails( metaData, context ); | |||||
| // Execute the command and check return code | |||||
| final int returnCode = execManager.execute( metaData, handler, m_timeout ); | |||||
| checkReturnCode( returnCode ); | |||||
| return returnCode; | |||||
| } | |||||
| catch( final Exception e ) | |||||
| { | |||||
| final String message = REZ.getString( "execute.failed.error", m_command.getExecutable() ); | |||||
| throw new TaskException( message, e ); | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| * Utility method to verify that specified return code was the | |||||
| * return code expected (if any). | |||||
| * Logs the details of the command. | |||||
| */ | */ | ||||
| private void checkReturnCode( final int returnCode ) | |||||
| private void logExecDetails( final ExecMetaData metaData, | |||||
| final TaskContext context ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( null != m_returnCode && | |||||
| returnCode != m_returnCode.intValue() ) | |||||
| if( ! context.isDebugEnabled() ) | |||||
| { | { | ||||
| throw new TaskException( "Unexpected return code " + returnCode ); | |||||
| return; | |||||
| } | } | ||||
| String cmdline = FileUtils.buildCommandLine( metaData.getCommand() ); | |||||
| String message = REZ.getString( "execute.command.notice", cmdline ); | |||||
| context.debug( message ); | |||||
| message = REZ.getString( "execute.env-vars.notice", metaData.getEnvironment() ); | |||||
| context.debug( message ); | |||||
| } | } | ||||
| /** | /** | ||||
| * Actually execute the native process. | |||||
| * Vaidates the arguments. | |||||
| */ | */ | ||||
| private int executeNativeProcess() | |||||
| throws TaskException | |||||
| private void validate() throws TaskException | |||||
| { | { | ||||
| try | |||||
| if( null == m_command.getExecutable() ) | |||||
| { | { | ||||
| final ExecMetaData metaData = buildExecMetaData(); | |||||
| if( null != m_handler ) | |||||
| { | |||||
| return m_execManager.execute( metaData, m_handler, m_timeout ); | |||||
| } | |||||
| else | |||||
| { | |||||
| return m_execManager.execute( metaData, | |||||
| null, | |||||
| System.out, | |||||
| System.err, | |||||
| m_timeout ); | |||||
| } | |||||
| final String message = REZ.getString( "execute.no-executable.error" ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| catch( final ExecException ee ) | |||||
| if( !m_workingDirectory.exists() ) | |||||
| { | { | ||||
| throw new TaskException( ee.getMessage(), ee ); | |||||
| final String message = REZ.getString( "execute.dir-noexist.error", m_workingDirectory ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| catch( final IOException ioe ) | |||||
| else if( !m_workingDirectory.isDirectory() ) | |||||
| { | |||||
| final String message = REZ.getString( "execute.dir-notdir.error", m_workingDirectory ); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Creates an output handler to use when executing the commmand. | |||||
| */ | |||||
| private ExecOutputHandler buildOutputHandler( final TaskContext context ) | |||||
| { | |||||
| ExecOutputHandler handler = m_handler; | |||||
| if( handler == null ) | |||||
| { | |||||
| handler = new LoggingExecOutputHandler( context ); | |||||
| } | |||||
| return handler; | |||||
| } | |||||
| /** | |||||
| * Utility method to verify that specified return code was the | |||||
| * return code expected (if any). | |||||
| */ | |||||
| private void checkReturnCode( final int returnCode ) | |||||
| throws TaskException | |||||
| { | |||||
| if( null != m_returnCode && | |||||
| returnCode != m_returnCode.intValue() ) | |||||
| { | { | ||||
| throw new TaskException( ioe.getMessage(), ioe ); | |||||
| final String message = REZ.getString( "execute.bad-resultcode.error", | |||||
| m_command.getExecutable(), | |||||
| new Integer(returnCode) ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -168,7 +213,7 @@ public class Execute | |||||
| * Utility method to create an ExecMetaData object | * Utility method to create an ExecMetaData object | ||||
| * to pass to the ExecManager service. | * to pass to the ExecManager service. | ||||
| */ | */ | ||||
| private ExecMetaData buildExecMetaData() | |||||
| private ExecMetaData buildExecMetaData( final ExecManager execManager ) | |||||
| throws ExecException | throws ExecException | ||||
| { | { | ||||
| final String[] command = m_command.getCommandline(); | final String[] command = m_command.getCommandline(); | ||||
| @@ -176,7 +221,7 @@ public class Execute | |||||
| final Properties newEnvironment = new Properties(); | final Properties newEnvironment = new Properties(); | ||||
| if( !m_newEnvironment ) | if( !m_newEnvironment ) | ||||
| { | { | ||||
| newEnvironment.putAll( m_execManager.getNativeEnvironment() ); | |||||
| newEnvironment.putAll( execManager.getNativeEnvironment() ); | |||||
| } | } | ||||
| newEnvironment.putAll( m_environment ); | newEnvironment.putAll( m_environment ); | ||||
| @@ -0,0 +1,47 @@ | |||||
| /* | |||||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
| * | |||||
| * This software is published under the terms of the Apache Software License | |||||
| * version 1.1, a copy of which has been included with this distribution in | |||||
| * the LICENSE.txt file. | |||||
| */ | |||||
| package org.apache.myrmidon.framework; | |||||
| import org.apache.aut.nativelib.ExecOutputHandler; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| /** | |||||
| * An {@link ExecOutputHandler} adaptor, that writes output to the logging | |||||
| * methods of a {@link TaskContext}. | |||||
| * | |||||
| * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class LoggingExecOutputHandler | |||||
| implements ExecOutputHandler | |||||
| { | |||||
| private final TaskContext m_context; | |||||
| public LoggingExecOutputHandler( final TaskContext context ) | |||||
| { | |||||
| m_context = context; | |||||
| } | |||||
| /** | |||||
| * Receive notification about the process writing | |||||
| * to standard output. | |||||
| */ | |||||
| public void stdout( final String line ) | |||||
| { | |||||
| m_context.info( line ); | |||||
| } | |||||
| /** | |||||
| * Receive notification about the process writing | |||||
| * to standard error. | |||||
| */ | |||||
| public void stderr( final String line ) | |||||
| { | |||||
| m_context.error( line ); | |||||
| } | |||||
| } | |||||
| @@ -17,4 +17,13 @@ type.no-id.error=Id must be specified. | |||||
| unknown-family=Don't know how to detect os family "{0}" | unknown-family=Don't know how to detect os family "{0}" | ||||
| facade.missing-impl.error=Unable to determine the name of implementation for facade task "{0}". | |||||
| facade.missing-impl.error=Unable to determine the name of implementation for facade task "{0}". | |||||
| execute.no-executable.error=No executable specified. | |||||
| execute.dir-noexist.error=The specified working directory "{0}" does not exist. | |||||
| execute.dir-notdir.error=The specified working directory "{0}" is not a directory. | |||||
| execute.failed.error=Command "{0}" failed. | |||||
| execute.bad-resultcode.error=Command "{0}" returned unexpected exit code {1}. | |||||
| execute.command.notice=Executing: {0} | |||||
| execute.env-vars.notice=Using environment: {0}. | |||||
| @@ -228,8 +228,7 @@ public class ANTLR extends AbstractTask | |||||
| private int run( final Commandline command ) | private int run( final Commandline command ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| if( workingdir != null ) | if( workingdir != null ) | ||||
| { | { | ||||
| exe.setWorkingDirectory( workingdir ); | exe.setWorkingDirectory( workingdir ); | ||||
| @@ -237,7 +236,7 @@ public class ANTLR extends AbstractTask | |||||
| exe.setCommandline( command ); | exe.setCommandline( command ); | ||||
| try | try | ||||
| { | { | ||||
| return exe.execute(); | |||||
| return exe.execute( getContext() ); | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| @@ -137,12 +137,11 @@ public class Cab | |||||
| try | try | ||||
| { | { | ||||
| File listFile = createListFile( files ); | File listFile = createListFile( files ); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| Execute exe = new Execute( execManager ); | |||||
| Execute exe = new Execute(); | |||||
| exe.setWorkingDirectory( m_baseDir ); | exe.setWorkingDirectory( m_baseDir ); | ||||
| final Commandline cmd = createCommand( listFile ); | final Commandline cmd = createCommand( listFile ); | ||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| listFile.delete(); | listFile.delete(); | ||||
| } | } | ||||
| @@ -215,8 +215,7 @@ public class Java | |||||
| private int run( final Commandline command ) | private int run( final Commandline command ) | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| if( m_dir == null ) | if( m_dir == null ) | ||||
| { | { | ||||
| @@ -230,6 +229,6 @@ public class Java | |||||
| exe.setWorkingDirectory( m_dir ); | exe.setWorkingDirectory( m_dir ); | ||||
| exe.setCommandline( command ); | exe.setCommandline( command ); | ||||
| return exe.execute(); | |||||
| return exe.execute( getContext() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -90,8 +90,7 @@ public class Rpm | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final Commandline cmd = createCommand(); | final Commandline cmd = createCommand(); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| if( m_topDir == null ) | if( m_topDir == null ) | ||||
| { | { | ||||
| @@ -103,7 +102,7 @@ public class Rpm | |||||
| final String message = "Building the RPM based on the " + m_specFile + " file"; | final String message = "Building the RPM based on the " + m_specFile + " file"; | ||||
| getContext().info( message ); | getContext().info( message ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| private Commandline createCommand() | private Commandline createCommand() | ||||
| @@ -119,12 +119,7 @@ public class CCMCheck extends Continuus | |||||
| checkOptions( commandLine ); | checkOptions( commandLine ); | ||||
| final int result = run( commandLine, null ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine, null ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -147,15 +147,7 @@ public class CCMCreateTask | |||||
| cmd.setExecutable( getCcmCommand() ); | cmd.setExecutable( getCcmCommand() ); | ||||
| cmd.addArgument( COMMAND_DEFAULT_TASK ); | cmd.addArgument( COMMAND_DEFAULT_TASK ); | ||||
| cmd.addArgument( m_task ); | cmd.addArgument( m_task ); | ||||
| getContext().debug( commandLine.toString() ); | |||||
| final int result2 = run( cmd, null ); | |||||
| if( result2 != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + cmd.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( cmd, null ); | |||||
| } | } | ||||
| private Commandline determineTask() | private Commandline determineTask() | ||||
| @@ -170,12 +162,7 @@ public class CCMCreateTask | |||||
| checkOptions( commandLine ); | checkOptions( commandLine ); | ||||
| final int result = run( commandLine, this ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine, this ); | |||||
| return commandLine; | return commandLine; | ||||
| } | } | ||||
| @@ -85,12 +85,7 @@ public class CCMReconfigure | |||||
| checkOptions( cmd ); | checkOptions( cmd ); | ||||
| final int result = run( cmd, null ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + cmd.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( cmd, null ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -106,17 +106,17 @@ public abstract class Continuus | |||||
| return toReturn; | return toReturn; | ||||
| } | } | ||||
| protected int run( final Commandline cmd, final ExecOutputHandler handler ) | |||||
| protected void run( final Commandline cmd, final ExecOutputHandler handler ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| if( null != handler ) | if( null != handler ) | ||||
| { | { | ||||
| exe.setExecOutputHandler( handler ); | exe.setExecOutputHandler( handler ); | ||||
| } | } | ||||
| exe.setWorkingDirectory( getBaseDirectory() ); | exe.setWorkingDirectory( getBaseDirectory() ); | ||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| return exe.execute(); | |||||
| exe.setReturnCode( 0 ); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -339,12 +339,7 @@ public class CCCheckin extends ClearCase | |||||
| checkOptions( commandLine ); | checkOptions( commandLine ); | ||||
| final int result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -427,12 +427,7 @@ public class CCCheckout extends ClearCase | |||||
| checkOptions( commandLine ); | checkOptions( commandLine ); | ||||
| final int result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -131,12 +131,7 @@ public class CCUnCheckout extends ClearCase | |||||
| checkOptions( commandLine ); | checkOptions( commandLine ); | ||||
| final int result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -341,15 +341,7 @@ public class CCUpdate extends ClearCase | |||||
| // Check the command line options | // Check the command line options | ||||
| checkOptions( commandLine ); | checkOptions( commandLine ); | ||||
| // For debugging | |||||
| System.out.println( commandLine.toString() ); | |||||
| final int result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -102,14 +102,14 @@ public abstract class ClearCase extends AbstractTask | |||||
| return toReturn; | return toReturn; | ||||
| } | } | ||||
| protected int run( Commandline cmd ) | |||||
| protected void run( Commandline cmd ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setWorkingDirectory( getBaseDirectory() ); | exe.setWorkingDirectory( getBaseDirectory() ); | ||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| return exe.execute(); | |||||
| exe.setReturnCode( 0 ); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -370,12 +370,11 @@ public abstract class DefaultCompilerAdapter | |||||
| commandArray = args; | commandArray = args; | ||||
| } | } | ||||
| final ExecManager execManager = (ExecManager)m_attributes.getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setWorkingDirectory( m_baseDir ); | exe.setWorkingDirectory( m_baseDir ); | ||||
| final String[] commandline = commandArray; | final String[] commandline = commandArray; | ||||
| exe.setCommandline( new Commandline( commandline ) ); | exe.setCommandline( new Commandline( commandline ) ); | ||||
| return exe.execute(); | |||||
| return exe.execute( getTaskContext() ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -181,11 +181,10 @@ public class JJTree | |||||
| cmdl.addVmArgument( "-mx140M" ); | cmdl.addVmArgument( "-mx140M" ); | ||||
| cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | cmdl.addVmArgument( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| getContext().debug( cmdl.toString() ); | getContext().debug( cmdl.toString() ); | ||||
| exe.setCommandline( new Commandline( cmdl.getCommandline() ) ); | exe.setCommandline( new Commandline( cmdl.getCommandline() ) ); | ||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -241,12 +241,11 @@ public class JavaCC | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| getContext().debug( cmdline.toString() ); | getContext().debug( cmdline.toString() ); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| final String[] commandline = cmdline.getCommandline(); | final String[] commandline = cmdline.getCommandline(); | ||||
| exe.setCommandline( new Commandline( commandline ) ); | exe.setCommandline( new Commandline( commandline ) ); | ||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -820,8 +820,7 @@ public class Javadoc | |||||
| getContext().info( "Javadoc execution" ); | getContext().info( "Javadoc execution" ); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setExecOutputHandler( this ); | exe.setExecOutputHandler( this ); | ||||
| /* | /* | ||||
| @@ -835,7 +834,7 @@ public class Javadoc | |||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| try | try | ||||
| { | { | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -241,8 +241,7 @@ public class JDependTask | |||||
| commandline.addArgument( f.getPath() ); | commandline.addArgument( f.getPath() ); | ||||
| } | } | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| final String[] commandline1 = commandline.getCommandline(); | final String[] commandline1 = commandline.getCommandline(); | ||||
| exe.setCommandline( new Commandline( commandline1 ) ); | exe.setCommandline( new Commandline( commandline1 ) ); | ||||
| @@ -256,7 +255,7 @@ public class JDependTask | |||||
| getContext().info( "Output to be stored in " + m_outputFile.getPath() ); | getContext().info( "Output to be stored in " + m_outputFile.getPath() ); | ||||
| } | } | ||||
| getContext().debug( "Executing: " + commandline.toString() ); | getContext().debug( "Executing: " + commandline.toString() ); | ||||
| return exe.execute(); | |||||
| return exe.execute( getContext() ); | |||||
| } | } | ||||
| @@ -632,8 +632,7 @@ public class JUnitTask extends AbstractTask | |||||
| throw new TaskException( "Error creating temporary properties file.", ioe ); | throw new TaskException( "Error creating temporary properties file.", ioe ); | ||||
| } | } | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setCommandline( new Commandline( cmd.getCommandline() ) ); | exe.setCommandline( new Commandline( cmd.getCommandline() ) ); | ||||
| if( dir != null ) | if( dir != null ) | ||||
| { | { | ||||
| @@ -643,7 +642,7 @@ public class JUnitTask extends AbstractTask | |||||
| getContext().debug( "Executing: " + cmd.toString() ); | getContext().debug( "Executing: " + cmd.toString() ); | ||||
| try | try | ||||
| { | { | ||||
| return exe.execute(); | |||||
| return exe.execute( getContext() ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -273,20 +273,16 @@ public abstract class AbstractMetamataTask | |||||
| /** | /** | ||||
| * execute the process with a specific handler | * execute the process with a specific handler | ||||
| * | |||||
| * @param handler Description of Parameter | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected void execute0() | protected void execute0() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| getContext().debug( m_cmdl.toString() ); | getContext().debug( m_cmdl.toString() ); | ||||
| final String[] commandline = m_cmdl.getCommandline(); | final String[] commandline = m_cmdl.getCommandline(); | ||||
| exe.setCommandline( new Commandline( commandline ) ); | exe.setCommandline( new Commandline( commandline ) ); | ||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| protected void generateOptionsFile( File tofile, ArrayList options ) | protected void generateOptionsFile( File tofile, ArrayList options ) | ||||
| @@ -288,13 +288,12 @@ public class MParse | |||||
| return; | return; | ||||
| } | } | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| getContext().debug( m_cmdl.toString() ); | getContext().debug( m_cmdl.toString() ); | ||||
| final String[] commandline = m_cmdl.getCommandline(); | final String[] commandline = m_cmdl.getCommandline(); | ||||
| exe.setCommandline( new Commandline( commandline ) ); | exe.setCommandline( new Commandline( commandline ) ); | ||||
| exe.setReturnCode( 0 ); | exe.setReturnCode( 0 ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -165,12 +165,11 @@ public abstract class P4Base | |||||
| handler = this; | handler = this; | ||||
| } | } | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setExecOutputHandler( handler ); | exe.setExecOutputHandler( handler ); | ||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| exe.execute(); | |||||
| exe.execute( getContext() ); | |||||
| if( null != m_error ) | if( null != m_error ) | ||||
| { | { | ||||
| throw m_error; | throw m_error; | ||||
| @@ -189,14 +189,12 @@ public class Pvcs | |||||
| final Commandline cmd = buildGetCommand( filelist ); | final Commandline cmd = buildGetCommand( filelist ); | ||||
| getContext().info( "Getting files" ); | getContext().info( "Getting files" ); | ||||
| getContext().debug( "Executing " + cmd.toString() ); | |||||
| try | try | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setWorkingDirectory( getBaseDirectory() ); | exe.setWorkingDirectory( getBaseDirectory() ); | ||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| result = exe.execute(); | |||||
| result = exe.execute( getContext() ); | |||||
| checkResultCode( result, cmd ); | checkResultCode( result, cmd ); | ||||
| } | } | ||||
| finally | finally | ||||
| @@ -268,13 +266,12 @@ public class Pvcs | |||||
| tmp = File.createTempFile( "pvcs_ant_", ".log" ); | tmp = File.createTempFile( "pvcs_ant_", ".log" ); | ||||
| final File fileList = File.createTempFile( "pvcs_ant_", ".log" ); | final File fileList = File.createTempFile( "pvcs_ant_", ".log" ); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| 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 ); | exe.setCommandline( cmd ); | ||||
| final int result = exe.execute(); | |||||
| final int result = exe.execute( getContext() ); | |||||
| checkResultCode( result, cmd ); | checkResultCode( result, cmd ); | ||||
| if( !tmp.exists() ) | if( !tmp.exists() ) | ||||
| @@ -116,22 +116,13 @@ public class CovMerge | |||||
| } | } | ||||
| cmdl.addArgument( "-jp_paramfile=" + paramfile.getAbsolutePath() ); | cmdl.addArgument( "-jp_paramfile=" + paramfile.getAbsolutePath() ); | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| getContext().debug( cmdl.toString() ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setCommandline( cmdl ); | exe.setCommandline( cmdl ); | ||||
| exe.setReturnCode( 0 ); | |||||
| // 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 ! :-( | ||||
| int exitValue = exe.execute(); | |||||
| if( exitValue != 0 ) | |||||
| { | |||||
| throw new TaskException( "JProbe Coverage Merging failed (" + exitValue + ")" ); | |||||
| } | |||||
| } | |||||
| catch( IOException e ) | |||||
| { | |||||
| throw new TaskException( "Failed to run JProbe Coverage Merge: " + e ); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -249,15 +249,10 @@ public class CovReport | |||||
| } | } | ||||
| // use the custom handler for stdin issues | // use the custom handler for stdin issues | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| getContext().debug( cmdl.toString() ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setCommandline( cmdl ); | exe.setCommandline( cmdl ); | ||||
| int exitValue = exe.execute(); | |||||
| if( exitValue != 0 ) | |||||
| { | |||||
| throw new TaskException( "JProbe Coverage Report failed (" + exitValue + ")" ); | |||||
| } | |||||
| exe.setReturnCode( 0 ); | |||||
| exe.execute( getContext() ); | |||||
| getContext().debug( "coveragePath: " + coveragePath ); | getContext().debug( "coveragePath: " + coveragePath ); | ||||
| getContext().debug( "format: " + format ); | getContext().debug( "format: " + format ); | ||||
| if( reference != null && "xml".equals( format ) ) | if( reference != null && "xml".equals( format ) ) | ||||
| @@ -250,19 +250,10 @@ public class Coverage | |||||
| cmdl.addArgument( "-jp_input=" + paramfile.getAbsolutePath() ); | cmdl.addArgument( "-jp_input=" + paramfile.getAbsolutePath() ); | ||||
| // use the custom handler for stdin issues | // use the custom handler for stdin issues | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| getContext().debug( cmdl.toString() ); | |||||
| final Execute exe = new Execute(); | |||||
| exe.setCommandline( cmdl ); | exe.setCommandline( cmdl ); | ||||
| int exitValue = exe.execute(); | |||||
| if( exitValue != 0 ) | |||||
| { | |||||
| throw new TaskException( "JProbe Coverage failed (" + exitValue + ")" ); | |||||
| } | |||||
| } | |||||
| catch( IOException e ) | |||||
| { | |||||
| throw new TaskException( "Failed to execute JProbe Coverage.", e ); | |||||
| exe.setReturnCode( 0 ); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -199,11 +199,10 @@ public abstract class MSVSS | |||||
| return m_vssPath; | return m_vssPath; | ||||
| } | } | ||||
| protected int run( Commandline cmd ) | |||||
| protected void run( final Commandline cmd ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||||
| final Execute exe = new Execute( execManager ); | |||||
| final Execute exe = new Execute(); | |||||
| // If location of ss.ini is specified we need to set the | // If location of ss.ini is specified we need to set the | ||||
| // environment-variable SSDIR to this value | // environment-variable SSDIR to this value | ||||
| @@ -216,7 +215,8 @@ public abstract class MSVSS | |||||
| exe.setWorkingDirectory( getBaseDirectory() ); | exe.setWorkingDirectory( getBaseDirectory() ); | ||||
| exe.setCommandline( cmd ); | exe.setCommandline( cmd ); | ||||
| return exe.execute(); | |||||
| exe.setReturnCode( 0 ); | |||||
| exe.execute( getContext() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -9,8 +9,6 @@ package org.apache.tools.todo.taskdefs.vss; | |||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.AbstractTask; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.todo.types.Commandline; | import org.apache.tools.todo.types.Commandline; | ||||
| import org.apache.tools.todo.types.Path; | import org.apache.tools.todo.types.Path; | ||||
| @@ -208,11 +206,6 @@ public class MSVSSCHECKIN | |||||
| // -C | // -C | ||||
| commandLine.addArgument( "-C" + m_comment ); | commandLine.addArgument( "-C" + m_comment ); | ||||
| final int result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -9,8 +9,6 @@ package org.apache.tools.todo.taskdefs.vss; | |||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.AbstractTask; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.todo.types.Commandline; | import org.apache.tools.todo.types.Commandline; | ||||
| import org.apache.tools.todo.types.Path; | import org.apache.tools.todo.types.Path; | ||||
| @@ -250,12 +248,7 @@ public class MSVSSCHECKOUT | |||||
| // -Y | // -Y | ||||
| getLoginCommand( commandLine ); | getLoginCommand( commandLine ); | ||||
| final int result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| final String message = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -9,8 +9,6 @@ package org.apache.tools.todo.taskdefs.vss; | |||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.api.AbstractTask; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.tools.todo.types.Commandline; | import org.apache.tools.todo.types.Commandline; | ||||
| import org.apache.tools.todo.types.Path; | import org.apache.tools.todo.types.Path; | ||||
| @@ -471,7 +469,6 @@ public class MSVSSGET extends MSVSS | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| Commandline commandLine = new Commandline(); | Commandline commandLine = new Commandline(); | ||||
| int result = 0; | |||||
| // first off, make sure that we've got a command and a vssdir ... | // first off, make sure that we've got a command and a vssdir ... | ||||
| if( getVsspath() == null ) | if( getVsspath() == null ) | ||||
| @@ -505,12 +502,7 @@ public class MSVSSGET extends MSVSS | |||||
| // -Y | // -Y | ||||
| getLoginCommand( commandLine ); | getLoginCommand( commandLine ); | ||||
| result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| String msg = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( msg ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -222,7 +222,6 @@ public class MSVSSHISTORY extends MSVSS | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| Commandline commandLine = new Commandline(); | Commandline commandLine = new Commandline(); | ||||
| int result = 0; | |||||
| // first off, make sure that we've got a command and a vssdir and a label ... | // first off, make sure that we've got a command and a vssdir and a label ... | ||||
| if( getVsspath() == null ) | if( getVsspath() == null ) | ||||
| @@ -270,13 +269,7 @@ public class MSVSSHISTORY extends MSVSS | |||||
| System.out.println( "***: " + commandLine ); | System.out.println( "***: " + commandLine ); | ||||
| result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| String msg = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( msg ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -323,7 +323,6 @@ public class MSVSSLABEL extends MSVSS | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| Commandline commandLine = new Commandline(); | Commandline commandLine = new Commandline(); | ||||
| int result = 0; | |||||
| // first off, make sure that we've got a command and a vssdir and a label ... | // first off, make sure that we've got a command and a vssdir and a label ... | ||||
| if( getVsspath() == null ) | if( getVsspath() == null ) | ||||
| @@ -365,12 +364,6 @@ public class MSVSSLABEL extends MSVSS | |||||
| // -Y | // -Y | ||||
| getLoginCommand( commandLine ); | getLoginCommand( commandLine ); | ||||
| result = run( commandLine ); | |||||
| if( result != 0 ) | |||||
| { | |||||
| String msg = "Failed executing: " + commandLine.toString(); | |||||
| throw new TaskException( msg ); | |||||
| } | |||||
| run( commandLine ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -184,6 +184,30 @@ public class FileUtils | |||||
| return new File( path ); | return new File( path ); | ||||
| } | } | ||||
| /** | |||||
| * Builds a command-line from an array of individual arguments, quoting | |||||
| * the arguments as necessary. | |||||
| * | |||||
| * @todo Move to {@link org.apache.aut.nativelib.Os}, and get rid of the | |||||
| * exception. | |||||
| */ | |||||
| public static String buildCommandLine( final String[] arguments ) | |||||
| throws TaskException | |||||
| { | |||||
| final StringBuffer cmd = new StringBuffer(); | |||||
| for( int i = 0; i < arguments.length; i++ ) | |||||
| { | |||||
| String arg = arguments[ i ]; | |||||
| if( i > 0 ) | |||||
| { | |||||
| cmd.append( ' ' ); | |||||
| } | |||||
| cmd.append( quoteArgument( arg ) ); | |||||
| } | |||||
| return cmd.toString(); | |||||
| } | |||||
| /** | /** | ||||
| * Put quotes around the given String if necessary. <p> | * Put quotes around the given String if necessary. <p> | ||||
| * | * | ||||
| @@ -191,10 +215,10 @@ public class FileUtils | |||||
| * contains double quotes, use single quotes - else surround the argument by | * contains double quotes, use single quotes - else surround the argument by | ||||
| * double quotes.</p> | * double quotes.</p> | ||||
| * | * | ||||
| * @param argument Description of Parameter | |||||
| * @return Description of the Returned Value | |||||
| * @todo Move to {@link org.apache.aut.nativelib.Os}, and get rid of the | |||||
| * exception. | |||||
| */ | */ | ||||
| public static String quoteArgument( String argument ) | |||||
| public static String quoteArgument( final String argument ) | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| if( argument.indexOf( "\"" ) > -1 ) | if( argument.indexOf( "\"" ) > -1 ) | ||||