If you find yourself like me, wondering how to get rid of all this
identical Maven plugin XML in multiple modules, where inheritence is
not an option, you may be wanting to create a plugin that executes the
goals of other plugins, a plugin macro, if you will.  Well, since I
could find no easy way to execute other plugins within a plugin, I
created the Mojo Executor library, which allows you to execute goals
on other plugins programmatically.

For example, say you wanted to execute the copy-dependencies goal on
the dependency plugin, you'd write this:

executeMojo(
             plugin(
                     groupId("org.apache.maven.plugins"),
                     artifactId("maven-dependency-plugin"),
                     version("2.0")
             ),
             goal("copy-dependencies"),
             configuration(
                     element(name("outputDirectory"),
"${project.build.directory}/foo")
             ),
             executionEnvironment(
                     project,
                     session,
                     pluginManager
             )
          );

Since this is just Java code, you can execute goals as many times as
you'd like with whatever configuration you need. The fluent interface
helps keep things readable, and the library leverages most of the
existing Maven behavior, including configuration merging, so it is
just like you defined an execution in your POM.  I'm currently using
this plugin for an integration test plugin that will run your
integration tests against any number of containers in one execution
with minimal XML (using repeated executions of surefire and cargo), so
you can do something like this:

mvn integration-test -Dcontainers=tomcat5x,jetty6x,jboss42x,resin3x

The mojo-executor project is here:

http://mojo-executor.googlecode.com

And the integration test plugin will be forthcoming...

Don

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to