From ecd0b2e013e35f52379894d76e04a074c8a23827 Mon Sep 17 00:00:00 2001 From: Aleksandr Mashchenko Date: Thu, 17 Dec 2015 22:33:44 +0200 Subject: [PATCH] Closes #8 - Enable to customize commit messages --- .../plugin/gitflow/AbstractGitFlowMojo.java | 4 + .../maven/plugin/gitflow/CommitMessages.java | 170 ++++++++++++++++++ .../gitflow/GitFlowFeatureFinishMojo.java | 2 +- .../gitflow/GitFlowFeatureStartMojo.java | 2 +- .../gitflow/GitFlowHotfixFinishMojo.java | 4 +- .../gitflow/GitFlowHotfixStartMojo.java | 2 +- .../gitflow/GitFlowReleaseFinishMojo.java | 4 +- .../plugin/gitflow/GitFlowReleaseMojo.java | 6 +- .../gitflow/GitFlowReleaseStartMojo.java | 2 +- 9 files changed, 185 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/amashchenko/maven/plugin/gitflow/CommitMessages.java diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java index fbec5b35..2f1f70c0 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -63,6 +63,10 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { @Parameter(defaultValue = "${gitFlowConfig}") protected GitFlowConfig gitFlowConfig; + /** Git commit messages. */ + @Parameter(defaultValue = "${commitMessages}") + protected CommitMessages commitMessages; + /** Whether this is Tycho build. */ @Parameter(defaultValue = "false") protected boolean tychoBuild; diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/CommitMessages.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/CommitMessages.java new file mode 100644 index 00000000..df4a785a --- /dev/null +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/CommitMessages.java @@ -0,0 +1,170 @@ +/* + * Copyright 2014-2015 Aleksandr Mashchenko. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.amashchenko.maven.plugin.gitflow; + +/** + * Git commit messages. + * + * @author Aleksandr Mashchenko + * + */ +public class CommitMessages { + private String featureStartMessage; + private String featureFinishMessage; + + private String hotfixStartMessage; + private String hotfixFinishMessage; + + private String releaseStartMessage; + private String releaseFinishMessage; + + private String tagHotfixMessage; + private String tagReleaseMessage; + + public CommitMessages() { + featureStartMessage = "updating versions for feature branch"; + featureFinishMessage = "updating versions for development branch"; + + hotfixStartMessage = "updating versions for hotfix"; + hotfixFinishMessage = "updating for next development version"; + + releaseStartMessage = "updating versions for release"; + releaseFinishMessage = "updating for next development version"; + + tagHotfixMessage = "tagging hotfix"; + tagReleaseMessage = "tagging release"; + } + + /** + * @return the featureStartMessage + */ + public String getFeatureStartMessage() { + return featureStartMessage; + } + + /** + * @param featureStartMessage + * the featureStartMessage to set + */ + public void setFeatureStartMessage(String featureStartMessage) { + this.featureStartMessage = featureStartMessage; + } + + /** + * @return the featureFinishMessage + */ + public String getFeatureFinishMessage() { + return featureFinishMessage; + } + + /** + * @param featureFinishMessage + * the featureFinishMessage to set + */ + public void setFeatureFinishMessage(String featureFinishMessage) { + this.featureFinishMessage = featureFinishMessage; + } + + /** + * @return the hotfixStartMessage + */ + public String getHotfixStartMessage() { + return hotfixStartMessage; + } + + /** + * @param hotfixStartMessage + * the hotfixStartMessage to set + */ + public void setHotfixStartMessage(String hotfixStartMessage) { + this.hotfixStartMessage = hotfixStartMessage; + } + + /** + * @return the hotfixFinishMessage + */ + public String getHotfixFinishMessage() { + return hotfixFinishMessage; + } + + /** + * @param hotfixFinishMessage + * the hotfixFinishMessage to set + */ + public void setHotfixFinishMessage(String hotfixFinishMessage) { + this.hotfixFinishMessage = hotfixFinishMessage; + } + + /** + * @return the releaseStartMessage + */ + public String getReleaseStartMessage() { + return releaseStartMessage; + } + + /** + * @param releaseStartMessage + * the releaseStartMessage to set + */ + public void setReleaseStartMessage(String releaseStartMessage) { + this.releaseStartMessage = releaseStartMessage; + } + + /** + * @return the releaseFinishMessage + */ + public String getReleaseFinishMessage() { + return releaseFinishMessage; + } + + /** + * @param releaseFinishMessage + * the releaseFinishMessage to set + */ + public void setReleaseFinishMessage(String releaseFinishMessage) { + this.releaseFinishMessage = releaseFinishMessage; + } + + /** + * @return the tagHotfixMessage + */ + public String getTagHotfixMessage() { + return tagHotfixMessage; + } + + /** + * @param tagHotfixMessage + * the tagHotfixMessage to set + */ + public void setTagHotfixMessage(String tagHotfixMessage) { + this.tagHotfixMessage = tagHotfixMessage; + } + + /** + * @return the tagReleaseMessage + */ + public String getTagReleaseMessage() { + return tagReleaseMessage; + } + + /** + * @param tagReleaseMessage + * the tagReleaseMessage to set + */ + public void setTagReleaseMessage(String tagReleaseMessage) { + this.tagReleaseMessage = tagReleaseMessage; + } +} diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureFinishMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureFinishMojo.java index edc813b3..f713392f 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureFinishMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureFinishMojo.java @@ -118,7 +118,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(version); // git commit -a -m updating versions for development branch - gitCommit("updating versions for development branch"); + gitCommit(commitMessages.getFeatureFinishMessage()); } if (installProject) { diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureStartMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureStartMojo.java index 6848b2db..3705fd2b 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureStartMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureStartMojo.java @@ -100,7 +100,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(version); // git commit -a -m updating versions for feature branch - gitCommit("updating versions for feature branch"); + gitCommit(commitMessages.getFeatureStartMessage()); } } diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java index 48639c50..d66dd3a0 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java @@ -121,7 +121,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // git tag -a ... gitTag(gitFlowConfig.getVersionTagPrefix() + tagVersion, - "tagging hotfix"); + commitMessages.getTagHotfixMessage()); } // check whether release branch exists @@ -168,7 +168,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(nextSnapshotVersion); // git commit -a -m updating for next development version - gitCommit("updating for next development version"); + gitCommit(commitMessages.getHotfixFinishMessage()); } if (installProject) { diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixStartMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixStartMojo.java index a7d418bf..6dc4a334 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixStartMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixStartMojo.java @@ -105,7 +105,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(version); // git commit -a -m updating versions for hotfix - gitCommit("updating versions for hotfix"); + gitCommit(commitMessages.getHotfixStartMessage()); } if (installProject) { diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java index 35f95f71..fc6abb9d 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java @@ -92,7 +92,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // git tag -a ... gitTag(gitFlowConfig.getVersionTagPrefix() + tagVersion, - "tagging release"); + commitMessages.getTagReleaseMessage()); } // git checkout develop @@ -123,7 +123,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(nextSnapshotVersion); // git commit -a -m updating for next development version - gitCommit("updating for next development version"); + gitCommit(commitMessages.getReleaseFinishMessage()); if (installProject) { // mvn clean install diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java index 593ccbdb..755ae412 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java @@ -116,7 +116,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(version); // git commit -a -m updating versions for release - gitCommit("updating versions for release"); + gitCommit(commitMessages.getReleaseStartMessage()); } // git checkout master @@ -133,7 +133,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // git tag -a ... gitTag(gitFlowConfig.getVersionTagPrefix() + version, - "tagging release"); + commitMessages.getTagReleaseMessage()); } // git checkout develop @@ -161,7 +161,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(nextSnapshotVersion); // git commit -a -m updating for next development version - gitCommit("updating for next development version"); + gitCommit(commitMessages.getReleaseFinishMessage()); if (installProject) { // mvn clean install diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseStartMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseStartMojo.java index e521677b..243601be 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseStartMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseStartMojo.java @@ -123,7 +123,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { mvnSetVersions(version); // git commit -a -m updating versions for release - gitCommit("updating versions for release"); + gitCommit(commitMessages.getReleaseStartMessage()); } if (installProject) {