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

Viewed 4321

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?

6 Answers

I have faced same issue when using Maven 3.3.9. Tested by upgrading to Maven 3.5.4 but the issue still exists. The problem of maven-metadata.xml getting uploaded twice was due to spotbug maven plugin v3.1.3. It got resolved in the latest spotbug maven plugin version- 3.1.12 on which I have tested.

I was experiencing the same problem with maven 3.3.9. In my case, upgrading to maven 3.5.4 fixed the problem, no more "twice everything" in the default-deploy phase.

Related