I checked out the source for commons-exec and built the
commons-exec-1.0-SNAPSHOT.jar. I added this jar as a dependency to my m2
plugin project and wrote a simple Foo app to verify that everything was
working. The app just writes the current time into a file and all is well
with this. What's missing is how to tie the output from my process into the
currently executing maven process. Below is my mojo's execute method. None
of the unit tests actually demonstrate how to configure the current process
to receive logging from a sub-process.


public void execute() throws MojoExecutionException
{
CommandLine cl = new CommandLineImpl();
cl.setExecutable("java");
cl.addArgument("-classpath");
cl.addArgument("D:/dev/workspace/maven-hello-plugin/bin");
cl.addArgument("com.mycompany.maven.plugins.Foo");
try
{
Exec exec = new Exec();
exec.execute(cl);
}
catch (IOException e)
{
throw new MojoExecutionException(e);
}
}


Wb

Reply via email to