views:

43

answers:

3

Given a local Maven repository, can one determine the remote repository that is the source of a particular dependency? How?

+1  A: 

Maven don't store such information. However if you purge your local repository and run your project build you can see the actual repository url when artifact is downloaded during Maven build.

However if you are using Maven repository manager like Nexus you can search artifact by its id, version, etc and then see artifact source in the search results.

Eugene Kuleshov
+1  A: 

You could delete the dependency from your local repository and then see where it pulls from on your next build.

digitaljoel
What Maven command can you use to just download dependencies, but otherwise not build the targets?
Derek Mahar
+2  A: 

As mentioned by @Eugene, the origin of a dependency isn't stored anywhere so the only way to find this after the fact (if you're not behind a corporate repository) would be to purge the dependencies of a given project and to re-resolve them. The following goal of the Maven Dependency Plugin can do that:

mvn dependency:purge-local-repository -DreResolve=true

Note that reResolve is set to true by default, I just mentioned it for documentation purposes.

Pascal Thivent
Does this command download the dependencies only?
Derek Mahar
@Derek: Yes, it won't run any other phase or goal.
Pascal Thivent
How can I tell Maven to suppress the messages for repositories in which it cannot find a dependency while displaying those where it finds a dependency? (That is, display the hits, but not the misses sine the misses drown out and obscure the hits.)
Derek Mahar