Maven仅部署更改的工件 [英] maven deploy changed artifacts only

查看:107
本文介绍了Maven仅部署更改的工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Maven 2.2与nexus 1.4.0一起使用

I'm using maven 2.2 with nexus 1.4.0

假设我有一个像这样的pom结构(带有相应的版本)

Let's say I have a pom-structure like this (with corresponding versions)

parentproj, v1.0.1
 - childproj1, v1.0.2
 - childproj2, v1.0.7

childproj1和childproj2代表应用程序的不同部分(例如gui和后端),我希望能够将它们的版本分开,这样我就可以发布后端的新版本而不必发布gui的新版本

childproj1 and childproj2 represent different parts of the application (e g gui and backend) and I want to be able to keep their versions separate so that I can release a new version of the backend without having to release a new version of the gui.

现在,要将这种结构部署到Nexus,可以很方便地转到parentproj说

Now, to deploy this structure to Nexus it would be convenient to go to parentproj and say

mvn deploy -DperformRelease = true

mvn deploy -DperformRelease=true

会将所有工件部署到Nexus realease存储库.第一次部署它时效果很好,但是第二次遇到问题:假设我对childproj1进行了更新,所以现在有了以下版本:

which would deploy all artifacts to the Nexus realease repository. This works fine the first time I deploy it, but the second time I run into problems: let's say that I made an update to childproj1 so that we now have the following versions:

parentproj, v1.0.1
 - childproj1, v1.0.3
 - childproj2, v1.0.7

在这种情况下,Nexus不允许我从parentproj进行mvn部署,因为它已经拥有1.0.7版本的childproj2的副本. Nexus会说资源非法请求:ID为'releases'的存储库不允许更新工件."很好,我不想错误地更新现有版本.

In this situation Nexus will not let me do mvn deploy from parentproj, since it already has a copy of childproj2 in the 1.0.7 version. Nexus will say "Resource, illegal request:Repository with ID='releases' does not allow updating artifacts." This is fine, I don't want to update existing versions by mistake.

但是我想我想做的是能够告诉Maven这样的事情,例如仅部署那些版本不存在于版本库中的工件".

But I guess that what I would like to do is to be able to tell maven something like "deploy only those artifacts that have versions that are not already present in the release repository".

有没有办法做到这一点,还是我必须自己部署每个项目?

Is there a way to do this, or would I have to deploy each project by itself?

推荐答案

首先,我认为您应该区分父项目和聚合项目.上级项目应用于几个项目共有的设置,例如依赖项的版本;应该使用集合项目,以便同时构建一组项目,例如一组罐子和包括它们的战争.

First of all, I think you should distinguish between parent project and aggregation project. Parent projects should be used for those settings that are common to several projects, e.g. dependencies' versions; aggregation projects should be used in order to build at the same time a group of projects, e.g. a set of jars and the war that includes them.

两种项目最好分开放置.上级项目通常不会经常更改,通常最好在发布时发布依赖于该项目的所有项目的新版本.聚合项目的唯一目的是推动一堆项目的构建,因此只要需要释放其中包含的一个项目,它的发行号就应该更改.

The two kind of projects are best kept separated. The parent project usually does not change very often and when it does it is usually best to release new versions of all the projects that depend from it; the aggregation project's only purpose is to drive the build of a bunch of projects, so its release number should probably change whenever one of the projects it contains needs to be released.

一旦您将父项与聚合器分离开了,您就可以更好地选择是遵循John Paulett的建议并将所有内容保持在相同的版本号,还是仅在实际需要发布时才尝试更改每个项目的版本号它.第一个选项更简单,更不易出错,但是会导致您发布未更改的库的新版本.例如,如果您需要交付补丁程序而不是完整版本,则这可能是不可接受的.第二个选项更复杂且容易出错,但是会导致您的发行版号与软件的发展相匹配. Maven发行插件和Jenkins持续集成工具可能对您有所帮助,我认为您应该检查一下它们.另外,请查看是否可以将Maven至少升级到2.2.1版本,并将Nexus升级到最新版本.

Once you've separated parent from aggregator you're in a better position to choose whether to follow John Paulett's advice and keep everything at the same version number or to try and change each project's version number only when you actually need to release it. The first option is simpler and less error prone, but causes you to release new version of libraries that haven't changed. This might not be acceptable if, for instance, you need to ship patches rather than full releases. The second option is more complicated and error prone, but causes your release numbers to match the evolution of your software. The Maven release plugin and the Jenkins continuous integration tool may be of help there, I think you should check them out. Also, see if you can upgrade Maven to at least version 2.2.1 and Nexus to a more recent version.

这篇关于Maven仅部署更改的工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆