Four Easy Steps to Providing Help for your Maven Plugin

This is easy, it is supported out of the box.

Step 1 - make sure each mojo has the JavaDoc, this will be used to generate your help files. E.g.:

	/**
	 * Create and provision each of the boxes defined in src/main/vbox.
	 *
	 * @goal provision
	 * @phase pre-integration-test
	 */
	public class ProvisionMojo extends AbstractVBoxesMojo {
	
		/**
		 * Which targets in the Provision.xml to execute, or all if "*".
		 *
		 * @parameter expression="${vbox.provision.targets}", default="*"
		 */
		protected String targets = "*";

Step 2 - add the "helpmojo" goal to your plugin.

	            <plugin>
	                <groupId>org.apache.maven.plugins</groupId>
	                <artifactId>maven-plugin-plugin</artifactId>
	                <version>3.2</version>
	                <executions>
	                    <execution>
	                        <id>generated-helpmojo</id>
	                        <goals>
	                            <goal>helpmojo</goal>
	                        </goals>
	                    </execution>
	                </executions>
	            </plugin>

Step 3 - execute "mvn install".

Step 4 - test by executing "mvn vbox:help" (substitute your own plugin's name), you'll see something like this.

...

A Maven plugin for creating, starting, and stopping VirtualBoxes.

This plugin has 8 goals:

...

vbox:help
  Display help information on vbox-maven-plugin.
  Call mvn vbox:help -Ddetail=true -Dgoal=<goal-name> to display parameter
  details.

...

vbox:provision
  Create and provision each of the boxes defined.
...

An example of the usage can be found on GitHub. And I've written tips on writing Maven plugins before.

Tags

ant (2)   antlr (1)   applet (1)   apsectj (1)   asm (1)   aspectj (1)   bdd (1)   blog (1)   cd (1)   coldfusion (2)   concurrency (4)   cucumber (1)   dashing (1)   docker (3)   drop-wizard (1)   drupal (1)   dsl (1)   gatling (1)   geb (1)   gist (13)   git (1)   graphite (1)   groovy (2)   hibernate (2)   ioc (1)   java (44)   java-8 (1)   java-fx (1)   jmeter (2)   jpa (2)   junit (5)   links (12)   maven (12)   middleman (2)   mocking (1)   mongodb (1)   oped (9)   os-x (1)   performance (4)   photos (1)   plaf (14)   ruby (3)   scala (1)   selenium (4)   software (10)   spring (5)   spring-mvc (1)   swing (15)   testing (17)   tips (4)   tomcat (3)   tuples (1)   tutorial (1)   unix (6)   vagrant (2)   web (4)   windows (1)