简体   繁体   English

Maven发布插件:使用SNAPSHOT版本发布

[英]Maven release plugin : Releasing with a SNAPSHOT version

I know, its not a good practice to release a project with SNAPSHOT dependencies. 我知道,使用SNAPSHOT依赖项发布项目不是一个好习惯。

But, I would like to know, Is there any way, we can make maven release plugin to release with SNAPSHOT dependencies? 但是,我想知道,有什么办法,我们可以使用maven发布插件来发布SNAPSHOT依赖项吗?

Is there any parameters that I can pass to the maven release plugin to accept SNAPSHOT version of the dependencies while releasing? 是否有任何参数可以传递给maven发布插件,以便在发布时接受SNAPSHOT版本的依赖项?

Like 喜欢

-Dallow.snapshots= true

You could consider using the allowTimestampedSnapshots option to release:prepare . 您可以考虑使用allowTimestampedSnapshots选项来release:prepare This was apparently added to deal with use-cases where SNAPSHOT dependencies are unavoidable. 这显然是为了处理SNAPSHOT依赖性不可避免的用例。

But you should only do this if it is unavoidable. 但是,如果不可避免,你应该这样做。 Among other things, some Maven repositories can be configured to automatically delete old SNAPSHOT releases. 除此之外,一些Maven存储库可以配置为自动删除旧的SNAPSHOT版本。 If that happened, your released artifacts could end up with permanently broken dependencies. 如果发生这种情况,您发布的工件最终可能会导致永久性破坏的依赖项。

Why would you want that? 你为什么要那样? A released version is supposed to never change. 发布的版本应该永远不会改变。 Updating one of the snapshot dependencies risks breaking the system. 更新其中一个快照依赖项可能会破坏系统。 I see two approaches: 我看到两种方法:

Either you have control over the source code of your dependencies, in which case I recommend you to go through the, albeit tedious, process of releasing those projects. 您可以控制依赖项的源代码,在这种情况下,我建议您完成释放这些项目的过程,尽管这是一个繁琐的过程。

If you don't control the source code you can still rename the binary and manually upload it to your release server. 如果您不控制源代码,您仍然可以重命名二进制文件并手动将其上载到发布服务器。 You might still take this approach even for projects under your control, although I strongly encourage you not to. 即使对于您可控制的项目,您仍可能采用这种方法,但我强烈建议您不要这样做。

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

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