Class CommandlineExecutor
java.lang.Object
org.apache.maven.surefire.extensions.util.CommandlineExecutor
- All Implemented Interfaces:
Closeable
,AutoCloseable
Programming model with this class:
try ( CommandlineExecutor exec = new CommandlineExecutor( cli, endOfStreamsCountdown );
CommandlineStreams streams = exec.execute() )
{
// register exec in the shutdown hook to destroy pending process
// register streams in the shutdown hook to close all three streams
ReadableByteChannel stdOut = streams.getStdOutChannel();
ReadableByteChannel stdErr = streams.getStdErrChannel();
WritableByteChannel stdIn = streams.getStdInChannel();
// lineConsumerThread = new LineConsumerThread( ..., stdErr, ..., endOfStreamsCountdown );
// lineConsumerThread.start();
// stdIn.write( ... );
int exitCode = exec.awaitExit();
// process exitCode
}
catch ( InterruptedException e )
{
lineConsumerThread.disable();
}
catch ( CommandLineException e )
{
// handle the exceptions
}
-
Constructor Summary
ConstructorsConstructorDescriptionCommandlineExecutor
(org.apache.maven.surefire.shared.utils.cli.Commandline cli, CountdownCloseable endOfStreamsCountdown) -
Method Summary
-
Constructor Details
-
Method Details
-
execute
public CommandlineStreams execute() throws org.apache.maven.surefire.shared.utils.cli.CommandLineException- Throws:
org.apache.maven.surefire.shared.utils.cli.CommandLineException
-
awaitExit
- Throws:
InterruptedException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-