Search code examples
javamavenjenkinsnexus3

How can I make maven-metadata.xml have the same timestamp as the artifact wen deployed with maven?


I have a Nexus 3 which I deploy some artifacts from Jenkins with "mvn deploy". I have A LOT of modules 500+. The build looks kind of like this:

mvn clean package -DskipTests -DskipITs -T C1

mvn install -DskipTests -DskipITs -T C1

mvn deploy --quiet -DskipTests -DskipITs -Dmaven.validate.skip=true -Dmaven.compile.skip=true -Dmaven.test.skip=true -Dmaven.package.skip=true -Dmaven.integration-test.skip=true -Dmaven.verify.skip=true -T C1

The problem is that from time to time my artifacts have a timestamp while the metadata has a different timestamp. 1 second difference usually.

This is what I see in nexus at https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/maven-metadata.xml

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
  <groupId>com.company</groupId>
  <artifactId>my-artifact</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20170613.140447</timestamp>
      <buildNumber>1</buildNumber>
    </snapshot>
    <lastUpdated>20170613140447</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <extension>war</extension>
        <value>1.0.0-20170613.140447-1</value>
        <updated>20170613140447</updated>
      </snapshotVersion>
      <snapshotVersion>
        <extension>pom</extension>
        <value>1.0.0-20170613.140447-1</value>
        <updated>20170613140447</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>

Judging the maven-metadata.xml, the artifact URL should be this:

https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/my-artifact/1.0.0-20170613.140447-1.war

But it is not. Instead, the artifact is at this location:

https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/my-artifact/1.0.0-20170613.140446-1.war

mvn --version OpenJDK 64-Bit Server VM Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00) Maven home: /usr/local/apache-maven Java version: 1.8.0_131, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-64-generic", arch: "amd64", family: "unix"

The version of maven-deploy-plugin is 2.8.2

What am I doing wrong? How can I fix this? Thank you!


Solution

  • This is a bug in Maven 3.5.0 and and will be resolved whenever 3.5.1 is released.

    The original bug-report targed the deploy-plugin (https://issues.apache.org/jira/browse/MDEPLOY-221) however it's an issue with maven core: https://issues.apache.org/jira/browse/MNG-6240.

    We hit the same issue at my work and after some digging and searching on mavens issue tracker I found the above links. I would suggest downgrading while waiting for 3.5.1 to come out.