You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sergey Shcherbakov <ss...@echelon.de> on 2009/04/06 12:06:56 UTC

How to override project version during the build?

Hi all,

 

We are building our maven project using Luntbuild CI system 

(I find it by the way worth mentioning here 

http://maven.apache.org/continuous-integration.html )

 

Each build gets it's own version number even if it is a snapshot build
(we need to distinguish them too).

So in the pom.xml I have:

 

<version>${MAJOR.VERSION}.${MINOR.VERSION}.${BUILD.VERSION}${SNAPSHOT}</
version>

 

<properties>

<MAJOR.VERSION>0</MAJOR.VERSION>

            <MINOR.VERSION>00</MINOR.VERSION>

            <BUILD.VERSION>000</BUILD.VERSION>-->

            <SNAPSHOT></SNAPSHOT>

</properties>

 

In order to have a harmless default version and be able to pass correct
build version through the command line parameters.

Overriding from the command line works fine, but the pom.xml gets
deployed unchanged to the repository, i.e. with default zeros as
property values and thus project version, although during the build
those values were overridden.

 

This is not a problem if you have no transitive dependencies made in
this way.

Assuming you have three projects that depend on each other: A -> B -> C;
and C has been built using project version shown above then the A build
fails because maven cannot find dependent C artifact of the version
0.00.000, although it finds artifact B of the appropriate version fine
(even if A and B are made in the same way as C).

 

How can I solve this problem and what is the right way to automatically
update maven project's version?

 

Thank you!

 

Best Regards,

Sergey Shcherbakov.