简体   繁体   中英

Maven- Getting dependencies from pom file

I need to get all the dependencies of a project, so to my knowledge, everything under

<dependencies> ... <dependencies> and <exclusions> ... </exclusions>

Is it possible to get all of these from the https://repo1.maven.org/maven2/ by going to a specific project's pom file and parsing it or do I have to get the effective pom of that project and only then will I have all the dependencies?

EDIT 1: How can I generate the effective pom for lets say, 100 packages? Currently, I'm using this command :

mvn -DgroupId=junit -DartifactId=junit -Dversion=4.13.1 dependency:get # get the pom/jar
cd .m2/repository/junit/junit/4.13.1
cp junit-4.13.1.pom pom.xml
mvn help:effective-pom -Doutput=effective-pom.xml

How could I write something that does this for 100 different inputs lets say, so I dont have to manually do this 100 times

You can list all the dependencies quite easily by taking advantage of the maven-dependency-plugin . You just have to open a shell and execute:

mvn -f my-project/pom.xml dependency:list

or

mvn -f my-project/pom.xml dependency:tree

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM