Reputation: 6297
I would like to have an external file, containing a single value - a version, such as 1.0
Then, I would like to reference this in my pom.xml, such that the version
property will be set during build by the value I give to it
This way I can have proper versioning on my jar without commiting changes using mvn to the entire reactor every time
For example, something like:
<version>./version.txt</version>
And if the content of version.txt
is 1.0
, when I compile my code to a jar, mvn will evaluate the content of my file and set the jar version to 1.0
It slightly differs from properties file since my external file is not a key=value
formatted file, its merely a value which I want to read in full and have it represent the value of a key in my pom.xml
Upvotes: 3
Views: 1653
Reputation: 1391
You can achieve this by running the maven versions plugin before running your build
Your build script could loook something like this:
mvn -B -DnewVersion=$(cat ./version.txt) -DgenerateBackupPoms=false versions:set
mvn -B clean install
Upvotes: 1