I have a maven based multi-module project. Also we manage multiple parallel releases for different clients for which we obviously need long lived branches. To all these branches, we give assign unique project version.
If in master branch, project version is 1.0.0-SNAPSHOT, whenever we will take a new git branch for a client, we will assign project version in a pattern 1.0.0.<ClientID>-SNAPSHOT.
Now, since this project version is present at multiple places like deployment scripts, MANIFEST.MF, assembly files, README.txt etc. Now I want to centralize project version at one place and all files in project should refer project version from this place. It can be ROOT pom.xml file or any txt file placed in root directory. Example version.properties.
Right now I am using Maven Flatten Plugin to reflect this in pom files of sub-modules, but not sure how to handle other files in best possible way.
I have a maven based multi-module project. Also we manage multiple parallel releases for different clients for which we obviously need long lived branches. To all these branches, we give assign unique project version.
If in master branch, project version is 1.0.0-SNAPSHOT, whenever we will take a new git branch for a client, we will assign project version in a pattern 1.0.0.<ClientID>-SNAPSHOT.
Now, since this project version is present at multiple places like deployment scripts, MANIFEST.MF, assembly files, README.txt etc. Now I want to centralize project version at one place and all files in project should refer project version from this place. It can be ROOT pom.xml file or any txt file placed in root directory. Example version.properties.
Right now I am using Maven Flatten Plugin to reflect this in pom files of sub-modules, but not sure how to handle other files in best possible way.
Share Improve this question asked Mar 25 at 12:11 pankaj_arpankaj_ar 7652 gold badges11 silver badges37 bronze badges 1- I recommend to read: maven.apache./guides/mini/guide-maven-ci-friendly.html – khmarbaise Commented Mar 25 at 20:57
1 Answer
Reset to default 0You manage the project version in the POM. You can either use the maven flatten plugin together with versions like ${revision}
or you can use versions:set
to set the version across all modules.
To put the version into other places like readme files etc. you usually use the maven resources plugin and do filtering, i.e. you put something like ${project.version}
into the files and let the maven resources plugin do the replacement. See also
https://maven.apache./plugins/maven-resources-plugin/index.html
That said, let me remark that having long-lived branches for different clients is often a bad idea. It means that you need to merge bugfixes and features into a multitude of different branches, which requires a lot of work. It is usually better to think about some kind of plugin system for client-specific behaviour, or at least have large core and only a small client-specific dependency.