Skip to content
🇫🇷 Lire en français

Maven goals cheat sheet

← Posts 1 min read

🔍 Search Maven Goal


Understanding goal chains

When you run a Maven command like mvn package, Maven doesn’t only execute that goal, it runs every phase leading up to it, in sequence.

CommandPhases
mvn compilevalidate -> compile
mvn testvalidate -> compile -> test
mvn packagevalidate -> compile -> test -> package
mvn installvalidate -> compile -> test -> package -> install
mvn deployvalidate -> compile -> test -> package -> install -> deploy
mvn verifyvalidate -> compile -> test -> verify

Each phase is bound by default to one or more plugin goals.
Example:
compile -> compiler:compile
package -> jar:jar or war:war (depending on packaging type).


Diagnostic & helper commands

CommandDescriptionExample Output
mvn help:effective-pomDisplays the full merged POM (parent + profiles + defaults).Useful to debug inheritance issues
mvn help:describe -Dcmd=compile

Shows which plugin and goal are bound to compile.

Reveals compiler:compile mapping

mvn help:describe -Dplugin=compilerLists all available goals for a given plugin.

compiler:compile, compiler:testCompile

mvn dependency:treeDisplays dependency hierarchy and conflicts.A:1.0 -> B:2.0 -> C:3.1
mvn -X

Runs in debug mode, showing plugin binding and lifecycle execution.

Great for build troubleshooting

Custom goal bindings

You can attach plugin goals to different phases in your pom.xml:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

References