I'm looking for something like this:
我正在寻找这样的东西:
List<URL> urls = listURLFromPOM("c:\pom.xml");
..
http://repo1.maven.org/maven2/org/apache/ibatis/ibatis-core/3.0/ibatis-core-3.0.jar
http://repo1.maven.org/maven2/org/apache/camel/camel-activemq/1.1.0/camel-activemq-1.1.0.jar
...
2 个解决方案
#1
1
You can use the Maven Dependency Plugin to analyze the dependencies of you POM.
您可以使用Maven Dependency Plugin来分析POM的依赖关系。
mvn dependency:list -DoutputAbsoluteArtifactFilename=true -DoutputFile=dependencies.txt
#2
2
A dependency is not aware of its "source repository" which might not be unique so you won't be able to get the "source URL" of a dependency without actually resolving it. One way to do that (without writing code using Maven internal APIs) would be to use dependency:purge-local-repository
. From the Maven Dependency Plugin documentation:
依赖项不知道它的“源存储库”可能不是唯一的,因此您无法在不实际解析它的情况下获取依赖项的“源URL”。一种方法(不使用Maven内部API编写代码)将使用依赖:purge-local-repository。从Maven Dependency Plugin文档:
dependency:purge-local-repository
tells Maven to clear all dependency-artifact files out of the local repository, and optionally re-resolve them.- dependency:purge-local-repository告诉Maven清除本地存储库中的所有依赖项工件文件,并可选择重新解析它们。
Run that command and redirect the output to a file for post-processing:
运行该命令并将输出重定向到文件以进行后处理:
mvn dependency:purge-local-repository > raw.txt
As I just mentioned, if you are using several repositories, you might need to do some post processing to separate the "successful" download from "failed" attempts. Here is a sample regex on Rubular that might be helpful to implement such a post-processing (I provided some content illustrating the "problem").
正如我刚才提到的,如果您使用多个存储库,则可能需要进行一些后处理以将“成功”下载与“失败”尝试分开。这是一个关于Rubular的示例正则表达式,可能有助于实现这样的后处理(我提供了一些说明“问题”的内容)。
#1
1
You can use the Maven Dependency Plugin to analyze the dependencies of you POM.
您可以使用Maven Dependency Plugin来分析POM的依赖关系。
mvn dependency:list -DoutputAbsoluteArtifactFilename=true -DoutputFile=dependencies.txt
#2
2
A dependency is not aware of its "source repository" which might not be unique so you won't be able to get the "source URL" of a dependency without actually resolving it. One way to do that (without writing code using Maven internal APIs) would be to use dependency:purge-local-repository
. From the Maven Dependency Plugin documentation:
依赖项不知道它的“源存储库”可能不是唯一的,因此您无法在不实际解析它的情况下获取依赖项的“源URL”。一种方法(不使用Maven内部API编写代码)将使用依赖:purge-local-repository。从Maven Dependency Plugin文档:
dependency:purge-local-repository
tells Maven to clear all dependency-artifact files out of the local repository, and optionally re-resolve them.- dependency:purge-local-repository告诉Maven清除本地存储库中的所有依赖项工件文件,并可选择重新解析它们。
Run that command and redirect the output to a file for post-processing:
运行该命令并将输出重定向到文件以进行后处理:
mvn dependency:purge-local-repository > raw.txt
As I just mentioned, if you are using several repositories, you might need to do some post processing to separate the "successful" download from "failed" attempts. Here is a sample regex on Rubular that might be helpful to implement such a post-processing (I provided some content illustrating the "problem").
正如我刚才提到的,如果您使用多个存储库,则可能需要进行一些后处理以将“成功”下载与“失败”尝试分开。这是一个关于Rubular的示例正则表达式,可能有助于实现这样的后处理(我提供了一些说明“问题”的内容)。