简体   繁体   English

Maven-从 pom 文件中获取依赖项

[英]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?是否可以通过转到特定项目的 pom 文件并解析它来从https://repo1.maven.org/maven2/获取所有这些,或者我必须获得该项目的有效 pom,然后我才会有所有的依赖?

EDIT 1: How can I generate the effective pom for lets say, 100 packages?编辑 1:我怎样才能为 100 个包生成有效的 pom? 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我怎么能写出针对 100 种不同输入的东西可以说,所以我不必手动执行 100 次

You can list all the dependencies quite easily by taking advantage of the maven-dependency-plugin .您可以利用maven-dependency-plugin轻松列出所有依赖项。 You just have to open a shell and execute:你只需要打开一个shell并执行:

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

or或者

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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