Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: Show dependency tree for specific artifact without adding it to pom

For showing the dependency tree of an existing project (with a pom.xml), there's mvn dependency:tree.

But sometimes, I want to have a look at the dependencies without having to create a pom.xml and adding the dependency there.

So, is there a command for showing the dependency tree of a specific groupId:artifactId:version without having an existing project?

(I'd also be happy if there is another tool that has something for this, maybe Gradle.)

like image 240
robinst Avatar asked Jul 31 '14 02:07

robinst


1 Answers

You definitely need a pom for resolving dependencies, that's where dependency information is stored. But you can workaround having a project:

  1. Get the pom of your artifact:

    mvn dependency:get \
    -Dartifact=groupId:artifactId:version:pom \
    -DremoteRepositories=default::http://repo.url... \
    -Dtransitive=false -Ddest=pom.xml
    
  2. Run mvn dependency:tree.

This worked for me. Or using dependency:copy:

  1. Run dependency:copy:

    mvn dependency:copy \
    -Dartifact=groupId:artifactId:version:pom \
    -DoutputDirectory=.
    
  2. mv artifactId-version.pom pom.xml.

  3. Run mvn dependency:tree.

like image 88
Ale Sequeira Avatar answered Oct 22 '22 22:10

Ale Sequeira