JF Meier JF Meier - 1 month ago 16
Java Question

Maven dependency:list includeParents

I am a little confused about the option "includeParents" of the dependency:list goal of the Maven dependency plugin

http://maven.apache.org/plugins/maven-dependency-plugin/list-mojo.html

It seems to me that the parent of the pom itself are not included into the list (I mean the parent of the project pom to which we apply the goal). Is this really the case or did I make some mistake? If so, is there a way to get the parent pom of the project as well?

EXAMPLE:

I used the pom of org.sonatype.plugins:sisu-maven-plugin:1.4 from MavenCentral. It contains a reference to the parent

<parent>
<groupId>org.sonatype.plugins</groupId>
<artifactId>plugins-parent</artifactId>
<version>9</version>
</parent>


But the result of
mvn dependency:list -DincludeParents=true
is:

javax.inject:javax.inject:jar:1:compile
org.apache.maven:maven-artifact-manager:jar:2.0.8:compile
javax.annotation:jsr250-api:jar:1.0:compile
com.google.code.findbugs:jsr305:jar:1.3.9:compile
org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.2.0:compile
org.apache.maven:maven-model:jar:2.0.8:compile
org.apache.maven:maven-plugin-registry:jar:2.0.8:compile
org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.6:compile
org.apache.maven:maven-project:jar:2.0.8:compile
org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-44:compile
org.apache.maven:maven-settings:jar:2.0.8:compile
aspectj:aspectjrt:jar:1.5.3:compile
junit:junit:jar:4.8.2:test
org.apache.maven:maven-repository-metadata:jar:2.0.8:compile
org.sonatype.sisu:sisu-inject-bean:jar:2.5.3:compile
com.google.guava:guava:jar:11.0.2:compile
org.apache.maven.shared:maven-common-artifact-filters:jar:1.4:compile
org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile
org.apache.maven:maven-artifact:jar:2.0.8:compile
org.codehaus.plexus:plexus-utils:jar:3.0.15:compile
javax.enterprise:cdi-api:jar:1.0:compile
org.apache.maven:maven-plugin-api:jar:2.0:compile
org.apache.maven:maven-profile:jar:2.0.8:compile
org.codehaus.plexus:plexus-classworlds:jar:1.2-alpha-10:compile

Answer

The parameter includeParents was introduced in version 2.8 of the Maven Dependency Plugin:

Include parent poms in the dependency resolution list. [...]

  • Since: 2.8

However, the specific Maven project on which you're launching this command declares version 2.2 of the plugin. Here's how I tracked this: sisu-maven-plugin-1.4 has as parent org.sonatype.plugins:plugins-parent:9, which itself has as parent org.sonatype.forge:forge-parent:12, which finally declares version 2.2 of the plugin... Maven will prefer to use that version since it is directly declared in the POM of the project.

Note that you can spot this in the logs as well. When running the command on this project, the logs are:

[INFO] Building Sisu Maven Plugin 1.4
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.2:list (default-cli) @ sisu-maven-plugin ---
[INFO]

showing that version 2.2 is the one used.

As such, you just need to force the usage of a version greater than 2.8 for the includeParents parameter to take effect, for example using 2.10 which is the current latest:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:list -DincludeParents