How to configure maven or eclipse in order to use the RELEASE constant within versions?

非 Y 不嫁゛ 提交于 2019-12-10 11:22:52

问题


All our projects are built using maven. we have centralized some of our main configuration within a super pom.

In order to always have an update version of this super pom (without having to modify the version), we have used the following syntax :

<parent>
    <groupId>my.organization</groupId>
    <artifactId>superPom</artifactId>
    <version>RELEASE</version>
</parent>

The problem is that Maven Eclipse plugin (m2e) doesn't understand this syntax (the RELEASE constant is not resolved). So, our Eclipse users can't use built-in compilation.

What do you suggest to overcome this problem ?

By the way, we have tried several options from a maven point of view (especially those described here), but the version.RELEASE is the easiest for everybody (except those who are using Eclipse).

EDIT: Our projects sources are split within multiple SVN repositories. This super pom is an independent project. It is retrieved through our Nexus server.


回答1:


You are trying to go into the wrong direction. A release in maven is a particular version like 1.0.0 and it indicates that you have a defined state of that artifact. In your case you super pom has a particular state. If you are trying to define the version to "RELEASE" you are saying my release is always the same but in reallity it's not true.

Usually such a super pom will change over the time lets say today you have defined some particular dependency versions in it (dependencyManagemet). And tomorrow you change those definition. Now the 1.000.000$ questions which state of the super pom is used in a build which has been done today? Ok in that simple scenario you can answer the question but if you have changed the super pom sometime yesterday you can't answer the question accurately.

Furthermore if you try to recreate an artifact of let's say last week you can't say which exact state of super pom has been used at that particular time cause you have no indicator which gives you the chance to see it.

And that's the reason why you need real versions like 1.0.0 or 1.1.0 etc.

I can strongly recomment to use real versions like 1.0.0 etc. but NOT things like "RELEASE" that will creep in the Maven system with its corrdinate group, artifact and version.




回答2:


Version ranges and expansion indeed do not work for parent artifacts.

Someone advised to invoke the version plugin instead :

mvn versions:update-parent 

which does not cover exactly your need, but I am afraid there is no better workaround. Other ideas : using a SNAPSHOT parent pom (not very satisfactory I admit). See also Maven2 cannot find parent from relative path.



来源:https://stackoverflow.com/questions/12371231/how-to-configure-maven-or-eclipse-in-order-to-use-the-release-constant-within-ve

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!