Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Passing properties to Maven based build

Is it possible to use the Properties tab to pass properties to Maven like we can do with Ant?

Currently I am just able to pass properties using JVM arguments field.

Thanks in advance,

    Chemi.

1

1 vote



2 answers

Permanent link

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.

0 votes

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".


Permanent link
Unfortunately, mvn doesn't have a command line option for passing a properties file (which is the mechanism JBE uses to pass properties to Ant), and the Maven participant in JBE does not generate -D's for every property.
You'll need to add these yourself, like in Victor's approach.  It will do property substitution in the various fields of the build definition before invoking mvn.  e.g. to pass through the build label, you can add: -DbuildLabel=${buildLabel}

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 562
× 45

Question asked: Jan 15 '13, 6:58 a.m.

Question was seen: 11,568 times

Last updated: Apr 18 '13, 2:44 p.m.

Confirmation Cancel Confirm