Skip to content

Commit 54e19b8

Browse files
committed
Glad I caught this before release
1 parent 2b755bd commit 54e19b8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ In practice, the Maven versions should:
9696
The `enforce-versions` goal asserts these semantics when it can resolve the `gitBranchExpression`.
9797

9898
The goal accomplishes this by checking the Maven pom.xml version value, and asserting the -SNAPSHOT status, as well as matching the current branch name
99-
against regular expressions, extracting version numbers from the branch names where applicable. If a regex specifies a subgroup 1, the content of that
100-
subgroup is asserted to equal the version defined in the pom.xml.
99+
against regular expressions, extracting version numbers from the branch names where applicable. If a regex specifies subgroups, the content of the
100+
last subgroup is asserted to equal the version defined in the pom.xml.
101101

102102
The following properties change the behavior of this goal:
103103

104104
| Property | Default Value | SNAPSHOT allowed? | Description |
105105
| -------------------- | ------------- | --------------------------- | ----------- |
106106
| gitBranchExpression | current git branch resolved from SCM or ${env.GIT_BRANCH} | n/a | Maven property expression to resolve in order to determine the current git branch |
107107
| masterBranchPattern | origin/master | No | Regex. When matched, signals the master branch is being built. Note the lack of a subgroup. |
108-
| releaseBranchPattern | origin/release/(.*) | No | Regex. When matched, signals a release branch being built. Subgroup 1, if present, must match the Maven project version. |
109-
| hotfixBranchPattern | origin/hotfix/(.*) | No | Regex. When matched, signals a hotfix branch is being built. Subgroup 1, if present, must match the Maven project version. |
108+
| releaseBranchPattern | origin/release/(.*) | No | Regex. When matched, signals a release branch being built. Last subgroup, if present, must match the Maven project version. |
109+
| hotfixBranchPattern | origin/hotfix/(.*) | No | Regex. When matched, signals a hotfix branch is being built. Last subgroup, if present, must match the Maven project version. |
110110
| developmentBranchPattern | origin/develop | Yes | Regex. When matched, signals a development branch is being built. Note the lack of a subgroup. |
111111

112112
## Goal: `retarget-deploy` (Branch Specific Deploy Targets & Staging)

src/main/java/com/e_gineering/maven/gitflowhelper/EnforceVersionsMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ protected void execute(final GitBranchType type, final String gitBranch, final S
2828
throw new MojoFailureException("The current git branch: [" + gitBranch + "] is defined as a release branch. The maven project version: [" + project.getVersion() + "] is currently a snapshot version.");
2929
}
3030

31-
// Expect the last group to match (exactly) the current projectVersion.
32-
if (gitMatcher.groupCount() > 0) {
31+
// Expect the last group on non-master branches to match (exactly) the current projectVersion. (only release / hotfix branches)
32+
if (gitMatcher.groupCount() > 0 && !GitBranchType.MASTER.equals(type)) {
3333
if (!gitMatcher.group(gitMatcher.groupCount()).trim().equals(project.getVersion().trim())) {
3434
throw new MojoFailureException("The current git branch: [" + gitBranch + "] expected the maven project version to be: [" + gitMatcher.group(gitMatcher.groupCount()).trim() + "], but the maven project version is: [" + project.getVersion() + "]");
3535
}

0 commit comments

Comments
 (0)