Maven3 unable to get latest artifact SNAPSHOT version from remote repo

I’ve been facing this error fro quite a while now. Without being able to trace it back in time precisely, I feel it dates back from the switch to maven3.

Here’s what happens:

  • I deploy artifact-SNAPSHOT from a server to an Artifactory instance
  • I force snapshot update on my local project that depends on artifact-SNAPSHOT

it doesn’t work, I may get compilation error that shows the artifact-SNAPSHOT isn’t the lastest one.

I have to either delete the local repo version of artifact-SNAPSHOT or get the lastest source and do a local ‘mvn install’ of artifact-SNAPSHOT.

Anyone facing the problem? Is it a known bug? If not, what could I check to understand exactly what happens?

cheers

Answer

This is a bug. Here is a link.

If you have worked on module-A (1.2.3-SNAPSHOT) for a while and you’ve run:

mvn clean install

This causes your local repository’s metadata to ‘lock’ the artifact, meaning that it won’t get updated anymore, as it thinks you’re still working on it. So, if, let’s say, in a couple of days you start working on module-B which depends on module-A:1.2.3-SNAPSHOT and there is a newer version installed in the remote repository, that version will completely be ignored. Thus, you’ll have to remove the local directory that contains this dependency first and then do:

mvn clean install

all over again. Passing the -U doesn’t help at all (which would actually be the natural thing to do).

Leave a Reply

Your email address will not be published. Required fields are marked *