From cf638986ab5f902a24f919c9523aa58c653d6a58 Mon Sep 17 00:00:00 2001 From: Michael Musenbrock Date: Tue, 21 Sep 2021 17:46:15 +0200 Subject: [PATCH] Add support for changelist property per branch for maven ci friendly versioning - closes #314 --- README.md | 12 + .../plugin/gitflow/AbstractGitFlowMojo.java | 243 +++++++++++++++++- .../maven/plugin/gitflow/BranchType.java | 5 + .../gitflow/GitFlowFeatureFinishMojo.java | 6 +- .../gitflow/GitFlowFeatureStartMojo.java | 3 +- .../gitflow/GitFlowHotfixFinishMojo.java | 12 +- .../gitflow/GitFlowHotfixStartMojo.java | 12 +- .../gitflow/GitFlowReleaseFinishMojo.java | 12 +- .../plugin/gitflow/GitFlowReleaseMojo.java | 6 +- .../gitflow/GitFlowReleaseStartMojo.java | 6 +- .../gitflow/GitFlowSupportStartMojo.java | 2 +- 11 files changed, 289 insertions(+), 30 deletions(-) create mode 100644 src/main/java/com/amashchenko/maven/plugin/gitflow/BranchType.java diff --git a/README.md b/README.md index dda928fe..626aacf3 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,18 @@ The `skipUpdateVersion` parameter can be used to skip updating `` in th To support [CI friendly versioning](https://maven.apache.org/maven-ci-friendly.html) in projects which use `${revision}` set `versionProperty` to `revision` and `skipUpdateVersion` to `true`. +### CI friendly in dependencies/multi module + +Projects which additionally use the `changelist` property in the version (`${revision}${changelist}`) and refer to it via `${project.version}` in dependencies are supported as well. + +As the different steps of the plugin running on different branches, different values for `changelist` may be needed to successfully resolve the dependencies. + +To set different values to `changelist` per branch the properties `productionChangelistValue`, `hotfixChangelistValue`, `releaseChangelistValue`, `developmentChangelistValue`, `featureChangelistValue`, `supportChangelistValue` are used. + +As example for the `gitflow:hotfix-finish` the following properties may be used (setting `developmentChangelistValue` done explicit for better understanding): + + mvn gitflow:hotfix-finish -DhotfixVersion=x.y.z -DproductionChangelistValue='' -DhotfixChangelistValue='' -DdevelopmentChangelistValue='-SNAPSHOT' + ## Additional goal parameters The `gitflow:release-finish`, `gitflow:release` and `gitflow:hotfix-finish` goals have `skipTag` parameter. This parameter controls whether the release/hotfix will be tagged in Git. 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 98fb03dc..3fc46e2a 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Properties; import java.util.TimeZone; import java.util.regex.Pattern; @@ -30,6 +31,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; @@ -91,7 +93,7 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { */ @Parameter(defaultValue = "false") protected boolean tychoBuild; - + /** * Whether to call Maven install goal during the mojo execution. * @@ -124,6 +126,12 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { @Parameter(property = "argLine") private String argLine; + /** + * Stores the branch specific maven arguments. + * Gets set if branch based properties are requested and appended to the maven commands. + */ + private String mvnArgsBranchSpecific = ""; + /** * Whether to make a GPG-signed commit. * @@ -149,6 +157,70 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { @Parameter(property = "versionProperty") private String versionProperty; + /** + * Property to treat as changelist property. + * Used for Maven CI friendly versioning handling. Only relevant in conjunction + * with the xxxChangelistValue's. + * + * @since 1.17.0 + */ + @Parameter(property = "changelistProperty", defaultValue = "changelist") + private String changelistProperty; + + /** + * The value to pass as changelist value when running on the + * production branch. + * + * @since 1.17.0 + */ + @Parameter(property = "productionChangelistValue") + private String productionChangelistValue; + + /** + * The value to pass as changelist value when running on the + * hotfix branch. + * + * @since 1.17.0 + */ + @Parameter(property = "hotfixChangelistValue") + private String hotfixChangelistValue; + + /** + * The value to pass as changelist value when running on the + * release branch. + * + * @since 1.17.0 + */ + @Parameter(property = "releaseChangelistValue") + private String releaseChangelistValue; + + /** + * The value to pass as changelist value when running on the + * development branch. + * + * @since 1.17.0 + */ + @Parameter(property = "developmentChangelistValue") + private String developmentChangelistValue; + + /** + * The value to pass as changelist value when running on the + * feature branch. + * + * @since 1.17.0 + */ + @Parameter(property = "featureChangelistValue") + private String featureChangelistValue; + + /** + * The value to pass as changelist value when running on the + * support branch. + * + * @since 1.17.0 + */ + @Parameter(property = "supportChangelistValue") + private String supportChangelistValue; + /** * Whether to skip updating version. Useful with {@link #versionProperty} to be * able to update revision property without modifying version tag. @@ -171,6 +243,7 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { */ @Parameter(property = "mvnExecutable") private String mvnExecutable; + /** * The path to the Git executable. Defaults to "git". */ @@ -191,7 +264,7 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { @Component protected ProjectBuilder projectBuilder; - + /** Default prompter. */ @Component protected Prompter prompter; @@ -611,7 +684,7 @@ protected boolean gitCheckTagExists(final String tagName) throws MojoFailureExce * @throws MojoFailureException * @throws CommandLineException */ - protected void gitCheckout(final String branchName) + private void gitCheckout(final String branchName) throws MojoFailureException, CommandLineException { getLog().info("Checking out '" + branchName + "' branch."); @@ -628,7 +701,7 @@ protected void gitCheckout(final String branchName) * @throws MojoFailureException * @throws CommandLineException */ - protected void gitCreateAndCheckout(final String newBranchName, + private void gitCreateAndCheckout(final String newBranchName, final String fromBranchName) throws MojoFailureException, CommandLineException { getLog().info( @@ -1188,7 +1261,8 @@ private void executeGitCommand(final String... args) */ private void executeMvnCommand(final String... args) throws CommandLineException, MojoFailureException { - executeCommand(cmdMvn, true, argLine, args); + final String argLineWithBranchSpecifics = joinStrings(argLine, mvnArgsBranchSpecific); + executeCommand(cmdMvn, true, argLineWithBranchSpecifics, args); } /** @@ -1289,4 +1363,163 @@ public String getError() { public void setArgLine(String argLine) { this.argLine = argLine; } + + /** + * Executes git checkout and sets Maven CI friendly settings per branch. + * + * @param branchType + * Type of branch to set config for. + * @param branchName + * Branch name to checkout. + * @throws MojoExecutionException an internal error occurred + * @throws MojoFailureException an error with the underlying commands occurred + * @throws CommandLineException an error with the underlying commands occurred + */ + protected void checkoutAndSetConfigForBranch(final BranchType branchType, final String branchName) + throws MojoExecutionException, MojoFailureException, CommandLineException { + if (branchType == null) { + throw new MojoExecutionException("INTERNAL: given BranchType is null"); + } + + gitCheckout(branchName); + setConfigForBranchType(branchType); + } + + /** + * Executes git checkout -b and sets Maven CI friendly settings per branch. + * + * @param branchType + * Type of branch to set config for. + * @param newBranchName + * Create branch with this name. + * @param fromBranchName + * Create branch from this branch. + * @throws MojoExecutionException an internal error occurred + * @throws MojoFailureException an error with the underlying commands occurred + * @throws CommandLineException an error with the underlying commands occurred + */ + protected void createAndCheckoutAndSetConfigForBranch(final BranchType branchType, final String newBranchName, + final String fromBranchName) throws MojoExecutionException, MojoFailureException, CommandLineException { + if (branchType == null) { + throw new MojoExecutionException("INTERNAL: given BranchType is null"); + } + + gitCreateAndCheckout(newBranchName, fromBranchName); + setConfigForBranchType(branchType); + } + + /** + * Sets Maven CI friendly settings dependent of the type of branch. + * This includes settings passed to the maven commands in executeMvnCommand and manipulates + * the user properties inside the MavenSession, to guarantee that internal mvn commands + * via e.g. ProjectBuilder.build also uses the correct properties. + * + * @param branchType + * Type of branch to set config for. + * @throws MojoExecutionException an internal error occurred + */ + protected void setConfigForBranchType(final BranchType branchType) throws MojoExecutionException { + if (branchType == null) { + throw new MojoExecutionException("INTERNAL: given BranchType is null"); + } + + final boolean noChangelistValueToBeModified = productionChangelistValue == null + && hotfixChangelistValue == null && releaseChangelistValue == null + && developmentChangelistValue == null && featureChangelistValue == null + && supportChangelistValue == null; + + if (StringUtils.isBlank(changelistProperty) || noChangelistValueToBeModified) { + return; + } + + final String changelistValue; + + switch (branchType) { + case PRODUCTION: + changelistValue = productionChangelistValue; + break; + case HOTFIX: + changelistValue = hotfixChangelistValue; + break; + case RELEASE: + changelistValue = releaseChangelistValue; + break; + case DEVELOPMENT: + changelistValue = developmentChangelistValue; + break; + case FEATURE: + changelistValue = featureChangelistValue; + break; + case SUPPORT: + changelistValue = supportChangelistValue; + break; + default: + throw new MojoExecutionException("INTERNAL: unhandled case for branchType value: " + branchType); + } + + setPropertyInProperties(changelistProperty, changelistValue, mavenSession.getProjectBuildingRequest().getUserProperties()); + mvnArgsBranchSpecific = getJavaPropertyAsArgLineString(changelistProperty, changelistValue); + } + + /** + * Sets a property in the given Properties. + * + * @param key + * The key of the property to set. + * @param value + * The value of the property to set, if null, the property gets removed. + * @param properties + * The properties where to replace the entry. + */ + private void setPropertyInProperties(final String key, final String value, final Properties properties) { + if (StringUtils.isBlank(key) || properties == null) { + return; + } + + if (value == null) { + properties.remove(key); + } else { + properties.put(key, value); + } + } + + /** + * Retrieve a string representation of a java property defined by key/value. + * + * @param key + * The key of the property to set. + * @param value + * The value of the property to set, if null, an empty string is returned. + * @return + * A string representation to be used as java argument. + * Empty if key is null or empty, or the value is null. + */ + private String getJavaPropertyAsArgLineString(final String key, final String value) { + if (StringUtils.isBlank(key) || value == null) { + return ""; + } else { + return "-D" + key + "=" + value; + } + } + + /** + * Join two String's with a space. + * Both String's can be null. And always a non-null value is returned. + * + * @param a + * The first string, where the second gets appended to. null is treated as empty. + * @param b + * The second string, which gets appended to the first one. null is treated as empty. + * @return + * The combined string, if both strings are null or empty, an empty String is returned. + */ + private String joinStrings(final String a, final String b) { + if (StringUtils.isBlank(a)) { + return StringUtils.clean(b); + } else if (StringUtils.isBlank(b)) { + return StringUtils.clean(a); + } else { + return a + " " + b; + } + } } diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/BranchType.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/BranchType.java new file mode 100644 index 00000000..bca11b39 --- /dev/null +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/BranchType.java @@ -0,0 +1,5 @@ +package com.amashchenko.maven.plugin.gitflow; + +public enum BranchType { + PRODUCTION, DEVELOPMENT, FEATURE, RELEASE, HOTFIX, SUPPORT; +} 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 45bb81bd..d11bd714 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureFinishMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureFinishMojo.java @@ -149,7 +149,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (!skipTestProject) { // git checkout feature/... - gitCheckout(featureBranchName); + checkoutAndSetConfigForBranch(BranchType.FEATURE, featureBranchName); // mvn clean test mvnCleanTest(); @@ -196,7 +196,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } // git checkout develop - gitCheckout(gitFlowConfig.getDevelopmentBranch()); + checkoutAndSetConfigForBranch(BranchType.DEVELOPMENT, gitFlowConfig.getDevelopmentBranch()); if (featureSquash) { // git merge --squash feature/... @@ -222,7 +222,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if (keepBranch) { - gitCheckout(featureBranchName); + checkoutAndSetConfigForBranch(BranchType.FEATURE, featureBranchName); mvnSetVersions(keptFeatureVersion); 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 efcf55f3..63e98792 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureStartMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowFeatureStartMojo.java @@ -120,7 +120,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { } // git checkout -b ... develop - gitCreateAndCheckout( + createAndCheckoutAndSetConfigForBranch( + BranchType.FEATURE, gitFlowConfig.getFeatureBranchPrefix() + featureBranchName, gitFlowConfig.getDevelopmentBranch()); 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 3ddd1ec9..50679ae1 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java @@ -192,7 +192,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } // git checkout hotfix/... - gitCheckout(hotfixBranchName); + checkoutAndSetConfigForBranch(BranchType.HOTFIX, hotfixBranchName); if (!skipTestProject) { // mvn clean test @@ -220,12 +220,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if (supportBranchName != null) { - gitCheckout(supportBranchName); + checkoutAndSetConfigForBranch(BranchType.SUPPORT, supportBranchName); // git merge --no-ff hotfix/... gitMergeNoff(hotfixBranchName, commitMessages.getHotfixFinishSupportMergeMessage(), messageProperties); } else if (!skipMergeProdBranch) { // git checkout master - gitCheckout(gitFlowConfig.getProductionBranch()); + checkoutAndSetConfigForBranch(BranchType.PRODUCTION, gitFlowConfig.getProductionBranch()); // git merge --no-ff hotfix/... gitMergeNoff(hotfixBranchName, commitMessages.getHotfixFinishMergeMessage(), messageProperties); } @@ -249,7 +249,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (skipMergeProdBranch && (supportBranchName == null)) { // switch to production branch so hotfix branch can be deleted - gitCheckout(gitFlowConfig.getProductionBranch()); + checkoutAndSetConfigForBranch(BranchType.PRODUCTION, gitFlowConfig.getProductionBranch()); } // maven goals after merge @@ -267,7 +267,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // if release branch exists merge hotfix changes into it if (StringUtils.isNotBlank(releaseBranch)) { // git checkout release - gitCheckout(releaseBranch); + checkoutAndSetConfigForBranch(BranchType.RELEASE, releaseBranch); String releaseBranchVersion = getCurrentProjectVersion(); if (!currentVersion.equals(releaseBranchVersion)) { @@ -291,7 +291,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { currentVersion); if (notSameProdDevName()) { // git checkout develop - gitCheckout(gitFlowConfig.getDevelopmentBranch()); + checkoutAndSetConfigForBranch(BranchType.DEVELOPMENT, gitFlowConfig.getDevelopmentBranch()); developVersionInfo = new GitFlowVersionInfo(getCurrentProjectVersion()); 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 83eb3b99..07ea3f64 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixStartMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixStartMojo.java @@ -91,6 +91,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { checkUncommittedChanges(); String branchName = gitFlowConfig.getProductionBranch(); + BranchType branchType = BranchType.PRODUCTION; // find support branches final String supportBranchesStr = gitFindBranches(gitFlowConfig.getSupportBranchPrefix(), false); @@ -134,6 +135,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (branchNumber != null) { int num = Integer.parseInt(branchNumber); branchName = branches[num - 1]; + branchType = BranchType.SUPPORT; } if (StringUtils.isBlank(branchName)) { @@ -141,8 +143,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } } else if (StringUtils.isNotBlank(fromBranch)) { - if (fromBranch.equals(gitFlowConfig.getProductionBranch()) || contains(supportBranches, fromBranch)) { + if (fromBranch.equals(gitFlowConfig.getProductionBranch())) { branchName = fromBranch; + branchType = BranchType.PRODUCTION; + } else if (contains(supportBranches, fromBranch)) { + branchName = fromBranch; + branchType = BranchType.SUPPORT; } else { throw new MojoFailureException("The fromBranch is not production or support branch."); } @@ -150,7 +156,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // need to be in master to get correct project version // git checkout master - gitCheckout(branchName); + checkoutAndSetConfigForBranch(branchType, branchName); // fetch and check remote if (fetchRemote) { @@ -222,7 +228,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } // git checkout -b hotfix/... master - gitCreateAndCheckout(hotfixBranchName, branchName); + createAndCheckoutAndSetConfigForBranch(BranchType.HOTFIX, hotfixBranchName, branchName); // execute if version changed if (!version.equals(currentVersion)) { 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 03c684a8..57539fa0 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java @@ -195,7 +195,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { "More than one remote release branch exists. Cannot finish release."); } - gitCreateAndCheckout(releaseBranch, gitFlowConfig.getOrigin() + "/" + releaseBranch); + createAndCheckoutAndSetConfigForBranch( + BranchType.RELEASE, releaseBranch, + gitFlowConfig.getOrigin() + "/" + releaseBranch); } else { throw new MojoFailureException("There is no release branch."); } @@ -207,7 +209,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // check snapshots dependencies if (!allowSnapshots) { - gitCheckout(releaseBranch); + checkoutAndSetConfigForBranch(BranchType.RELEASE, releaseBranch); checkSnapshotDependencies(); } @@ -233,7 +235,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } // git checkout release/... - gitCheckout(releaseBranch); + checkoutAndSetConfigForBranch(BranchType.RELEASE, releaseBranch); if (!skipTestProject) { // mvn clean test @@ -262,7 +264,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (!skipReleaseMergeProdBranch) { // git checkout master - gitCheckout(gitFlowConfig.getProductionBranch()); + checkoutAndSetConfigForBranch(BranchType.PRODUCTION, gitFlowConfig.getProductionBranch()); gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF, releaseMergeFFOnly, commitMessages.getReleaseFinishMergeMessage(), messageProperties); @@ -292,7 +294,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (notSameProdDevName()) { // git checkout develop - gitCheckout(gitFlowConfig.getDevelopmentBranch()); + checkoutAndSetConfigForBranch(BranchType.DEVELOPMENT, gitFlowConfig.getDevelopmentBranch()); // get develop version final String developReleaseVersion = getCurrentProjectVersion(); 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 29cdc528..ababfe2d 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java @@ -196,7 +196,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // need to be in develop to check snapshots and to get correct // project version // git checkout develop - gitCheckout(gitFlowConfig.getDevelopmentBranch()); + checkoutAndSetConfigForBranch(BranchType.DEVELOPMENT, gitFlowConfig.getDevelopmentBranch()); // check snapshots dependencies if (!allowSnapshots) { @@ -269,7 +269,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (!skipReleaseMergeProdBranch && notSameProdDevName()) { // git checkout master - gitCheckout(gitFlowConfig.getProductionBranch()); + checkoutAndSetConfigForBranch(BranchType.PRODUCTION, gitFlowConfig.getProductionBranch()); gitMerge(gitFlowConfig.getDevelopmentBranch(), releaseRebase, releaseMergeNoFF, releaseMergeFFOnly, commitMessages.getReleaseFinishMergeMessage(), @@ -295,7 +295,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (notSameProdDevName()) { // git checkout develop - gitCheckout(gitFlowConfig.getDevelopmentBranch()); + checkoutAndSetConfigForBranch(BranchType.DEVELOPMENT, gitFlowConfig.getDevelopmentBranch()); } // get next snapshot version 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 899c31b2..973d0315 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseStartMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseStartMojo.java @@ -177,7 +177,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // need to be in develop to check snapshots and to get // correct project version - gitCheckout(startPoint); + checkoutAndSetConfigForBranch(BranchType.DEVELOPMENT, startPoint); // check snapshots dependencies if (!allowSnapshots) { @@ -231,10 +231,10 @@ public void execute() throws MojoExecutionException, MojoFailureException { commitProjectVersion(nextSnapshotVersion, commitMessages.getReleaseVersionUpdateMessage()); // git checkout release/... - gitCheckout(fullBranchName); + checkoutAndSetConfigForBranch(BranchType.RELEASE, fullBranchName); } else { // git checkout -b release/... develop - gitCreateAndCheckout(fullBranchName, startPoint); + createAndCheckoutAndSetConfigForBranch(BranchType.RELEASE, fullBranchName, startPoint); // mvn versions:set ... // git commit -a -m ... diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowSupportStartMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowSupportStartMojo.java index 20bce91c..d8b42ea9 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowSupportStartMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowSupportStartMojo.java @@ -124,7 +124,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } // git checkout -b ... tag - gitCreateAndCheckout(gitFlowConfig.getSupportBranchPrefix() + branchName, tag); + createAndCheckoutAndSetConfigForBranch(BranchType.SUPPORT, gitFlowConfig.getSupportBranchPrefix() + branchName, tag); if (useSnapshotInSupport) { String version = getCurrentProjectVersion();