Build number and version with TC+Maven
I guess this is something easy to do as there are properties created by TC, but how can I, with Maven 2, use the build properties to create a properties file which will be bundled with my application in order to be used at runtime ?
Furthermore, how can I emulate this behaviour when building from Idea (so build properties are not available) ?
Thx.
Please sign in to leave a comment.
Hello Cedric,
Not really sure what you mean. Could you give a more specific example?
Anyway, Maven has extension mechanisms to enhance the build process with
custom functionality.
For example, you can write your own Ant-scripted plugin which would create
the file you need on a certain phase of the build.
WBR
--
Sergey Anchipolevsky
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Sure, I would like something similar to what TC does itself. When you open the main TC page, at the bottom, you can read " TeamCity Version 2.1.1(build 4261) ". I suppose that to be able to do that, the build number is automatically set by the TC build agent (Ant ? Maven ?) in some property file which is bundled with the build.
What I would like is to read "2.1.1" from my pom.xml, and 4261 from the property set by TC, and generate a properties file for it, assuming a properties file is the easiest way to achieve it, but if you have better ideas ;)
Hello Cedric,
Your idea looks quite reasonable. We use the similar way. But I can't give
you an exact solution since we don't build our projects with Maven.
However I'm sure it isn't very difficult to find an example it in the Net
since this problem is quite common.
At least, you can create your own Maven plugin which will read system property
build.number and Maven's artifact version and store them in a file.
--
Sergey Anchipolevsky
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Cedric Champeau wrote:
Have you looked at using the maven build-number plugin?
http://commons.ucalgary.ca/projects/maven-buildnumber-plugin/howto.html
With this you can set your artifacts naming to include such things as:
Date / Time
Incrementing build number
Subversion repository revision
This will work both from IDEA and TeamCity as its at the
maven/build-level and not the CI level.
Mark
This plugin does not really do what I would like. I guess I'll create an Ant task for it.
Cedric Champeau wrote:
Out of curiosity - why an Ant task and not your own maven plugin? I
assume possibly because you know how to write ant tasks and not looked
at maven mojos?
That's it. Maybe I could check an eye at mojos ;)
Finally made my own mojo. Works like a charm. Thanks !
Cedric Champeau wrote:
:)