7

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.

Community
  • 1
  • 1
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
  • Why would you like to purge local cache ? What kind of problem are you trying to solve? – khmarbaise Apr 27 '16 at 10:41
  • 1
    @khmarbaise I need to purge the local repository cache, because the content of artifacts has changed, without the version being changed. I'm fully aware that this wrong on all levels, but it's something I can't change (at least right now). Also I don't have access to the filesystem, which is on a CI-Server – Jens Schauder Apr 27 '16 at 10:58
  • The job in the CI server should have the local cache and not the whole CI server cause it makes automatically all jobs depend on this cache...I would suggest to make a separate job which deletes those things don't make a maven call for this...In particular if you violating the immutability of release version artifacts which results exactly such problems and issues... – khmarbaise Apr 27 '16 at 11:24

2 Answers2

9

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 :-/

Community
  • 1
  • 1
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
3

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.

Tunaki
  • 132,869
  • 46
  • 340
  • 423