@@ -89,6 +89,12 @@ public class GitFlowFeatureFinishMojo extends AbstractGitFlowMojo {
8989 @ Parameter (property = "postFeatureFinishGoals" )
9090 private String postFeatureFinishGoals ;
9191
92+ /**
93+ * Whether to increment the version during feature-finish goal.
94+ *
95+ */
96+ @ Parameter (property = "incrementVersionAtFinish" , defaultValue = "false" )
97+ private boolean incrementVersionAtFinish ;
9298
9399 /** {@inheritDoc} */
94100 @ Override
@@ -138,12 +144,26 @@ public void execute() throws MojoExecutionException, MojoFailureException {
138144 mvnRun (preFeatureFinishGoals );
139145 }
140146
141- final String currentFeatureVersion = getCurrentProjectVersion ();
147+ String featureVersion = getCurrentProjectVersion ();
142148
143149 final String featName = featureBranchName .replaceFirst (gitFlowConfig .getFeatureBranchPrefix (), "" );
144150
145- if (currentFeatureVersion .contains ("-" + featName )) {
146- final String version = currentFeatureVersion .replaceFirst ("-" + featName , "" );
151+ if (incrementVersionAtFinish ) {
152+ GitFlowVersionInfo developVersionInfo = new GitFlowVersionInfo (featureVersion );
153+ featureVersion = developVersionInfo .nextSnapshotVersion ();
154+
155+ mvnSetVersions (featureVersion );
156+
157+ Map <String , String > properties = new HashMap <String , String >();
158+ properties .put ("version" , featureVersion );
159+ properties .put ("featureName" , featName );
160+ gitCommit (commitMessages .getFeatureFinishIncrementVersionMessage (), properties );
161+ }
162+
163+ final String keptFeatureVersion = featureVersion ;
164+
165+ if (keptFeatureVersion .contains ("-" + featName )) {
166+ final String version = keptFeatureVersion .replaceFirst ("-" + featName , "" );
147167
148168 // mvn versions:set -DnewVersion=... -DgenerateBackupPoms=false
149169 mvnSetVersions (version );
@@ -181,10 +201,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
181201 if (keepBranch ) {
182202 gitCheckout (featureBranchName );
183203
184- mvnSetVersions (currentFeatureVersion );
204+ mvnSetVersions (keptFeatureVersion );
185205
186206 Map <String , String > properties = new HashMap <String , String >();
187- properties .put ("version" , currentFeatureVersion );
207+ properties .put ("version" , keptFeatureVersion );
188208 properties .put ("featureName" , featName );
189209
190210 gitCommit (commitMessages .getUpdateFeatureBackMessage (), properties );
0 commit comments