I also need to commit some additional files (modified by the Maven Replacer plugin). I did it as follows:
First, I configured the Maven Release plugin to accomplish additional goals:
<plugin> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> <configuration> <preparationGoals>-Prelease -DreplacerVersion="${releaseVersion}" clean replacer:replace scm:checkin verify</preparationGoals> <completionGoals>-Prelease -DreplacerVersion="${developmentVersion}" clean replacer:replace scm:checkin verify</completionGoals> </configuration> </plugin>
release profile defines plugin configuration Maven SCM ArgumentreplacerVersion used by the Maven Replacer plugin to install the correct version in some files.clean - the standard target launched by the Maven Release plugin (default: clean verify )replacer:replace The target is responsible for modifying filesscm:checkin commit and clickverify is the standard target executed by the Maven Release plugin (default: clean verify )
Next, I configured the Maven Replacer Plugin :
<plugin> <groupId>com.google.code.maven-replacer-plugin</groupId> <artifactId>replacer</artifactId> <version>1.5.3</version> <configuration> <includes> <include>${basedir}/file1.txt</include> <include>${basedir}/file2.txt</include> </includes> <replacements> <replacement> <token><![CDATA[<pattern>.*</pattern>]]></token> <value><![CDATA[<pattern>${replacerVersion}</pattern>]]></value> </replacement> <replacement> </configuration> </plugin>
${replacerVersion} allows you to use the same configuration to move from development to release and from version to the next development version.
Finally, I determined which version of the Maven SCM plugin I want to use:
<plugin> <artifactId>maven-scm-plugin</artifactId> <version>1.9.5</version> </plugin>
and configure it in the release profile (I defined it in the profile to prevent accidental commit during build without release):
<profile> <id>release</id> <build> <pluginManagement> <plugins> <plugin> <artifactId>maven-scm-plugin</artifactId> <configuration> <message>[maven-scm-plugin] set ${replacerVersion} version in files</message> <includes>file1.txt, file2.txt</includes> </configuration> </plugin> </plugins> </pluginManagement> </build> </profile>
Thanks to this, after executing the command:
mvn release:prepare -DdevelopmentVersion=1.2.1-SNAPSHOT -DreleaseVersion=1.2.0 -Dtag=1.2.0
I see 4 commits:
- [maven-scm-plugin] install version 1.2.0 in files
- [maven-release-plugin] prepare release 1.2.0
- [maven-scm-plugin] install version 1.2.1-SNAPSHOT in files
- [maven-release-plugin] getting ready for the next development iteration
agabrys
source share