Show Maven build plan

This post is also available in: fr

I often find myself in front of a POM scratching my head while trying to find what Maven will execute during my build. Since Maven 3 it is possible to calculate execution plan by simulating the build. Strangely there is not easy way do display it. Here is buildplan-maven-plugin.

Configuration

To easily use the plugin, add its groupId in your Maven configuration (ie settings.xml):

<pluginGroups>
    <pluginGroup>fr.jcgay.maven.plugins</pluginGroup>
</pluginGroups>

Show build plan

It is possible to list goals executed during a build. The simulated phase is deploy.

> mvn buildplan:list

[INFO] --- buildplan-maven-plugin:1.0:list (default-cli) @ maven-notifier ---
[INFO] ----------------------------------------------------------------------------------------------
[INFO] PLUGIN                    | PHASE                  | ID                    | GOAL
[INFO] ----------------------------------------------------------------------------------------------
[INFO] maven-resources-plugin    | process-resources      | default-resources     | resources
[INFO] maven-compiler-plugin     | compile                | default-compile       | compile
[INFO] plexus-component-metadata | process-classes        | default               | generate-metadata
[INFO] maven-resources-plugin    | process-test-resources | default-testResources | testResources
[INFO] maven-compiler-plugin     | test-compile           | default-testCompile   | testCompile
[INFO] maven-surefire-plugin     | test                   | default-test          | test
[INFO] maven-dependency-plugin   | process-sources        | get-logging-binding   | copy
[INFO] maven-jar-plugin          | package                | default-jar           | jar
[INFO] maven-shade-plugin        | package                | default               | shade
[INFO] maven-assembly-plugin     |                        | make-assembly         | single
[INFO] maven-source-plugin       | package                | default               | jar-no-fork
[INFO] maven-install-plugin      | install                | default-install       | install
[INFO] maven-deploy-plugin       | deploy                 | default-deploy        | deploy

Show phases

A view per phase is available. This way, we can quickly see which plugins are used during a phase.

> mvn buildplan:list-phase

[INFO] --- buildplan-maven-plugin:1.0:list-phase (default-cli) @ maven-notifier ---
[INFO] install --------------------------------------------------------------------
[INFO]     + maven-install-plugin      | default-install       | install
[INFO] process-resources ----------------------------------------------------------
[INFO]     + maven-resources-plugin    | default-resources     | resources
[INFO] process-sources ------------------------------------------------------------
[INFO]     + maven-dependency-plugin   | get-logging-binding   | copy
[INFO] test -----------------------------------------------------------------------
[INFO]     + maven-surefire-plugin     | default-test          | test
[INFO] test-compile ---------------------------------------------------------------
[INFO]     + maven-compiler-plugin     | default-testCompile   | testCompile
[INFO] process-test-resources -----------------------------------------------------
[INFO]     + maven-resources-plugin    | default-testResources | testResources
[INFO] process-classes ------------------------------------------------------------
[INFO]     + plexus-component-metadata | default               | generate-metadata
[INFO] compile --------------------------------------------------------------------
[INFO]     + maven-compiler-plugin     | default-compile       | compile
[INFO] default-phase --------------------------------------------------------------
[INFO]     + maven-assembly-plugin     | make-assembly         | single
[INFO] package --------------------------------------------------------------------
[INFO]     + maven-jar-plugin          | default-jar           | jar
[INFO]     + maven-shade-plugin        | default               | shade
[INFO]     + maven-source-plugin       | default               | jar-no-fork
[INFO] deploy ---------------------------------------------------------------------
[INFO]     + maven-deploy-plugin       | default-deploy        | deploy

Filtering phase using parameter buildplan.phase:

mvn buildplan:list-phase -Dbuildplan.phase=test

Show plugins

In this cas, executions are grouped by plugin.

> mvn buildplan:list-plugin

[INFO] --- buildplan-maven-plugin:1.0:list-plugin (default-cli) @ maven-notifier ---
[INFO] maven-deploy-plugin -----------------------------------------------------
[INFO]     + deploy                 | default-deploy        | deploy
[INFO] maven-source-plugin -----------------------------------------------------
[INFO]     + package                | default               | jar-no-fork
[INFO] maven-assembly-plugin ---------------------------------------------------
[INFO]     +                        | make-assembly         | single
[INFO] maven-dependency-plugin -------------------------------------------------
[INFO]     + process-sources        | get-logging-binding   | copy
[INFO] maven-resources-plugin --------------------------------------------------
[INFO]     + process-resources      | default-resources     | resources
[INFO]     + process-test-resources | default-testResources | testResources
[INFO] maven-jar-plugin --------------------------------------------------------
[INFO]     + package                | default-jar           | jar
[INFO] maven-shade-plugin ------------------------------------------------------
[INFO]     + package                | default               | shade
[INFO] maven-surefire-plugin ---------------------------------------------------
[INFO]     + test                   | default-test          | test
[INFO] maven-compiler-plugin ---------------------------------------------------
[INFO]     + compile                | default-compile       | compile
[INFO]     + test-compile           | default-testCompile   | testCompile
[INFO] maven-install-plugin ----------------------------------------------------
[INFO]     + install                | default-install       | install
[INFO] plexus-component-metadata -----------------------------------------------
[INFO]     + process-classes        | default               | generate-metadata

The parameter buildplan.plugin allow specific plugin filtering:

mvn buildplan:list-plugin -Dbuildplan.plugin=maven-compiler-plugin

This is it, your build plan will have no secret for you anymore !

comments powered by Disqus