Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] executing maven goal from user's request

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? 


On Thu, Apr 11, 2013 at 12:12 PM, Greg Amerson <gregory.amerson@xxxxxxxxxxx> wrote:
Hello m2e-devs,

I have an eclipse plugin I'm building that adds some support for custom maven goals for one of my companies maven build plugins.  Basically I want the user to be able to manually invoke a particular execution of a maven goal via a button or toolbar, etc. and then my code could execute the approach maven goal/execution automatically.  So when they select the action, someway I need to programmatically execute a command like this: 

mvn liferay:build-serivce

My question is what is the correct m2e-API for me to use.  One idea would be to use the m2e build launch configuration type (org.eclipse.m2e.Maven2LaunchConfigurationType) and invoke a full launch?

The other approach I could see would be using the IMaven api more directly, something like:
IMaven maven = MavenPlugin.getMaven();
then maven.execute(...) command?

The 2nd approach seems simpler and more testable (wouldn't require UI plugin for unit testing), but not sure feasible that approach would be.

Would love to hear other m2e-* developers thoughts.

Thanks 

--
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com



--
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com

Back to the top