Passing properties to Maven based build
2 answers
We are successfully passing the RTC buildLabel property in our Maven builds.
In the .pom, we define:
<properties>
<buildNumber>1.0-SNAPSHOT</buildNumber>
</properties>
also
<version>${buildNumber}</version>
(Note: the "N" in buildNumber tag is a capital "N", it just doesn't display that way)
In the build definition for our release builds, on the "goals" in the Maven tab, we add:
-DbuildNumber=1.0-${buildLabel}
Without the parameter, the developers still run SNAPSHOT buiilds, using 1.0-SNAPSHOT. Our release builds are created with the RTC build label as: MyBuild-1.0-20130402-1000.jar
What doesn't work for us was adding the property in the Properties section, as this doesn't seem to work like it did running ANT builds.
Comments
The above solution is a simplistic approach to include the RTC buildLabel in Maven builds. For our larger projects that use an aggregate POM with several sub-projects, it doesn't work.
Ideally, the versions plugin would be used to set the version number in all the POMs. An issue with including a call to the plugin within the goals of an RTC Maven build definition is that even though all the POMs physically get updated correctly, a single invocation of Maven does not pick up the changes.
This has required us to substitute the usage of the Maven build definition with a Command Line build definition, which allows us to run a batch file that invokes Maven twice, first with "mvn versions:set", and secondly with "mvn deploy".