Help with Maven MojosThe best sources of information are Developing Java Plugins for Maven 3.x and Maven: The Definitive Guide: Chapter 11 Writing Plugins. New Mojos
Each Mojo is a java file that extends package org.apache.commons.release.plugin.mojos; @Mojo(name = "detach-distributions", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true) public class CommonsDistributionDetachmentMojo extends AbstractMojo { ..... } commons-release:detach-distributions that is to occur during the VERIFY maven
lifecycle.
The variables in the mojo that are declared as private with the annotations @Parameter(property = "commons.release.dryRun", defaultValue = "false") private Boolean dryRun; <plugin> <groupId>org.apache.commons</groupId> <artifactId>commons-release-plugin</artifactId> <version>1.8.0</version> <configuration> <dryRun>true</dryRun> </configuration> </plugin> property here (as in the 1.1 release), you can, on the command line,
use the following -Dcommons.release.dryRun=true .
Unit testing
We've declared mock maven poms in the <plugin> <groupId>org.apache.commons</groupId> <artifactId>commons-release-plugin</artifactId> <configuration> <project implementation="org.apache.commons.release.plugin.stubs.DistributionDetachmentProjectStub" /> <workingDirectory>target/commons-release-plugin</workingDirectory> <distSvnStagingUrl>mockDistSvnStagingUrl</distSvnStagingUrl> </configuration> </plugin> MojoRule in our test class,
@Rule public MojoRule rule = new MojoRule() { @Override protected void before() throws Throwable { } @Override protected void after() { } }; File pointed to the path of the mock pom, and then
making the following call:
mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testPom); compress-site goal.
DebuggingMaven ships with a debugger under the hood. It is suggested that you have a sandbox project in which you can run the goals or the plugin configuration. Once you have that set up you can run something like mvnDebug commons-release:detach-distributions |