How to display a list of available goals?

Since Maven is an open system of plugins, the best answer is probably "Google" ;-). If you mean all build lifecycle phases, they are static, and can be found at http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html and at other places.

Then, for a given plugin, the help plugin can be used to get the possible goals and all their parameters:

mvn help:describe -DgroupId=org.apache.maven.plugins \
                  -DartifactId=maven-war-plugin \
                  -Ddetail=true

But this doesn't really answer your question, especially the "for a given prefix" part. For this, the best solution might be to use **auto completion with BASH (**not sure it will be exhaustive though). See for example the Guide to Maven 2.x auto completion using BASH. To get bash completion working under Windows, you'll need CYGWIN. See Maven Tab Auto Completion in Bash for detailed setup steps (and a "better" working auto completion script).


A shorter way

As an alternative, you can also use the -Dplugin parameter to display the list of available goals.

mvn help:describe -Dplugin=org.apache.maven.plugins:maven-war-plugin\
                  -Ddetail=true

See Maven help plugin.


More and more Maven plugins propose an help goal as alternative to the verbose mvn help:describe command.

You can read from the Maven doc:

Recent Maven plugins have generally an help goal to have in the command line the description of the plugin, with their parameters and types

That is really more natural and pleasant to use.

It works of course for Maven core plugins.
Some examples :

  • to list goals of the dependency plugin :

    mvn dependency:help

  • to have detail about the javadoc goal of the javadoc plugin :

    mvn javadoc:help -Ddetail -Dgoal=javadoc

And it works also for third party plugins.

For example, to list goals of the spring-boot-maven-plugin :

mvn org.springframework.boot:spring-boot:help

[INFO] Spring Boot Maven Plugin 2.0.0.RELEASE Spring Boot Maven Plugin

This plugin has 6 goals:

spring-boot:build-info

Generate a build-info.properties file based the content of the current MavenProject.

spring-boot:help

Display help information on spring-boot-maven-plugin. Call mvn spring-boot:help -Ddetail=true -Dgoal= to display
parameter details.

spring-boot:repackage

Repackages existing JAR and WAR archives so that they can be executed from the command line using java -jar. With layout=NONE can also be used simply to package a JAR with nested dependencies (and no main class, so not executable).

.....

Or to get detailed information about the build goal of the dockerfile-maven-plugin :

mvn com.spotify:dockerfile-maven-plugin:help -Ddetail -Dgoal=build

[INFO] Dockerfile Maven Plugin 1.3.6

Adds support for building Dockerfiles in Maven

dockerfile:build

Available parameters:

- archive

  The archive configuration to use for the Docker info JAR. This can be used
  to embed additional information in the JAR.

....

You could note that the syntax to get a detailed output of the help and to focus on a specific goal (-Ddetail -Dgoal=myGoal) is exactly the same as this used for the core maven plugins.

Of course some esoteric plugins may not provide the help goal but in most of well designed plugins this is present.