Paul McKenzie
Paul McKenzie

Reputation: 20096

How can I get Maven to write a property into a property file at package time?

For continuous integration I am using Maven 2 and TeamCity 5.1.2. My builder number is defined by the pattern %maven.project.version%.{0}, and this is exported to Maven build script as ${build.number}

When the build creates the jar file I would like the jar to contain a property file with this information inside:

build.number=#1.1-SNAPSHOT.106

This is so that the build number is available for display etc at runtime.

Upvotes: 0

Views: 3807

Answers (3)

Jay
Jay

Reputation: 1

Try

build.number=${buildNumber}

where ${buildNumber} is place holder for Maven to add the next number.

Upvotes: 0

Mike Cornell
Mike Cornell

Reputation: 6059

Based upon the comment, it sounds like %maven.project.version% is not being replaced by TeamCity. You're getting the build job number, but not getting the value for the maven ID.

I would look at potentially doing this in two parts.

Can ${build.number} only contain the actual build number, instead of %maven.project.version%?

If so, you should be able to have your properties file say:

build.number=#${project.version}.${build.number}

In theory that would produce:

build.number=#1.1-SNAPSHOT.106

But not having worked with TeamCity, this is just a theory.

Upvotes: 1

sblundy
sblundy

Reputation: 61414

You could have a copy of the property file with a placeholder for the build number

build.number=${build.number}

Than copy with filtering enabled.

Upvotes: 3

Related Questions