Made some tasks specify expected return code rather than checkin it themselves. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271266 13f79535-47bb-0310-9956-ffa450edef68master
@@ -8,7 +8,6 @@ | |||
package org.apache.antlib.build; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -102,17 +101,8 @@ public class Patch | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
buildCommand( exe.getCommandline() ); | |||
try | |||
{ | |||
exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
} | |||
exe.execute(); | |||
} | |||
private void validate() | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.antlib.cvslib; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Properties; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
@@ -158,19 +157,8 @@ public class Cvs | |||
exe.setCommandline( command ); | |||
exe.setEnvironment( env ); | |||
try | |||
{ | |||
final int retCode = exe.execute(); | |||
if( retCode != 0 ) | |||
{ | |||
//replace with an ExecuteException(message,code); | |||
throw new TaskException( "cvs exited with error code " + retCode ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( e.toString(), e ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
private Properties buildEnvironment() | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.antlib.nativelib; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Properties; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.aut.nativelib.Os; | |||
@@ -119,21 +118,8 @@ public class Exec | |||
private void doExecute( final Execute exe ) | |||
throws TaskException | |||
{ | |||
try | |||
{ | |||
final int err = exe.execute(); | |||
if( 0 != err ) | |||
{ | |||
final String message = | |||
REZ.getString( "exec.bad-resultcode.error", new Integer( err ) ); | |||
throw new TaskException( message ); | |||
} | |||
} | |||
catch( final IOException ioe ) | |||
{ | |||
final String message = REZ.getString( "exec.failed.error", ioe ); | |||
throw new TaskException( message, ioe ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
private void validate() | |||
@@ -7,7 +7,6 @@ | |||
*/ | |||
package org.apache.antlib.security; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -125,14 +124,7 @@ public class GenerateKey | |||
final Execute exe = new Execute( execManager ); | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
try | |||
{ | |||
exe.execute(); | |||
} | |||
catch( final IOException ioe ) | |||
{ | |||
throw new TaskException( ioe.getMessage(), ioe ); | |||
} | |||
exe.execute(); | |||
} | |||
private Commandline createCommand() | |||
@@ -298,14 +298,7 @@ public class SignJar | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
exe.setCommandline( cmd ); | |||
try | |||
{ | |||
exe.execute(); | |||
} | |||
catch( final IOException ioe ) | |||
{ | |||
throw new TaskException( ioe.getMessage(), ioe ); | |||
} | |||
exe.execute(); | |||
} | |||
private Commandline buildCommand( final File jarTarget, final File jarSource ) | |||
@@ -110,20 +110,31 @@ public class Execute | |||
* @return the exit status of the subprocess or <code>INVALID</code> | |||
*/ | |||
public int execute() | |||
throws IOException, TaskException | |||
throws TaskException | |||
{ | |||
final int returnCode = executenativeProcess(); | |||
final int returnCode = executeNativeProcess(); | |||
checkReturnCode( returnCode ); | |||
return returnCode; | |||
} | |||
/** | |||
* 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( "Unexpected return code " + returnCode ); | |||
} | |||
return returnCode; | |||
} | |||
private int executenativeProcess() | |||
/** | |||
* Actually execute the native process. | |||
*/ | |||
private int executeNativeProcess() | |||
throws TaskException | |||
{ | |||
final ExecMetaData metaData = buildExecMetaData(); | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.PrintStream; | |||
import java.util.ArrayList; | |||
import org.apache.aut.nativelib.ExecManager; | |||
@@ -233,14 +232,6 @@ public class Java | |||
exe.setWorkingDirectory( m_dir ); | |||
exe.setCommandline( command ); | |||
try | |||
{ | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
final String message = "Error executing class"; | |||
throw new TaskException( message, e ); | |||
} | |||
return exe.execute(); | |||
} | |||
} |
@@ -359,19 +359,12 @@ public abstract class DefaultCompilerAdapter | |||
commandArray = args; | |||
} | |||
try | |||
{ | |||
final ExecManager execManager = (ExecManager)m_attributes.getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
exe.setWorkingDirectory( m_baseDir ); | |||
final String[] commandline = commandArray; | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error running " + args[ 0 ] + " compiler", e ); | |||
} | |||
} | |||
finally | |||
{ | |||
@@ -19,9 +19,9 @@ import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.aut.nativelib.ExecOutputHandler; | |||
import org.apache.aut.nativelib.Os; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.myrmidon.framework.Pattern; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -825,22 +825,14 @@ public class Javadoc | |||
* Avoid problems with command line length in some environments. | |||
*/ | |||
exe.setWorkingDirectory( null ); | |||
exe.setCommandline( cmd ); | |||
exe.setReturnCode( 0 ); | |||
try | |||
{ | |||
exe.setCommandline( cmd ); | |||
final int ret = exe.execute(); | |||
if( ret != 0 ) | |||
{ | |||
throw new TaskException( "Javadoc returned " + ret ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Javadoc failed: " + e, e ); | |||
exe.execute(); | |||
} | |||
finally | |||
{ | |||
if( m_tmpList != null ) | |||
{ | |||
m_tmpList.delete(); | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.tools.ant.taskdefs.optional.ccm; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.aut.nativelib.ExecOutputHandler; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
@@ -72,7 +71,7 @@ public abstract class Continuus | |||
/** | |||
* Set the value of ccmAction. | |||
* | |||
* @param v Value to assign to ccmAction. | |||
* @param ccmAction Value to assign to ccmAction. | |||
*/ | |||
public void setCcmAction( final String ccmAction ) | |||
{ | |||
@@ -110,21 +109,14 @@ public abstract class Continuus | |||
protected int run( final Commandline cmd, final ExecOutputHandler handler ) | |||
throws TaskException | |||
{ | |||
try | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
if( null != handler ) | |||
{ | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
if( null != handler ) | |||
{ | |||
exe.setExecOutputHandler( handler ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
catch( final IOException ioe ) | |||
{ | |||
throw new TaskException( "Error", ioe ); | |||
exe.setExecOutputHandler( handler ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
} |
@@ -8,11 +8,10 @@ | |||
package org.apache.tools.ant.taskdefs.optional.clearcase; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -106,18 +105,11 @@ public abstract class ClearCase extends Task | |||
protected int run( Commandline cmd ) | |||
throws TaskException | |||
{ | |||
try | |||
{ | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
} | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
} | |||
@@ -8,12 +8,11 @@ | |||
package org.apache.tools.ant.taskdefs.optional.dotnet;// imports | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -141,35 +140,28 @@ public class NetCommand | |||
throws TaskException | |||
{ | |||
int err = -1;// assume the worst | |||
try | |||
if( _traceCommandLine ) | |||
{ | |||
//_owner.getLogger().info( _commandLine.toString() ); | |||
} | |||
else | |||
{ | |||
//in verbose mode we always log stuff | |||
logVerbose( _commandLine.toString() ); | |||
} | |||
_exe.setCommandline( _commandLine ); | |||
err = _exe.execute(); | |||
if( err != 0 ) | |||
{ | |||
if( _traceCommandLine ) | |||
if( _failOnError ) | |||
{ | |||
//_owner.getLogger().info( _commandLine.toString() ); | |||
throw new TaskException( _title + " returned: " + err ); | |||
} | |||
else | |||
{ | |||
//in verbose mode we always log stuff | |||
logVerbose( _commandLine.toString() ); | |||
} | |||
_exe.setCommandline( _commandLine ); | |||
err = _exe.execute(); | |||
if( err != 0 ) | |||
{ | |||
if( _failOnError ) | |||
{ | |||
throw new TaskException( _title + " returned: " + err ); | |||
} | |||
else | |||
{ | |||
getLogger().error( _title + " Result: " + err ); | |||
} | |||
getLogger().error( _title + " Result: " + err ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( _title + " failed: " + e, e ); | |||
} | |||
} | |||
/** | |||
@@ -185,17 +185,7 @@ public class JJTree extends Task | |||
final Execute exe = new Execute( execManager ); | |||
getLogger().debug( cmdl.toString() ); | |||
exe.setCommandline( new Commandline( cmdl.getCommandline() ) ); | |||
try | |||
{ | |||
if( exe.execute() != 0 ) | |||
{ | |||
throw new TaskException( "JJTree failed." ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Failed to launch JJTree: " + e ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
} |
@@ -8,13 +8,12 @@ | |||
package org.apache.tools.ant.taskdefs.optional.javacc; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Enumeration; | |||
import java.util.Hashtable; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -239,23 +238,13 @@ public class JavaCC extends Task | |||
private void runCommand( final CommandlineJava cmdline ) | |||
throws TaskException | |||
{ | |||
try | |||
{ | |||
getLogger().debug( cmdline.toString() ); | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
final String[] commandline = cmdline.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
int retval = exe.execute(); | |||
if( retval != 0 ) | |||
{ | |||
throw new TaskException( cmdline + " failed with return code " + retval ); | |||
} | |||
} | |||
catch( final IOException ioe ) | |||
{ | |||
throw new TaskException( "Could not launch " + cmdline + ": " + ioe ); | |||
} | |||
getLogger().debug( cmdline.toString() ); | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
final String[] commandline = cmdline.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
/** | |||
@@ -13,8 +13,8 @@ import java.io.IOException; | |||
import java.io.PrintWriter; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -255,14 +255,7 @@ public class JDependTask | |||
getLogger().info( "Output to be stored in " + m_outputFile.getPath() ); | |||
} | |||
getLogger().debug( "Executing: " + commandline.toString() ); | |||
try | |||
{ | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Process fork failed.", e ); | |||
} | |||
return exe.execute(); | |||
} | |||
@@ -658,14 +658,9 @@ public class JUnitTask extends Task | |||
} | |||
getLogger().debug( "Executing: " + cmd.toString() ); | |||
int retVal; | |||
try | |||
{ | |||
retVal = exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Process fork failed.", e ); | |||
return exe.execute(); | |||
} | |||
finally | |||
{ | |||
@@ -674,8 +669,6 @@ public class JUnitTask extends Task | |||
throw new TaskException( "Could not delete temporary properties file." ); | |||
} | |||
} | |||
return retVal; | |||
} | |||
/** | |||
@@ -284,17 +284,8 @@ public abstract class AbstractMetamataTask | |||
getLogger().debug( m_cmdl.toString() ); | |||
final String[] commandline = m_cmdl.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
try | |||
{ | |||
if( 0 != exe.execute() ) | |||
{ | |||
throw new TaskException( "Metamata task failed." ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Failed to launch Metamata task: " + e ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
protected void generateOptionsFile( File tofile, ArrayList options ) | |||
@@ -16,8 +16,8 @@ import java.util.Random; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.avalon.excalibur.io.IOUtil; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Argument; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
@@ -292,17 +292,8 @@ public class MParse | |||
getLogger().debug( m_cmdl.toString() ); | |||
final String[] commandline = m_cmdl.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
try | |||
{ | |||
if( exe.execute() != 0 ) | |||
{ | |||
throw new TaskException( "Metamata task failed." ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Failed to launch Metamata task: " + e ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
/** | |||
@@ -7,12 +7,11 @@ | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.perforce; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.aut.nativelib.ExecOutputHandler; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.oro.text.perl.Perl5Util; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.oro.text.perl.Perl5Util; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -171,14 +170,7 @@ public abstract class P4Base | |||
exe.setExecOutputHandler( handler ); | |||
exe.setCommandline( cmd ); | |||
try | |||
{ | |||
exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
} | |||
exe.execute(); | |||
if( null != m_error ) | |||
{ | |||
throw m_error; | |||
@@ -198,11 +198,6 @@ public class Pvcs | |||
result = exe.execute(); | |||
checkResultCode( result, cmd ); | |||
} | |||
catch( IOException e ) | |||
{ | |||
String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); | |||
throw new TaskException( msg ); | |||
} | |||
finally | |||
{ | |||
if( filelist != null ) | |||
@@ -8,12 +8,11 @@ | |||
package org.apache.tools.ant.taskdefs.optional.vss; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Properties; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -203,28 +202,21 @@ public abstract class MSVSS extends Task | |||
protected int run( Commandline cmd ) | |||
throws TaskException | |||
{ | |||
try | |||
{ | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
// If location of ss.ini is specified we need to set the | |||
// environment-variable SSDIR to this value | |||
if( m_serverPath != null ) | |||
{ | |||
final Properties env = new Properties(); | |||
env.setProperty( "SSDIR", m_serverPath ); | |||
exe.setEnvironment( env ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
// If location of ss.ini is specified we need to set the | |||
// environment-variable SSDIR to this value | |||
if( m_serverPath != null ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
final Properties env = new Properties(); | |||
env.setProperty( "SSDIR", m_serverPath ); | |||
exe.setEnvironment( env ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
} | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.tools.ant.taskdefs.unix; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -98,22 +97,12 @@ public class Rpm | |||
m_topDir = getBaseDirectory(); | |||
} | |||
exe.setWorkingDirectory( m_topDir ); | |||
exe.setCommandline( cmd ); | |||
try | |||
{ | |||
final String message = "Building the RPM based on the " + m_specFile + " file"; | |||
getLogger().info( message ); | |||
exe.setReturnCode( 0 ); | |||
if( 0 != exe.execute() ) | |||
{ | |||
throw new TaskException( "Failed to execute rpm" ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
} | |||
final String message = "Building the RPM based on the " + m_specFile + " file"; | |||
getLogger().info( message ); | |||
exe.execute(); | |||
} | |||
private Commandline createCommand() | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.PrintStream; | |||
import java.util.ArrayList; | |||
import org.apache.aut.nativelib.ExecManager; | |||
@@ -233,14 +232,6 @@ public class Java | |||
exe.setWorkingDirectory( m_dir ); | |||
exe.setCommandline( command ); | |||
try | |||
{ | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
final String message = "Error executing class"; | |||
throw new TaskException( message, e ); | |||
} | |||
return exe.execute(); | |||
} | |||
} |
@@ -359,19 +359,12 @@ public abstract class DefaultCompilerAdapter | |||
commandArray = args; | |||
} | |||
try | |||
{ | |||
final ExecManager execManager = (ExecManager)m_attributes.getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
exe.setWorkingDirectory( m_baseDir ); | |||
final String[] commandline = commandArray; | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error running " + args[ 0 ] + " compiler", e ); | |||
} | |||
} | |||
finally | |||
{ | |||
@@ -19,9 +19,9 @@ import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.aut.nativelib.ExecOutputHandler; | |||
import org.apache.aut.nativelib.Os; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.myrmidon.framework.Pattern; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -825,22 +825,14 @@ public class Javadoc | |||
* Avoid problems with command line length in some environments. | |||
*/ | |||
exe.setWorkingDirectory( null ); | |||
exe.setCommandline( cmd ); | |||
exe.setReturnCode( 0 ); | |||
try | |||
{ | |||
exe.setCommandline( cmd ); | |||
final int ret = exe.execute(); | |||
if( ret != 0 ) | |||
{ | |||
throw new TaskException( "Javadoc returned " + ret ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Javadoc failed: " + e, e ); | |||
exe.execute(); | |||
} | |||
finally | |||
{ | |||
if( m_tmpList != null ) | |||
{ | |||
m_tmpList.delete(); | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.tools.ant.taskdefs.optional.ccm; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.aut.nativelib.ExecOutputHandler; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
@@ -72,7 +71,7 @@ public abstract class Continuus | |||
/** | |||
* Set the value of ccmAction. | |||
* | |||
* @param v Value to assign to ccmAction. | |||
* @param ccmAction Value to assign to ccmAction. | |||
*/ | |||
public void setCcmAction( final String ccmAction ) | |||
{ | |||
@@ -110,21 +109,14 @@ public abstract class Continuus | |||
protected int run( final Commandline cmd, final ExecOutputHandler handler ) | |||
throws TaskException | |||
{ | |||
try | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
if( null != handler ) | |||
{ | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
if( null != handler ) | |||
{ | |||
exe.setExecOutputHandler( handler ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
catch( final IOException ioe ) | |||
{ | |||
throw new TaskException( "Error", ioe ); | |||
exe.setExecOutputHandler( handler ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
} |
@@ -8,11 +8,10 @@ | |||
package org.apache.tools.ant.taskdefs.optional.clearcase; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -106,18 +105,11 @@ public abstract class ClearCase extends Task | |||
protected int run( Commandline cmd ) | |||
throws TaskException | |||
{ | |||
try | |||
{ | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
} | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
} | |||
@@ -8,12 +8,11 @@ | |||
package org.apache.tools.ant.taskdefs.optional.dotnet;// imports | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -141,35 +140,28 @@ public class NetCommand | |||
throws TaskException | |||
{ | |||
int err = -1;// assume the worst | |||
try | |||
if( _traceCommandLine ) | |||
{ | |||
//_owner.getLogger().info( _commandLine.toString() ); | |||
} | |||
else | |||
{ | |||
//in verbose mode we always log stuff | |||
logVerbose( _commandLine.toString() ); | |||
} | |||
_exe.setCommandline( _commandLine ); | |||
err = _exe.execute(); | |||
if( err != 0 ) | |||
{ | |||
if( _traceCommandLine ) | |||
if( _failOnError ) | |||
{ | |||
//_owner.getLogger().info( _commandLine.toString() ); | |||
throw new TaskException( _title + " returned: " + err ); | |||
} | |||
else | |||
{ | |||
//in verbose mode we always log stuff | |||
logVerbose( _commandLine.toString() ); | |||
} | |||
_exe.setCommandline( _commandLine ); | |||
err = _exe.execute(); | |||
if( err != 0 ) | |||
{ | |||
if( _failOnError ) | |||
{ | |||
throw new TaskException( _title + " returned: " + err ); | |||
} | |||
else | |||
{ | |||
getLogger().error( _title + " Result: " + err ); | |||
} | |||
getLogger().error( _title + " Result: " + err ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( _title + " failed: " + e, e ); | |||
} | |||
} | |||
/** | |||
@@ -185,17 +185,7 @@ public class JJTree extends Task | |||
final Execute exe = new Execute( execManager ); | |||
getLogger().debug( cmdl.toString() ); | |||
exe.setCommandline( new Commandline( cmdl.getCommandline() ) ); | |||
try | |||
{ | |||
if( exe.execute() != 0 ) | |||
{ | |||
throw new TaskException( "JJTree failed." ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Failed to launch JJTree: " + e ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
} |
@@ -8,13 +8,12 @@ | |||
package org.apache.tools.ant.taskdefs.optional.javacc; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Enumeration; | |||
import java.util.Hashtable; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -239,23 +238,13 @@ public class JavaCC extends Task | |||
private void runCommand( final CommandlineJava cmdline ) | |||
throws TaskException | |||
{ | |||
try | |||
{ | |||
getLogger().debug( cmdline.toString() ); | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
final String[] commandline = cmdline.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
int retval = exe.execute(); | |||
if( retval != 0 ) | |||
{ | |||
throw new TaskException( cmdline + " failed with return code " + retval ); | |||
} | |||
} | |||
catch( final IOException ioe ) | |||
{ | |||
throw new TaskException( "Could not launch " + cmdline + ": " + ioe ); | |||
} | |||
getLogger().debug( cmdline.toString() ); | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
final String[] commandline = cmdline.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
/** | |||
@@ -13,8 +13,8 @@ import java.io.IOException; | |||
import java.io.PrintWriter; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -255,14 +255,7 @@ public class JDependTask | |||
getLogger().info( "Output to be stored in " + m_outputFile.getPath() ); | |||
} | |||
getLogger().debug( "Executing: " + commandline.toString() ); | |||
try | |||
{ | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Process fork failed.", e ); | |||
} | |||
return exe.execute(); | |||
} | |||
@@ -658,14 +658,9 @@ public class JUnitTask extends Task | |||
} | |||
getLogger().debug( "Executing: " + cmd.toString() ); | |||
int retVal; | |||
try | |||
{ | |||
retVal = exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Process fork failed.", e ); | |||
return exe.execute(); | |||
} | |||
finally | |||
{ | |||
@@ -674,8 +669,6 @@ public class JUnitTask extends Task | |||
throw new TaskException( "Could not delete temporary properties file." ); | |||
} | |||
} | |||
return retVal; | |||
} | |||
/** | |||
@@ -284,17 +284,8 @@ public abstract class AbstractMetamataTask | |||
getLogger().debug( m_cmdl.toString() ); | |||
final String[] commandline = m_cmdl.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
try | |||
{ | |||
if( 0 != exe.execute() ) | |||
{ | |||
throw new TaskException( "Metamata task failed." ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Failed to launch Metamata task: " + e ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
protected void generateOptionsFile( File tofile, ArrayList options ) | |||
@@ -16,8 +16,8 @@ import java.util.Random; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.avalon.excalibur.io.IOUtil; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Argument; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
@@ -292,17 +292,8 @@ public class MParse | |||
getLogger().debug( m_cmdl.toString() ); | |||
final String[] commandline = m_cmdl.getCommandline(); | |||
exe.setCommandline( new Commandline( commandline ) ); | |||
try | |||
{ | |||
if( exe.execute() != 0 ) | |||
{ | |||
throw new TaskException( "Metamata task failed." ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Failed to launch Metamata task: " + e ); | |||
} | |||
exe.setReturnCode( 0 ); | |||
exe.execute(); | |||
} | |||
/** | |||
@@ -7,12 +7,11 @@ | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.perforce; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.aut.nativelib.ExecOutputHandler; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.oro.text.perl.Perl5Util; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.oro.text.perl.Perl5Util; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -171,14 +170,7 @@ public abstract class P4Base | |||
exe.setExecOutputHandler( handler ); | |||
exe.setCommandline( cmd ); | |||
try | |||
{ | |||
exe.execute(); | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
} | |||
exe.execute(); | |||
if( null != m_error ) | |||
{ | |||
throw m_error; | |||
@@ -198,11 +198,6 @@ public class Pvcs | |||
result = exe.execute(); | |||
checkResultCode( result, cmd ); | |||
} | |||
catch( IOException e ) | |||
{ | |||
String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); | |||
throw new TaskException( msg ); | |||
} | |||
finally | |||
{ | |||
if( filelist != null ) | |||
@@ -8,12 +8,11 @@ | |||
package org.apache.tools.ant.taskdefs.optional.vss; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Properties; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.myrmidon.framework.Execute; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Commandline; | |||
/** | |||
@@ -203,28 +202,21 @@ public abstract class MSVSS extends Task | |||
protected int run( Commandline cmd ) | |||
throws TaskException | |||
{ | |||
try | |||
{ | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
// If location of ss.ini is specified we need to set the | |||
// environment-variable SSDIR to this value | |||
if( m_serverPath != null ) | |||
{ | |||
final Properties env = new Properties(); | |||
env.setProperty( "SSDIR", m_serverPath ); | |||
exe.setEnvironment( env ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
catch( IOException e ) | |||
final ExecManager execManager = (ExecManager)getService( ExecManager.class ); | |||
final Execute exe = new Execute( execManager ); | |||
// If location of ss.ini is specified we need to set the | |||
// environment-variable SSDIR to this value | |||
if( m_serverPath != null ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
final Properties env = new Properties(); | |||
env.setProperty( "SSDIR", m_serverPath ); | |||
exe.setEnvironment( env ); | |||
} | |||
exe.setWorkingDirectory( getBaseDirectory() ); | |||
exe.setCommandline( cmd ); | |||
return exe.execute(); | |||
} | |||
} | |||
@@ -8,7 +8,6 @@ | |||
package org.apache.tools.ant.taskdefs.unix; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import org.apache.aut.nativelib.ExecManager; | |||
import org.apache.myrmidon.api.AbstractTask; | |||
import org.apache.myrmidon.api.TaskException; | |||
@@ -98,22 +97,12 @@ public class Rpm | |||
m_topDir = getBaseDirectory(); | |||
} | |||
exe.setWorkingDirectory( m_topDir ); | |||
exe.setCommandline( cmd ); | |||
try | |||
{ | |||
final String message = "Building the RPM based on the " + m_specFile + " file"; | |||
getLogger().info( message ); | |||
exe.setReturnCode( 0 ); | |||
if( 0 != exe.execute() ) | |||
{ | |||
throw new TaskException( "Failed to execute rpm" ); | |||
} | |||
} | |||
catch( IOException e ) | |||
{ | |||
throw new TaskException( "Error", e ); | |||
} | |||
final String message = "Building the RPM based on the " + m_specFile + " file"; | |||
getLogger().info( message ); | |||
exe.execute(); | |||
} | |||
private Commandline createCommand() | |||