views:

42

answers:

2

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

...
A: 

You can use the Maven Dependency Plugin to analyze the dependencies of you POM.

Daniel Murygin
Thanks!! It helps a lot...Almost that...mvn dependency:list -DoutputAbsoluteArtifactFilename=true -DoutputFile=C:\dependencies.txt... But this list a local asolute path.There isn't a option to list from remote.
CelinHC
Use SCP or FTP to transfer the file after the maven call is finished (and don't forget to rate the answer).
Daniel Murygin
A: 

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:

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").

Pascal Thivent
Thanks a lot!!!I did this on windows to get just the urls...findstr "Downloading" raw.txt > urls.txt
CelinHC
@CelinHC: You're welcome. I just updated my answer and posted a link to illustrate a potential problem when using multiple repositories (and how to filter the output).
Pascal Thivent