Tuesday 9 July 2019

Maven: print tree representation of maven dependencies


'mvn dependency:tree' command prints all the dependencies in tree format.

For example, consider below pom file.

pom.xml
<project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.selflearningjava</groupId>
   <artifactId>rootWebPom</artifactId>
   <packaging>pom</packaging>
   <version>1</version>
   
   <name>Root pom for all the web application</name>

 <dependencies> 
 
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>${junit.version}</version>
   <scope>test</scope>
  </dependency>
  
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>${hibernate.version}</version>
  </dependency>

  <dependency>
   <groupId>org.glassfish.jersey.core</groupId>
   <artifactId>jersey-server</artifactId>
   <version>${jersey.version}</version>
  </dependency>

 </dependencies>
   
   <properties>
  <junit.version>4.12</junit.version>
  <hibernate.version>5.2.16.Final</hibernate.version>
  <jersey.version>2.27</jersey.version>
   </properties>
   
</project>


Go the the directory, where the pom file is located and execute the command 'mvn dependency:tree', you will see below kind of output.

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.selflearningjava:rootWebPom >-------------------
[INFO] Building Root pom for all the web application 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ rootWebPom ---
[INFO] org.selflearningjava:rootWebPom:pom:1
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.hibernate:hibernate-core:jar:5.2.16.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  +- org.javassist:javassist:jar:3.22.0-GA:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.1.Final:compile
[INFO] |  +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.3.0:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] \- org.glassfish.jersey.core:jersey-server:jar:2.27:compile
[INFO]    +- org.glassfish.jersey.core:jersey-common:jar:2.27:compile
[INFO]    |  \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO]    +- org.glassfish.jersey.core:jersey-client:jar:2.27:compile
[INFO]    +- javax.ws.rs:javax.ws.rs-api:jar:2.1:compile
[INFO]    +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.27:compile
[INFO]    +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO]    +- org.glassfish.hk2.external:javax.inject:jar:2.5.0-b42:compile
[INFO]    \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.826 s
[INFO] Finished at: 2018-04-20T14:18:00+05:30
[INFO] ------------------------------------------------------------------------




Previous                                                    Next                                                    Home

No comments:

Post a Comment