views:

38

answers:

1

Hi all,

Is it possible to execute a plugin from a plugin? For instance, if I want to programmatically call another plugin from within a plugin, not via static XML.

Is this possible, how would I do that?

Thanks,

Walter

A: 

There are several ways to do this:

  • Use MavenInvoker to fork a new maven process.

This has pros and cons, especially since you're building the project twice, but a common pattern is to modify the maven model, write it out to the file system as a temporary pom XML file, point the invoker to this pom. Drawback: you're losing the original model and wasting resources. Pro: you can do anything you want to the (new) maven model dynamically. This is very powerful

  • Let your plugin either aggregate or extend the original plugin.

Extending is a lot simpler, configuration is automatically there (Google for maven extend plugin ). By Aggregation I mean calling the plugin programmatically which means you will probably have to access the plexus container to wire up the plugin configuration

seanizer
I am using the Maven Embedder, I think it is exactly what I wanted.