How do I list the goals and goal parameters of a maven plugin?
Author: Deron Eriksson
Description: This tutorial describes how to list the goals of a maven plugin and the parameters of the goals.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


Page: < 1 2

(Continued from page 1)

Now, let's try getting a full description of the "help" plugin. I'll run the same external tool configuration. This time, I'll ask for a description of the mavenSW "help" plugin.

Specifying help plugin

The resulting console output is shown below.

Console output from 'mvn help:describe -Dplugin=help -Dfull=true'

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [help:describe] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [help:describe]
[INFO] Plugin: 'org.apache.maven.plugins:maven-help-plugin:2.0.2'
-----------------------------------------------
Group Id:  org.apache.maven.plugins
Artifact Id: maven-help-plugin
Version:     2.0.2
Goal Prefix: help
Description:

The Maven Help plugin provides goals aimed at helping to make sense out of
    the build environment. It includes the ability to view the effective
    POM and settings files, after inheritance and active profiles
    have been applied, as well as a describe a particular plugin goal to give usage information.

Mojos:

===============================================
Goal: 'active-profiles'
===============================================
Description:
Lists the profiles which are currently active for this build.

Implementation: org.apache.maven.plugins.help.ActiveProfilesMojo
Language: java

Parameters:
-----------------------------------------------

[0] Name: output
Type: java.io.File
Required: false
Directly editable: true
Description:
This is an optional parameter for a file destination for the output
of this mojo...the listing of active profiles per project.

-----------------------------------------------

[1] Name: projects
Type: java.util.List
Required: true
Directly editable: false
Description:
This is the list of projects currently slated to be built by Maven.

-----------------------------------------------

This mojo doesn't have any component requirements.
===============================================


===============================================
Goal: 'describe'
===============================================
Description:
Describes the attributes of a plugin and/or plugin mojo.

Implementation: org.apache.maven.plugins.help.DescribeMojo
Language: java

Parameters:
-----------------------------------------------

[0] Name: artifactId
Type: java.lang.String
Required: false
Directly editable: true
Description:
The plugin artifactId to describe.
(Used with groupId specification).

-----------------------------------------------

[1] Name: full
Type: boolean
Required: false
Directly editable: true
Description:
This flag specifies that full (verbose) information should be
given. Use true/false.

-----------------------------------------------

[2] Name: groupId
Type: java.lang.String
Required: false
Directly editable: true
Description:
The plugin groupId to describe.
(Used with artifactId specification).

-----------------------------------------------

[3] Name: localRepository
Type: org.apache.maven.artifact.repository.ArtifactRepository
Required: true
Directly editable: false
Description:
The local repository ArtifactRepository instance. This is used
for plugin manager API calls.

-----------------------------------------------

[4] Name: medium
Type: boolean
Required: false
Directly editable: true
Description:
This flag specifies that a short list of mojo information should be
given. Use true/false.

-----------------------------------------------

[5] Name: mojo
Type: java.lang.String
Required: false
Directly editable: true
Description:
The goal name of a mojo to describe within the specified plugin.
If this parameter is specified, only the corresponding mojo will
be described, rather than the whole plugin.

-----------------------------------------------

[6] Name: output
Type: java.io.File
Required: false
Directly editable: true
Description:
If specified, this parameter will cause the plugin/mojo descriptions
to be written to the path specified, instead of writing to the console.

-----------------------------------------------

[7] Name: plugin (Alias: prefix)
Type: java.lang.String
Required: false
Directly editable: true
Description:
The plugin/mojo to describe. This must be specified in one of three ways:


1. plugin-prefix
2. groupId:artifactId
3. groupId:artifactId:version

-----------------------------------------------

[8] Name: project
Type: org.apache.maven.project.MavenProject
Required: false
Directly editable: false
Description:
The current project, if there is one. This is listed as optional, since
the help plugin should be able to function on its own. If this
parameter is empty at execution time, this mojo will instead use the
super-project.

-----------------------------------------------

[9] Name: session
Type: org.apache.maven.execution.MavenSession
Required: true
Directly editable: false
Description:
The current build session instance. This is used for
plugin manager API calls.

-----------------------------------------------

[10] Name: settings
Type: org.apache.maven.settings.Settings
Required: true
Directly editable: false
Description:
The current user system settings for use in Maven. This is used for
plugin manager API calls.

-----------------------------------------------

[11] Name: version
Type: java.lang.String
Required: false
Directly editable: true
Description:
The plugin version to describe.


(Used with groupId/artifactId specification).

-----------------------------------------------

Component Requirements:

-----------------------------------------------
[0] Role: org.apache.maven.project.MavenProjectBuilder

-----------------------------------------------
[1] Role: org.apache.maven.plugin.PluginManager

-----------------------------------------------
===============================================


===============================================
Goal: 'effective-pom'
===============================================
Description:
Display the effective POM for this build, with the active profiles factored in.

Implementation: org.apache.maven.plugins.help.EffectivePomMojo
Language: java

Parameters:
-----------------------------------------------

[0] Name: output
Type: java.io.File
Required: false
Directly editable: true
Description:
If specified, write the output to this path.

-----------------------------------------------

[1] Name: project
Type: org.apache.maven.project.MavenProject
Required: true
Directly editable: false
Description:
Unknown

-----------------------------------------------

[2] Name: projects
Type: java.util.List
Required: true
Directly editable: false
Description:
The projects in the current build. The effective-POM for
each of these projects will written.

-----------------------------------------------

This mojo doesn't have any component requirements.
===============================================


===============================================
Goal: 'effective-settings'
===============================================
Description:
Print out the calculated settings for this project, given any profile enhancement and
the inheritance of the global settings into the user-level settings.

Implementation: org.apache.maven.plugins.help.EffectiveSettingsMojo
Language: java

Parameters:
-----------------------------------------------

[0] Name: output
Type: java.lang.String
Required: false
Directly editable: true
Description:
If specified write the effective settings file out to this path.

-----------------------------------------------

[1] Name: settings
Type: org.apache.maven.settings.Settings
Required: true
Directly editable: false
Description:
The system settings for Maven. This is the instance resulting from
merging global- and user-level settings files.

-----------------------------------------------

This mojo doesn't have any component requirements.
===============================================


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sat Feb 09 19:12:16 PST 2008
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------

As we have seen, the full description listing made available by the "help:describe" goal is a great way to get very detailed information about the goals and the goal parameters that are made available by a particular plugin.

Page: < 1 2