We have a maven project structure like this:
Parent
L A
L B
A
depends on B
Both have various dependencies on other libs
Building this with mvn clean install
works fine, but when we try to prune all dependencies as described here with
mvn dependency:purge-local-repository
We get an error saying that it can't resolve the dependency to B:jar:snapshot-version
:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:purge-local-repository (default-cli) on project A: Failed to refresh project dependencies for: A:jar:4.0.1-SNAPSHOT: required artifacts missing:
[ERROR] B:jar:6.0-5
My current interpretation is that during an actual build B
gets build first and can get resolved, but during the purge nothing gets build so the resolution fails. But the project is there and its dependencies should get purged. How can I fix this?
-DactTransitively=false
doesn't seem to change anything.
In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.
To clear/delete your local maven repository cache, simply delete the . m2/repository folder. The local repository path can also be configured in Maven setting. xml (either the global or the user one).
It only cleans the project. Show activity on this post. Show activity on this post. With the help of Purging local repository dependencies you need to do that.
While it doesn't seem to be the exact issue referenced by @Tunaki the example in there let me try this:
mvn dependency:purge-local-repository -DreResolve=false
Which got rid of the exception but failed to actually reload the dependency I had problems with. At which point I came across this answer which made me try
mvn dependency:purge-local-repository -DreResolve=false -DactTransitively=false
which solved the problem although it seems to requesting the opposite of what I wanted to achieve :-/
This looks like a bug with the maven-dependency-plugin
(JIRA issue MDEP-405) introduced by a regression in Maven 3.0.4.
From Paul Gier's comment:
I think the reason this happens is because in order to determine the full set of transitive dependencies to delete, the poms need to be available. If the poms were already resolved in the previous module, Maven won't re-resolve them again and just fails. So the dependency doesn't have a problem with the file already being deleted from the local repo, but the maven dependency resolution code fails when trying to resolve the same file twice in the same build.
You might try the build with Maven 3.0.3 because there was a change in this in Maven 3.0.4: http://mail-archives.apache.org/mod_mbox/maven-dev/201210.mbox/%3C5752023.Vp0WJBo1vZ%40bigmax%3E
This is linked to the regression MNG-5366, that is currently unresolved.
I don't see any real work-around apart from downgrading Maven.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With