Reputation: 159
I have a maven project with lots of modules (and modules inside modules). I am using maven-release-plugin for controlling the versions in the pom.xml files.
When running command mvn release:prepare
plugin is pushing two commits with messages: "[maven-release-plugin] prepare release v0.9.0.38" and "[maven-release-plugin] prepare for next development iteration" accordingly. Herein the second one is just snapshot version.
Here is the maven-release-plugin settings:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<checkModificationExcludes>
<checkModificationExclude>pom.xml</checkModificationExclude>
<checkModificationExclude>*/pom.xml</checkModificationExclude>
</checkModificationExcludes>
<branchBase>master</branchBase>
</configuration>
</plugin>
</plugins>
</build>
When pushing I am setting the tag to the remote git project as well (You can see it in <tagNameFormat>v@{project.version}</tagNameFormat>
) so I need to push commits definitely, but I don't want it to push snapshot versions (e.g. 0.9.0.38-SNAPSHOT).
Edit:
As I am incrementing minor version of the project on each commit by running
mvn release:prepare
.
e.g. Commits looks like following:
[maven-release-plugin] prepare for next development iteration
[maven-release-plugin] prepare release v0.9.0.38
(refactor) Code cleaned up
[maven-release-plugin] prepare for next development iteration
[maven-release-plugin] prepare release v0.9.0.37
(feature) Added I18N support
This looks very ugly, and pushing three commits on every change is very bad solution only for just incrementing minor version of the pom file not manually.
How can I achieve this?
Upvotes: 4
Views: 12559
Reputation: 1885
Described behavior is intended - plugin increments version of your modules after releasing them which is normal. So the main advice is think twice before customizing it.
If you're using Git, you can set pushChanges to false
to avoid pushing. After that you can rollback last commit and push changes
git reset HEAD~ --hard
git push origin master
Advice would be more practical if you explained why you consider the second commit as redundant.
Also you always can use dryRun switch if you're not sure about changes.
Update:
mvn versions:set -DnewVersion=<version-to-set> -DgenerateBackupPoms=false
git commit -m "your-comment"
git tag <your-tag>
These steps can be easily aggregated to script file to avoid monkey-job.
As an alternative, you can look to BuildNumber-maven-plugin, which also can be useful.
Upvotes: 1
Reputation: 29949
To just update versions you can use release:update-versions
and then commit manually.
The documentation also lists the suppressCommitBeforeTag
option for release:prepare
, which sounds like it should prevent committing.
Upvotes: 1