Class CommandlineExecutor

java.lang.Object
org.apache.maven.surefire.extensions.util.CommandlineExecutor
All Implemented Interfaces:
Closeable, AutoCloseable

public class CommandlineExecutor extends Object implements Closeable
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 Details

    • CommandlineExecutor

      public CommandlineExecutor(org.apache.maven.surefire.shared.utils.cli.Commandline cli, CountdownCloseable endOfStreamsCountdown)
  • Method Details