简体   繁体   English

使用Aether从pom.xml下载依赖项

[英]Downloading dependencies from pom.xml with Aether

I need to download all dependencies from a given pom.xml in my java programm. 我需要从Java程序中的给定pom.xml下载所有依赖项。 In Aether examples I can see only examples of resolving and downloading artifacts by maven coordinates, so I have to parse pom.xml, resolve constants in <version> tag, handle exclusions and etc. by myself. 在Aether示例中,我只能看到通过maven坐标解析和下载工件的示例,因此我必须自己解析pom.xml,解析<version>标记中的常量,自行处理排除等。 Can Aether (or other tool) do it for me? Aether(或其他工具)可以帮我吗?

Try using ShrinkWrap instead, which uses Aether itself underneath. 尝试改用ShrinkWrap ,它在下面使用Aether本身。 Example: 例:

Maven.resolver()
    .loadPomFromFile("/path/to/pom.xml")
    .importRuntimeDependencies()
    .resolve()
    .withTransitivity()
    .asFile();

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

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