'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



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1