Laird Nelson
Laird Nelson

Reputation: 16174

Why can't Maven find my SNAPSHOT artifact when I can download it manually just fine?

I have the world's simplest Maven/Jenkins/Nexus setup.

Maven runs via Jenkins dozens of times a day and deploys SNAPSHOTs to our Nexus repository just fine.

Every once in a blue moon, with seemingly no cause, running another Maven job that requires resolution of SNAPSHOTs will fail. It fails in these rare cases with Maven telling me that it cannot any longer find the SNAPSHOTs that it uploaded in many cases several hours before.

If I point my web browser at the very repository location that Maven is using I can find them just fine.

Immediately before these errors, I always see (as I do in success cases) a bunch of maven-metadata.xml files being downloaded. Presumably these files tell Maven something about how to take, e.g. 1.009-SNAPSHOT and turn it into 1.009-somehugetimestamphere.

(I have never found any documentation of this file, and it does not seem to mark any of the filenames contained therein as "latest" or anything similar. In fact I cannot see how it is of any use at all, but clearly it must be.)

(I also see various references to resolver-status.properties in the debug output, which seems to be another undocumented file written to the local repository that tracks something having to do with resolution, but I confess I don't know what.)

My broad question is: how exactly does Maven go about downloading and resolving and checking SNAPSHOTs? Assuming that the repository information is valid (after all, this job works 90% of the time and fails 10% of the time with no changes), what steps does Maven take with a given repository to find the proper SNAPSHOT?

EDIT: Found some documentation: http://maven.apache.org/ref/3.0.4/maven-repository-metadata/repository-metadata.html although it doesn't explain why none of the maven-metadata.xml files I find in my Nexus 2.0 installation have the <latest/> element in them. Nor does it detail how these files are used.

My posting on the users list brought a response that some of this might be a Nexus problem, in that it may or may not be generating these maven-metadata.xml files properly.

Upvotes: 1

Views: 2796

Answers (1)

herrtim
herrtim

Reputation: 2755

I ran into a very similar problem the other day with a Nexus server proxying another repository. In my case, changing the Expiration Settings in Nexus fixed the problem. I reduced the "Artifact Max Age" and "Metadata Max Age" from 1 day to 1 minute.

Upvotes: 1

Related Questions