List all of the possible goals in Maven 2?
I'm new to Maven, coming from the Ant world.
Is it possible to list all of the possible goals (including, say, all the plugins) that you can run?
I can see that there used to be a -g
flag in Maven 1, but this isn't available in version 2.
Solution 1:
The goal you indicate in the command line is linked to the lifecycle of Maven. For example, the build
lifecycle (you also have the clean
and site
lifecycles which are different) is composed of the following phases:
-
validate
: validate the project is correct and all necessary information is available. -
compile
: compile the source code of the project. -
test
: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed. -
package
: take the compiled code and package it in its distributable format, such as a JAR. -
integration-test
: process and deploy the package if necessary into an environment where integration tests can be run. -
verify
: run any checks to verify the package is valid and meets quality criteria -
install
: install the package into the local repository, for use as a dependency in other projects locally. -
deploy
: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
You can find the list of "core" plugins here, but there are plenty of others plugins, such as the codehaus ones, here.
Solution 2:
Is it possible to list all of the possible goals (including, say, all the plugins) that it is possible to run?
Maven doesn't have anything built-in for that, although the list of phases is finite (the list of plugin goals isn't since the list of plugins isn't).
But you can make things easier and leverage the power of bash completion (using cygwin if you're under Windows) as described in the Guide to Maven 2.x auto completion using BASH (but before to choose the script from this guide, read further).
To get things working, first follow this guide to setup bash completion on your computer. Then, it's time to get a script for Maven2 and:
- While you could use the one from the mini guide
- While you use an improved version attached to MNG-3928
- While you could use a random scripts found around the net (see the resources if you're curious)
- I personally use the Bash Completion script from Ludovic Claude's PPA (which is bundled into the packaged version of
maven
in Ubuntu) that you can download from the HEAD. It's simply the best one.
Below, here is what I get just to illustrate the result:
$ mvn [tab][tab] Display all 377 possibilities? (y or n) ant:ant ant:clean ant:help antrun:help antrun:run archetype:crawl archetype:create archetype:create-from-project archetype:generate archetype:help assembly:assembly assembly:directory assembly:directory-single assembly:help assembly:single ...
Of course, I never browse the 377 possibilities, I use completion. But this gives you an idea about the size of "a" list :)
Resources
- Guide to Maven 2.x auto completion using BASH
- Fixing Maven 2.x BASH auto completion on CYGWIN
- Maven bash completion
- maven2 bash completion complete
- Maven Tab Auto Completion in Bash
- Advanced Bash completion script for Maven 2
Solution 3:
If you use IntelliJ IDEA you can browse all maven goals/tasks (including plugins) in Maven Projects
tab:
Solution 4:
Strange nobody listed an actual command to do it:
mvn help:describe -e -Dplugin=site
If you want to list all goals of the site
plugin. Output:
Name: Apache Maven Site Plugin Description: The Maven Site Plugin is a plugin that generates a site for the current project. Group Id: org.apache.maven.plugins Artifact Id: maven-site-plugin Version: 3.7.1 Goal Prefix: site
This plugin has 9 goals:
site:attach-descriptor Description: Adds the site descriptor (site.xml) to the list of files to be installed/deployed. For Maven-2.x this is enabled by default only when the project has pom packaging since it will be used by modules inheriting, but this can be enabled for other projects packaging if needed. This default execution has been removed from the built-in lifecycle of Maven 3.x for pom-projects. Users that actually use those projects to provide a common site descriptor for sub modules will need to explicitly define this goal execution to restore the intended behavior.
site:deploy Description: Deploys the generated site using wagon supported protocols to the site URL specified in the section of the POM. For scp protocol, the website files are packaged by wagon into zip archive, then the archive is transfered to the remote host, next it is un-archived which is much faster than making a file by file copy.
site:effective-site Description: Displays the effective site descriptor as an XML for this build, after inheritance and interpolation of site.xml, for the first locale.
site:help Description: Display help information on maven-site-plugin. Call mvn site:help -Ddetail=true -Dgoal= to display parameter details.
site:jar Description: Bundles the site output into a JAR so that it can be deployed to a repository.
site:run Description: Starts the site up, rendering documents as requested for faster editing. It uses Jetty as the web server.
site:site Description: Generates the site for a single project. Note that links between module sites in a multi module build will not work, since local build directory structure doesn't match deployed site.
site:stage Description: Deploys the generated site to a local staging or mock directory based on the site URL specified in the section of the POM. It can be used to test that links between module sites in a multi-module build work.
This goal requires the site to already have been generated using the site goal, such as by calling mvn site.
site:stage-deploy Description: Deploys the generated site to a staging or mock URL to the site URL specified in the section of the POM, using wagon supported protocols
For more information, run 'mvn help:describe [...] -Ddetail'
More details on https://mkyong.com/maven/how-to-display-maven-plugin-goals-and-parameters/