So first I'm trying to use the IMaven.execute() approach. Also I'm trying out the new IMavenExecutionRequest that I saw Igor mention a few days ago. So here is what I'm doing:
return this.maven.execute( new ICallable<IStatus>()
{
public IStatus call( IMavenExecutionContext context, IProgressMonitor monitor ) throws CoreException
{
final IMavenProjectFacade projectFacade = // get project facade
projectManager.execute(projectFacade, new ICallable<IStatus>()
{
public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor)
{
// calculate execution plan
// get mojoexecution
// run maven.execute( proj, mojo, monitor )
This seems to be working the first time, however, on subsequent executes() it is failing. The m2e code isn't failling, its just underlying mojo plugin custom goal is not executing the same as it does the first time I perform the execute. Also it doesn't work as it does everytime on the CLI. I suspect that the Mojo that I'm calling is executing some code that assumes its running in a single/separate JVM instance, i.e. I believe the mojo may be doing some things assuming that the JVM will be shutdown right afterwards. Therefore multiple calls into the mojo plugin with the same instance of the JVM could be causing problems.
Is there any way that for a particular mojo execution I can tell Maven to exec it in a separate JVM instance?