donaldp 02/02/09 16:26:05
Modified: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec
Execute2.java
Log:
All logging will be routed via System.err or System.out if there is no
ExecOutputHandler defined.
Revision Changes Path
1.7 +34 -18
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute2.java
Index: Execute2.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/Execute2.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Execute2.java 6 Feb 2002 12:45:18 -0000 1.6
+++ Execute2.java 10 Feb 2002 00:26:05 -0000 1.7
@@ -10,12 +10,10 @@
import java.io.File;
import java.io.IOException;
import java.util.Properties;
-import org.apache.aut.nativelib.DefaultExecOutputHandler;
import org.apache.aut.nativelib.ExecException;
import org.apache.aut.nativelib.ExecManager;
import org.apache.aut.nativelib.ExecMetaData;
import org.apache.aut.nativelib.ExecOutputHandler;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.Commandline;
@@ -25,7 +23,6 @@
* @author [EMAIL PROTECTED]
*/
public class Execute2
- extends AbstractLogEnabled
{
private Commandline m_command;
private Properties m_environment = new Properties();
@@ -53,13 +50,22 @@
/**
* Sets the commandline of the subprocess to launch.
*
- * @param commandline the commandline of the subprocess to launch
+ * @param command the commandline of the subprocess to launch
*/
public void setCommandline( final Commandline command )
{
m_command = command;
}
+ public Commandline getCommandline()
+ {
+ if( null == m_command )
+ {
+ m_command = new Commandline();
+ }
+ return m_command;
+ }
+
public void setEnvironment( final Properties environment )
{
if( null == environment )
@@ -72,7 +78,7 @@
/**
* Set whether to propagate the default environment or not.
*
- * @param newenv whether to propagate the process environment.
+ * @param newEnvironment whether to propagate the process environment.
*/
public void setNewenvironment( boolean newEnvironment )
{
@@ -93,30 +99,40 @@
* Runs a process defined by the command line and returns its exit
status.
*
* @return the exit status of the subprocess or <code>INVALID</code>
- * @exception IOException Description of Exception
*/
public int execute()
throws IOException, TaskException
{
- if( null == m_handler )
- {
- m_handler = new DefaultExecOutputHandler();
- setupLogger( m_handler );
- }
-
try
{
- final String[] command = m_command.getCommandline();
-
- final ExecMetaData metaData =
- new ExecMetaData( command, m_environment,
- m_workingDirectory, m_newEnvironment );
+ final ExecMetaData metaData = buildExecMetaData();
- return m_execManager.execute( metaData, m_handler, m_timeout );
+ 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 );
+ }
}
catch( final ExecException ee )
{
throw new TaskException( ee.getMessage(), ee );
}
+ }
+
+ private ExecMetaData buildExecMetaData()
+ {
+ final String[] command = m_command.getCommandline();
+
+ final ExecMetaData metaData =
+ new ExecMetaData( command, m_environment,
+ m_workingDirectory, m_newEnvironment );
+ return metaData;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>