Apache Maven Help Plugin

1. Overview

The Maven Help Plugin is used to get relative information about a project or the system.

2. Plugin Goals

The Help Plugin has 7 goals:
  • help:active-profiles lists the profiles which are currently active for the build.
  • help:all-profiles lists the available profiles under the current project.
  • help:describe describes the attributes of a Plugin and/or a Mojo (Maven plain Old Java Object).
  • help:effective-pom displays the effective POM as an XML for the current build, with the active profiles factored in.
  • help:effective-settings displays the calculated settings as an XML for the project, given any profile enhancement and the inheritance of the global settings into the user-level settings.
  • help:evaluate evaluates Maven expressions given by the user in an interactive mode.
  • help:system displays a list of the platform details like system properties and environment variables.

3.Usage

Below are the different goals and the minimalist configurations of the Help Plugin.

The help:active-profiles Goal

The active-profiles goal is used to discover which profiles have been applied to the projects currently being built. For each project in the build session, it will output a list of profiles which have been applied to that project, along with the source of the profile (POM, settings.xml or profiles.xml).
You can execute this goal using the following command:
# mvn help:active-profiles

The help:all-profiles Goal

The all-profiles goal is used to discover all available profiles under the current project.
You can execute this goal using the following command:
# mvn help:all-profiles

The help:describe Goal

The describe goal is used to discover information about Maven plugins. Given either a plugin or a groupId, an artifactId and optionally a version, the goal will lookup that plugin and output details about it. If the user also specifies which goal to describe, the describe goal will limit output to the details of that goal, including parameters.
You can execute this goal using the following command:
# mvn help:describe -DgroupId=org.somewhere -DartifactId=some-plugin -Dversion=0.0.0
Refer to Configuring Describe Goal for more information about its configuration.

The help:effective-pom Goal

The effective-pom goal is used to make visible the POM that results from the application of interpolation, inheritance and active profiles. It provides a useful way of removing the guesswork about just what ends up in the POM that Maven uses to build your project. It will iterate over all projects in the current build session, printing the effective POM for each.
You can execute this goal using the following command:
# mvn help:effective-pom

The help:effective-settings Goal

The effective-settings goal is used to view the settings that Maven actually uses to run the build. These settings are a result of merging the global file with the user's file, with the user's file taking precedence.
You can execute this goal using the following command:
# mvn help:effective-settings

The help:system Goal

The system goal is used to view the system information like system properties and environment variables.
You can execute this goal using the following command:
# mvn help:system

The help:evaluate Goal

You could use this interactive goal to evaluate some Maven expressions. To do it, just call the help:evaluate goal:
# mvn help:evaluate -Dartifact=org.apache.maven.plugins:maven-help-plugin
...
[INFO] [help:evaluate]
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${project.artifactId}
[INFO]
maven-help-plugin
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${project.none}
[INFO]
null object or invalid expression
...

3.Examples

Use this maven-help plugin to display a list of available goals and parameters of a plugin. For example,

List all of the available goals of maven-eclipse plugin.

$ mvn help:describe -Dplugin=eclipse
Output
$ mvn help:describe -Dplugin=eclipse

Name: Maven Eclipse Plugin
Description: The Eclipse Plugin is used to generate Eclipse IDE files
  (.project, .classpath and the .settings folder) from a POM.
Group Id: org.apache.maven.plugins
Artifact Id: maven-eclipse-plugin
Version: 2.9
Goal Prefix: eclipse

This plugin has 13 goals:

//...
eclipse:myeclipse
  Description: Generates MyEclipse configuration files

eclipse:myeclipse-clean
  Description: Deletes configuration files used by MyEclipse

eclipse:rad
  Description: Generates the rad-6 configuration files.

eclipse:rad-clean
  Description: Deletes the config files used by Rad-6. the files .j2ee and
    the file .websettings

eclipse:remove-cache
  Description: Removes the not-available marker files from the repository.

//...

Display the detail of maven-eclipse, “eclipse” goal and all its parameters.

$ mvn help:describe -Dplugin=eclipse -Dmojo=eclipse -Dfull=true
Output
$ mvn help:describe -Dplugin=eclipse -Dmojo=eclipse -Dfull=true

//...
eclipse:eclipse
  Description: Generates the following eclipse configuration files:
    - .project and .classpath files
    - .setting/org.eclipse.jdt.core.prefs with project specific compiler
//...

  Available parameters:

    addGroupIdToProjectName (Default: false)
      Expression: ${eclipse.addGroupIdToProjectName}
      If set to true, the groupId of the artifact is appended to the name of
      the generated Eclipse project. See projectNameTemplate for other options.

    additionalBuildcommands
      List of eclipse build commands to be added to the default ones. Old
      style:
     

    //...

Few help:describe examples to describe maven-archetype plugin :

$ mvn help:describe -Dplugin=archetype

$ mvn help:describe -Dplugin=archetype -Dmojo=generate -Ddetail

5.Conclusion

In this quick guide, we went over the clean plugin and gave instructions on using and customizing it. Also we have seen the different plugin goals and their usage.
Reference : http://maven.apache.org/plugins/maven-help-plugin/

Comments