Skip to content

Commit dab3167

Browse files
committed
I had too much fun with this branch name.
1 parent 45da3ec commit dab3167

File tree

9 files changed

+38
-7
lines changed

9 files changed

+38
-7
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public abstract class AbstractGitflowBranchMojo extends AbstractMojo {
3333
@Parameter(defaultValue = "(origin/)?master", property = "masterBranchPattern", required = true)
3434
private String masterBranchPattern;
3535

36+
@Parameter(defaultValue = "(origin/)?support/(.*)", property = "supportBranchPattern", required = true)
37+
private String supportBranchPattern;
38+
3639
@Parameter(defaultValue = "(origin/)?release/(.*)", property = "releaseBranchPattern", required = true)
3740
private String releaseBranchPattern;
3841

@@ -91,6 +94,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9194
*/
9295
if (gitBranch.matches(masterBranchPattern)) {
9396
logExecute(GitBranchType.MASTER, gitBranch, masterBranchPattern);
97+
} else if (gitBranch.matches(supportBranchPattern)) {
98+
logExecute(GitBranchType.SUPPORT, gitBranch, supportBranchPattern);
9499
} else if (gitBranch.matches(releaseBranchPattern)) {
95100
logExecute(GitBranchType.RELEASE, gitBranch, releaseBranchPattern);
96101
} else if (gitBranch.matches(hotfixBranchPattern)) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public class AttachDeployedArtifactsMojo extends AbstractGitflowBasedRepositoryM
1616
@Override
1717
protected void execute(GitBranchType type, String gitBranch, String branchPattern) throws MojoExecutionException, MojoFailureException {
1818
switch (type) {
19-
case MASTER: {
19+
case MASTER:
20+
case SUPPORT:
21+
{
2022
getLog().info("Attaching artifacts from release repository...");
2123
attachExistingArtifacts(releaseDeploymentRepository, true);
2224
break;

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 on non-master branches to match (exactly) the current projectVersion. (only release / hotfix branches)
32-
if (gitMatcher.groupCount() > 0 && !GitBranchType.MASTER.equals(type)) {
31+
// Expect the last group on non-master (and non-support) branches to match (exactly) the current projectVersion. (only release / hotfix branches)
32+
if (gitMatcher.groupCount() > 0 && !(GitBranchType.MASTER.equals(type) || GitBranchType.SUPPORT.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
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
*/
88
public enum GitBranchType {
99
MASTER,
10+
SUPPORT,
1011
RELEASE,
1112
HOTFIX,
1213
DEVELOPMENT,
1314
OTHER,
1415
UNDEFINED;
1516

16-
static final EnumSet<GitBranchType> VERSIONED_TYPES = EnumSet.of(GitBranchType.MASTER, GitBranchType.RELEASE, GitBranchType.HOTFIX);
17+
static final EnumSet<GitBranchType> VERSIONED_TYPES = EnumSet.of(GitBranchType.MASTER, GitBranchType.SUPPORT, GitBranchType.RELEASE, GitBranchType.HOTFIX);
1718
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
6565
try {
6666
pluginsToRetain.add(descriptorCreator.findPluginForPrefix(prefix, session));
6767
} catch (NoPluginFoundForPrefixException ex) {
68-
throw new MavenExecutionException("Unable to resolve plugin for prefix: " + prefix, ex);
68+
logger.warn("gitflow-helper-maven-plugin: Unable to resolve project plugin for prefix: " + prefix + " for goal: " + goal);
69+
// throw new MavenExecutionException("Unable to resolve plugin for prefix: " + prefix, ex);
6970
}
7071
}
7172
}
@@ -128,7 +129,10 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
128129
logger.info("gitflow-helper-maven-plugin: Enabling MasterPromoteExtension. GIT_BRANCH: [" + gitBranch + "] matches masterBranchPattern: [" + masterBranchPattern + "]");
129130

130131
for (MavenProject project : session.getProjects()) {
131-
// Drop all the plugins from the build except for the gitflow-helper-maven-plugin.
132+
// Drop all the plugins from the build except for the gitflow-helper-maven-plugin, or plugins we
133+
// invoked goals for which could be mapped back to plugins in our project build.
134+
// Goals invoked from the commandline which cannot be mapped back to our project, will get warnings, but should still execute.
135+
// If someone is on 'master' and starts executing goals, we need to allow them to do that.
132136
project.getBuildPlugins().removeAll(pluginsToDrop.get(project));
133137
}
134138
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ protected void execute(final GitBranchType type, final String gitBranch, final S
2828
break;
2929
}
3030

31+
case SUPPORT:
3132
case MASTER: {
3233
getLog().info("Resolving & Reattaching existing artifacts from stageDeploymentRepository [" + stageDeploymentRepository + "]");
3334

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ protected void execute(final GitBranchType type, final String gitBranch, final S
1818
}
1919

2020
switch (type) {
21+
case SUPPORT:
2122
case MASTER: {
2223
getLog().info("Setting release artifact repository to: [" + releaseDeploymentRepository + "]");
2324
project.setSnapshotArtifactRepository(null);

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ public class SetPropertiesMojo extends AbstractGitflowBranchMojo {
3030
@Parameter(property = "masterBranchPropertyFile")
3131
private File masterBranchPropertyFile;
3232

33+
/**
34+
* Properties to be applied if executing against a support branch
35+
*/
36+
@Parameter(property = "supportBranchProperties")
37+
private Properties supportBranchProperties;
38+
39+
/**
40+
* A Property file to load if executing against the support branch
41+
*/
42+
@Parameter(property = "supportBranchPropertyFile")
43+
private File supportBranchPropertyFile;
44+
3345
/**
3446
* Properties to be applied if executing against a release branch
3547
*/
@@ -114,6 +126,11 @@ protected void execute(final GitBranchType type, final String gitBranch, final S
114126
Properties toInject = null;
115127
File toLoad = null;
116128
switch (type) {
129+
case SUPPORT: {
130+
toInject = supportBranchProperties;
131+
toLoad = supportBranchPropertyFile;
132+
break;
133+
}
117134
case MASTER: {
118135
toInject = masterBranchProperties;
119136
toLoad = masterBranchPropertyFile;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class TagMasterMojo extends AbstractGitflowBranchMojo {
2727

2828
@Override
2929
protected void execute(final GitBranchType type, final String gitBranch, final String branchPattern) throws MojoExecutionException, MojoFailureException {
30-
if (project.isExecutionRoot() && type.equals(GitBranchType.MASTER)) {
30+
if (project.isExecutionRoot() && (type.equals(GitBranchType.MASTER) || type.equals(GitBranchType.SUPPORT))) {
3131
if (gitURLExpression == null) {
3232
gitURLExpression = ScmUtils.resolveUrlOrExpression(project, getLog());
3333
}

0 commit comments

Comments
 (0)