Hi Shahzad,
On Tue, Mar 23, 2010 at 10:58 AM, Qureshi,Shahzad [Ontario]
<[email protected]> wrote:
>
> I would like the ability to read the project's version number from pom in my
> java code as I need to insert that version number in the text file I generate
> as a result of my code. I am NOT writing a maven plugin but a standalone java
> project that uses maven as a build/dependency system
>
> At this point, I can only think of one way of doing that and that is using
> the properties-maven-plugin to output the <properties> section from the pom
> into a text file and in my <properties> seciton I reference the project's
> version as ${project.version}
>
> Can you suggest or think of a better solution?
>
I have a somewhat novel solution, if I do say so myself. :-)
$ cat src/main/resources/com/acme/project.properties.vm
# project.properties
project.name = ${project.name}
project.version = ${project.version}
project.description = ${project.description}
project.inceptionYear = ${project.inceptionYear}
And make sure to have resource filtering enabled (although I'm not
sure if this is required). Then simply read the project.properties
file (note: no .vm suffix) from your program using standard
java.util.Properties. I actually bundle this project properties and
unpack it with maven-remote-resources-plugin automatically in my
corporate pom.
-Jesse
--
There are 10 types of people in this world, those
that can read binary and those that can not.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]