Browse Source

Reworked task to remove dependency on Execute

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270799 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
8d3ee3fbea
2 changed files with 70 additions and 10 deletions
  1. +35
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
  2. +35
    -5
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java

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

@@ -19,11 +19,11 @@ import java.text.MessageFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import org.apache.aut.nativelib.ExecOutputHandler;
import org.apache.avalon.excalibur.io.IOUtil;
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.tools.ant.taskdefs.exec.Execute;
import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.taskdefs.exec.LogOutputStream;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;


/** /**
@@ -44,6 +44,7 @@ import org.apache.tools.ant.types.Commandline;
*/ */
public class Pvcs public class Pvcs
extends AbstractTask extends AbstractTask
implements ExecOutputHandler
{ {
/** /**
* Constant for the thing to execute * Constant for the thing to execute
@@ -72,6 +73,7 @@ public class Pvcs
private String m_repository; private String m_repository;
private boolean m_updateOnly; private boolean m_updateOnly;
private String m_workspace; private String m_workspace;
private FileOutputStream m_output;


/** /**
* Creates a Pvcs object * Creates a Pvcs object
@@ -269,9 +271,10 @@ 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 Execute exe = new Execute();
exe.setOutput( new FileOutputStream( tmp ) );
exe.setError( new LogOutputStream( getLogger(), true ) );
final Execute2 exe = new Execute2();
setupLogger( exe );
exe.setExecOutputHandler( this );
m_output = new FileOutputStream( tmp );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() ); exe.setCommandline( cmd.getCommandline() );
final int result = exe.execute(); final int result = exe.execute();
@@ -306,6 +309,7 @@ public class Pvcs
} }
finally finally
{ {
IOUtil.shutdownStream( m_output );
if( null != tmp ) if( null != tmp )
{ {
tmp.delete(); tmp.delete();
@@ -313,6 +317,32 @@ public class Pvcs
} }
} }


/**
* Receive notification about the process writing
* to standard output.
*/
public void stdout( final String line )
{
try
{
m_output.write( line.getBytes() );
}
catch( final IOException ioe )
{
final String message = "Failed to write to output stream";
getLogger().error( message );
}
}

/**
* Receive notification about the process writing
* to standard error.
*/
public void stderr( final String line )
{
getLogger().warn( line );
}

private Commandline buildPCLICommand() private Commandline buildPCLICommand()
throws TaskException throws TaskException
{ {


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

@@ -19,11 +19,11 @@ import java.text.MessageFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import org.apache.aut.nativelib.ExecOutputHandler;
import org.apache.avalon.excalibur.io.IOUtil;
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.tools.ant.taskdefs.exec.Execute;
import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.taskdefs.exec.Execute2;
import org.apache.tools.ant.taskdefs.exec.LogOutputStream;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;


/** /**
@@ -44,6 +44,7 @@ import org.apache.tools.ant.types.Commandline;
*/ */
public class Pvcs public class Pvcs
extends AbstractTask extends AbstractTask
implements ExecOutputHandler
{ {
/** /**
* Constant for the thing to execute * Constant for the thing to execute
@@ -72,6 +73,7 @@ public class Pvcs
private String m_repository; private String m_repository;
private boolean m_updateOnly; private boolean m_updateOnly;
private String m_workspace; private String m_workspace;
private FileOutputStream m_output;


/** /**
* Creates a Pvcs object * Creates a Pvcs object
@@ -269,9 +271,10 @@ 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 Execute exe = new Execute();
exe.setOutput( new FileOutputStream( tmp ) );
exe.setError( new LogOutputStream( getLogger(), true ) );
final Execute2 exe = new Execute2();
setupLogger( exe );
exe.setExecOutputHandler( this );
m_output = new FileOutputStream( tmp );
exe.setWorkingDirectory( getBaseDirectory() ); exe.setWorkingDirectory( getBaseDirectory() );
exe.setCommandline( cmd.getCommandline() ); exe.setCommandline( cmd.getCommandline() );
final int result = exe.execute(); final int result = exe.execute();
@@ -306,6 +309,7 @@ public class Pvcs
} }
finally finally
{ {
IOUtil.shutdownStream( m_output );
if( null != tmp ) if( null != tmp )
{ {
tmp.delete(); tmp.delete();
@@ -313,6 +317,32 @@ public class Pvcs
} }
} }


/**
* Receive notification about the process writing
* to standard output.
*/
public void stdout( final String line )
{
try
{
m_output.write( line.getBytes() );
}
catch( final IOException ioe )
{
final String message = "Failed to write to output stream";
getLogger().error( message );
}
}

/**
* Receive notification about the process writing
* to standard error.
*/
public void stderr( final String line )
{
getLogger().warn( line );
}

private Commandline buildPCLICommand() private Commandline buildPCLICommand()
throws TaskException throws TaskException
{ {


Loading…
Cancel
Save