开发者

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

开发者 https://www.devze.com 2023-01-14 01:50 出处:网络
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}

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.开发者_如何学Pythonnumber=#1.1-SNAPSHOT.106

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


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.


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.


Try

build.number=${buildNumber}

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

0

精彩评论

暂无评论...
验证码 换一张
取 消