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

Thanks Igor,  I'll have a look at ExecutePomAction.

With regards to IMaven.execute() I believe it is working as expected.  I'm executing a mojo for a 3rd party maven plugin and I've received confirmation from the developer of that plugin that multiple executions of the mojo from same JVM instance will lead to problems, due to classloading and keeping old settings from previous invocation.




On Tue, Apr 16, 2013 at 1:18 AM, Igor Fedorenko <igor@xxxxxxxxxxxxxx> wrote:
Running Maven in external JVM is mostly a convenience meant for users
who do not want to run builds from command line for whatever reason. It
provides very limited integration with eclipse workspace and
specifically no integration with eclipse workspace build. There is no
public API to launch maven build in external JVM but you can see how
this is implemented in ExecutePomAction and do the same in your code.

IMaven.execute should also work, but the API is rather low-level and
verbose, which was necessary to enable caching of plugin classloaders
across multiple executions of the same mojo. I will need complete
standalone example to tell why it is not working for you.

--
Regards,
Igor


On 2013-04-15 12:58 PM, Greg Amerson wrote:
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 <mailto:gregory.amerson@liferay.com>> 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 <http://www.liferay.com>





--
Greg Amerson
Liferay Developer Tools
Liferay, Inc. www.liferay.com <http://www.liferay.com>


_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-dev

_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-dev



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

Back to the top