简体   繁体   English

如何使maven-metadata.xml与maven部署的工件具有相同的时间戳?

[英]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". 我有一个Nexus 3,我使用“mvn deploy”从Jenkins部署了一些工件。 I have A LOT of modules 500+. 我有很多模块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. 通常有1秒的差异。

This is what I see in nexus at https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/maven-metadata.xml 这是我在nexus上看到的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: 判断maven-metadata.xml,工件URL应该是这样的:

https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/my-artifact/1.0.0-20170613.140447-1.war 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 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" mvn --version OpenJDK 64位服务器VM Apache Maven 3.5.0(ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06 + 02:00)Maven home:/ usr / local / apache-maven Java版本:1.8.0_131,供应商:Oracle Corporation Java home:/ usr / lib / jvm / java-8-openjdk-amd64 / jre默认语言环境:en_US,平台编码:UTF-8操作系统名称:“linux”,版本:“4.4.0-64- generic“,arch:”amd64“,family:”unix“

The version of maven-deploy-plugin is 2.8.2 maven-deploy-plugin的版本是2.8.2

What am I doing wrong? 我究竟做错了什么? How can I fix this? 我怎样才能解决这个问题? Thank you! 谢谢!

This is a bug in Maven 3.5.0 and and will be resolved whenever 3.5.1 is released. 这是Maven 3.5.0中的一个错误,并且只要3.5.1发布就会解决。

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 . 最初的错误报告标记了deploy-plugin( https://issues.apache.org/jira/browse/MDEPLOY-221 )但是它与maven核心有关: 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. 我们在工作中遇到了同样的问题,在对mavens问题跟踪器进行了一些挖掘和搜索后,我找到了上述链接。 I would suggest downgrading while waiting for 3.5.1 to come out. 我建议等到3.5.1出来时降级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM