maven -SNAPSHOT 关键字未替换

发布于 2024-10-18 01:48:31 字数 501 浏览 0 评论 0原文

我有一个带有 jar0.0.11-SNAPSHOT 的 Maven 项目。当我运行 mvn clean install 时,它将以下内容部署到我的本地存储库

~/.m2/repository/com/example/myproject/0.0.11-SNAPSHOT/Commons-0.0.11-SNAPSHOT.jar

我预计生成的工件的名称将由 -SNAPSHOT 替换为JAR 构建时间的时间戳,例如:

~/.m2/repository/com/example/myproject/0.0.11-SNAPSHOT/Commons-0.0.11-20110217011633.jar

为什么这种替换没有发生?

I have a Maven project with <packaging>jar</packaging> and <version>0.0.11-SNAPSHOT</version>. When I run mvn clean install, it deploys the following to my local repository

~/.m2/repository/com/example/myproject/0.0.11-SNAPSHOT/Commons-0.0.11-SNAPSHOT.jar

I expected that the name of the generated artifact would have -SNAPSHOT replaced by a timestamp of when the JAR was built, something like:

~/.m2/repository/com/example/myproject/0.0.11-SNAPSHOT/Commons-0.0.11-20110217011633.jar

Why is this replacement not happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

々眼睛长脚气 2024-10-25 01:48:31

我重读了这个问题,看起来你在谈论你的本地机器。 我怀疑您是否可以在本地存储库中存储唯一版本

请参阅:存储库 -快照处理,它说

在构建期间在本地存储库中安装工件时,version.txt 文件不会更新。这是因为该文件的本地最后修改时间用于确定下一次检查应该发生的时间。

相反,文件使用 0.15-SNAPSHOT 等格式存储。在将来的尝试中,会将此文件上的文件系统时间戳与 version.txt 上的文件系统时间戳进行比较,以确定哪个较新(其中 version.txt 仅在其内容更新时才更新其时间戳)。

还,

这意味着每次发布新的远程快照时,无论年龄如何,它都会覆盖本地快照。这是提供一致行为并避免时钟偏差的唯一方法 - 例如,虽然如果本地快照比远程快照新,则尊重本地快照可能是有意义的,但本地快照可能是从较旧的源构建的,因此事实上,年纪更大了。


下面的描述是针对私有存储库的。

在私有存储库中:

您需要配置本地存储库来存储唯一 SNAPSHOT 版本。 AFAIK,Artifactory 和 Nexus 中有一个设置可以做到这一点。

请参阅此处:http://wiki.jfrog.org/confluence/display/RTF/Local+Repositories

您可以选择:

  • 非唯一快照。
  • 独特的快照 - 具有独特的时间戳和版本号后缀。
  • 尊重部署者的行为 - Artifactory 将尊重用户快照策略,即充当标准的非智能存储库。

我没有使用过 Nexus,但似乎默认情况下它存储唯一的快照,您可以定义要保留快照的天数。我没有收到文章,但您可以查看 http:// www.sonatype.com/books/nexus-book/reference/config-sect-scheduled-services.html

另外,您可以在分发管理块中明确指示 uniqueVersion 为 true。但是,我想默认情况下是这样。也许给它一个机会,

 <distributionManagement>
   ...
   <repository>     
     ...
     <uniqueVersion>true</uniqueVersion>
   </repository>
   ...
 </distributionManagement>

I reread the question, seem like you're talking about your local machine. I doubt that you could store Unique version in local repository

refer this: Repository - SNAPSHOT Handling, it says

When installing an artifact in the local repository during a build, the version.txt file is not updated. This is because the local last modification time of that file is used to determine when the next check should occur.

Instead, the file is stored using the format such as 0.15-SNAPSHOT. On future attempts, the filesystem timestamp on this file is compared to the filesystem timestamp on the version.txt to determine which is newer (where version.txt only has its timestamp updated when its contents have been updated).

Also,

This means that every time a new remote snapshot is published, it will overwrite a local snapshot regardless of age. This is the only way to provide consistent behaviour and avoid clock skew - for example, while it might make sense to honour a local snapshot if it were newer than the remote snapshot, it may be that the local one was built from older sources and so is, in fact, older.


The description below is for private repository.

In a private repositiry:

You need to configure your local repository to store unique SNAPSHOT versions. AFAIK, there is a setting in Artifactory and Nexus to do this.

See here: http://wiki.jfrog.org/confluence/display/RTF/Local+Repositories

You can choose between:

  • Non-unique snapshots.
  • Unique snapshots - with unique time-stamp and build number suffix.
  • Deployer-respecting behavior - Artifactory will respect the user snapshot policy, i.e. act as a standard, non-smart, repository.

I havn't used Nexus, but seems like by default it stores unique snapshot and you can define how many days you want to keep the SNAPSHOT. I didn't get an article but you may look into http://www.sonatype.com/books/nexus-book/reference/config-sect-scheduled-services.html

Also, you may explicitely indicate uniqueVersion as true in distribution management blocl. But, I guess that true by default. may be give it a chance,

 <distributionManagement>
   ...
   <repository>     
     ...
     <uniqueVersion>true</uniqueVersion>
   </repository>
   ...
 </distributionManagement>
沉溺在你眼里的海 2024-10-25 01:48:31

我认为当您将工件部署到快照存储库时,您所写的内容(替换SNAPSHOT令牌)是正确的。但是 install 的工作原理(至少对我来说)正如您所描述的那样 - 所以它不会用时间戳替换 SNAPSHOT

I think what you wrote (replacing SNAPSHOT token) is true when you deploy the artifact to snapshot repository. But install works (at least for me) as you udescribed - so it doesn't replace the SNAPSHOT with timestamp.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文