Blog




To check for plugin or dependency updates of a Maven project the Versions Maven Plugin has two interesting mojos:

mvn versions:display-plugin-updates
mvn versions:display-dependency-updates

Unfortunately the command line is a bit long. Cumbersome to type, not that easy to remember. Using the Alias Maven Plugin the command line can be shortened to:

pu
du

In addition to that checking a project for declaring all dependencies (that is not relying on transitive dependencies) or not declaring unused dependencies is a common task to keep the project dependencies clean. The Maven Dependency Plugin provides the analyze mojo for this:

mvn dependency:analyze

In short this would be

a

The configuration to make this work looks like this:

<group name="project-analysis">
  <comment>
    Aliases to analyze project information.
  </comment>
  <alias>
    <name>a</name>
    <command>mvn dependency:analyze</command>
    <comment>
      Analyzes the dependencies of this project and determines which are: used and declared;
      used and undeclared; unused and declared. This goal is intended to be used standalone,
      thus it always executes the test-compile phase - use the dependency:analyze-only goal
      instead when participating in the build lifecycle.
 
      <p>
        For more information please refer to the
        <a href="http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html">analyze mojo</a>.
      </p>
    </comment>
  </alias>
  <alias>
    <name>pu</name>
    <command>mvn versions:display-plugin-updates</command>
    <comment>
      Displays all plugins that have newer versions available.
      <p>
        For more information please refer to the
        <a href="http://mojo.codehaus.org/versions-maven-plugin/display-plugin-updates-mojo.html">display-plugin-updates mojo</a>.
      </p>
    </comment>
  </alias>
  <alias>
    <name>du</name>
    <command>mvn versions:display-dependency-updates</command>
    <comment>
      Displays all dependencies that have newer versions available.
      <p>
        For more information please refer to the
        <a href="http://mojo.codehaus.org/versions-maven-plugin/display-dependency-updates-mojo.html">display-dependency-updates mojo</a>.
      </p>
    </comment>
  </alias>
</group>

The comment elements are optional, but help teams to share information about the aliases.

And if you can’t remember all the shortcuts? Type h!

--- project-analysis
a   = mvn dependency:analyze [args]
pu  = mvn versions:display-plugin-updates [args]
du  = mvn versions:display-dependency-updates [args]

For more information please refer to the Alias Maven Plugin and (for an example configuration) config-smartics-alias.


Link

Link

Posts