Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The timestamp in snapshot jar's maven-metadata.xml is more than a second than the actual jar's timestamp?

I encountered a quirky problem:

I used "mvn deploy" (Maven 3.3.9, Jenkins 2.45, Nexus 2.12.0) to deploy a snapshot jar to my nexus in jenkins, result as below (suppose the jar name is userdao.jar):

Uploaded: myNexusIp/nexus/content/repositories/snapshots/xxx/1.0-SNAPSHOT/userdao-1.0-20170512.111840-6.jar 
Uploaded: myNexusIp/nexus/content/repositories/snapshots/xxx/1.0-SNAPSHOT/maven-metadata.xml

The build was successful and everything was OK.

But when I built another maven project that depended above userdao.jar, error occurred as below:

Could not find artifact userdao:jar:1.0-20170512.111840-6 in public (http://myNexusIp/nexus/content/groups/public/)

After positioning I found that the timestamp in maven-metadata.xml in the nexus was more than a second than the actual jar's timestamp!
As below:

  • in maven-metadata.xml: 1.0-20170512.111840-6
  • actual existing snapshot jar: userdao-1.0-20170512.111839-6.jar

Because userdao-1.0-20170512.111840-6.jar did not exist in Nexus, the right one should be userdao-1.0-20170512.111839-6.jar, so it errors.

Who can tell me why and how to resolve it?

like image 355
IcyLemon Avatar asked May 14 '17 04:05

IcyLemon


4 Answers

This has been confirmed a maven-3.5 issue https://issues.apache.org/jira/browse/MNG-6240 and a fixed applied. The release of maven-3.5.1 with the fix is voted here https://www.mail-archive.com/[email protected]/msg114783.html

like image 196
WuchenW Avatar answered Oct 15 '22 20:10

WuchenW


I actually found the opposite. After upgrading from Maven 3.3.9 to 3.5.0 I could reliably deploy artifacts where by the time stamps appearing in the metadata.xml files on Nexus were incorrect compared to the actual files that were deployed.

By downgrading (back to 3.3.9) everything worked correctly. The metadata.xml versions and timestamps matched always.

Perhaps it's something to do with the Maven 3.5.0 upgrade to remove Aether?

like image 27
Pinocchio Code Avatar answered Oct 15 '22 22:10

Pinocchio Code


The first thing to try is to rebuild your metadata on the repo where you uploaded your snapshot artifact.

See "Managing Scheduled Tasks"

Rebuild Maven Metadata Files

This task will rebuild the maven-metadata.xml files with the correct information and will also validate the checksums (.md5/.sha1) for all files in the specified Repository/Group.
Typically this task is run manually to repair a corrupted repository.

like image 32
VonC Avatar answered Oct 15 '22 22:10

VonC


I updated maven from 3.3.9 to 3.5.0, found that the maven-metadata.xml was uploaded once and the issue was resolved! So I guess this is a bug in maven 3.3.9, my current solution is updating maven to 3.5.0.

like image 29
IcyLemon Avatar answered Oct 15 '22 21:10

IcyLemon