Im facing the following problem: I want to integrate the mercurial hash into my java project. I want to integrate it in the name of the generate file (a debian package) and I also want to have a file like version.properties where I can access the mercurial hash.
I know that there are a lot of similiar questions, but I read through them and somehow Im not able to solve my problem.
I use buildnumber-maven-plugin for retrieving the mercurial hash. I then integrate it in the version. The debian package is then generated with this hash when I run mvn clean install
This is working so far.
<version>project-${buildNumber}</version>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
What I am missing is the buildNumber.properties
file, which should be generated automatically by the plugin. I cant find it anywhere. So I decided to write my own properties file. I created one in src/main/resources
and I added a property to my pom.xml. Here are the snippets:
pom.xml
<properties>
<merc.version>${buildNumber}</merc.version>
</properties>
version.properties
version=${buildNumber}
version2=${merc.version}
I run then mvn clean install
from cmdl. But when I open my version.properties file from command line with less
, I see the content as plaintext like written above. The properties are not replaced with real content. I only see version=${buildNumber}
, and so on.
Also, the file "pom.properties" which should be generated by maven does contain a very old version from one month ago. I dont understand what to do to update it.
Please, if any one could help me, that would be great :-) Thank you!
You have to activate filtering for the resources you wan't to be filter in that case this means:
<build>
<resources>
<resource>
<directory>src/main/resources/version/</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
If your version.properties files is correctly located under src/main/resources/version/ it will be filtered during the build process and will be copied to target/class/ ... where it should been replaced placeholders.