Skip to content

Commit 1b3fa6c

Browse files
committed
Hotfix 1.2.1 - Forgot an important piece of the puzzle...
* If doing builds locally, or on a feature / bugfix branch in a CI job, we need to skip the actual 'deploy' step. The primary method of doing this is to set `maven.deploy.skip=true` * Refactored (generalized) configuration scanning in the build extension, which is what's responsible for removing plugins we don't want to run in 'master'. The assumption is that we only ever want to run our own plugins in the master branch. This should probably be configurable, but I'm waiting for a 'valid' use case to emerge before I create an issue for that.
1 parent 93c8438 commit 1b3fa6c

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>com.e-gineering</groupId>
1010
<artifactId>gitflow-helper-maven-plugin</artifactId>
1111

12-
<version>1.2.0</version>
12+
<version>1.2.1</version>
1313
<packaging>maven-plugin</packaging>
1414

1515
<name>gitflow-helper-maven-plugin</name>

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

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class MasterPromoteExtension extends AbstractMavenLifecycleParticipant {
2626
@Requirement
2727
private Logger logger;
2828

29+
30+
2931
@Override
3032
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
3133
Properties systemEnvVars = null;
@@ -37,6 +39,7 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
3739

3840
// Look for a gitflow-helper-maven-plugin, so we can determine what the gitBranchExpression and masterBranchPattern are...
3941
String masterBranchPattern = null;
42+
4043
String gitBranchExpression = null;
4144
boolean pluginFound = false;
4245

@@ -47,27 +50,21 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
4750
List<Plugin> dropPlugins = new ArrayList<Plugin>();
4851

4952
for (Plugin plugin : project.getBuildPlugins()) {
50-
// Don't drop our plugin. Read it's config.
53+
// Don't drop our plugin. Read it's config
5154
if (plugin.getKey().equals("com.e-gineering:gitflow-helper-maven-plugin")) {
5255
pluginFound = true;
5356

5457
logger.debug("gitflow-helper-maven-plugin found in project: [" + project.getName() + "]");
5558

5659
if (masterBranchPattern == null) {
57-
masterBranchPattern = extractMasterBranchPattern(plugin.getConfiguration());
58-
for (int i = 0; i < plugin.getExecutions().size() && masterBranchPattern == null; i++) {
59-
masterBranchPattern = extractMasterBranchPattern(plugin.getExecutions().get(i).getConfiguration());
60-
}
60+
masterBranchPattern = extractPluginConfigValue("masterBranchPattern", plugin);
6161
}
6262

6363
if (gitBranchExpression == null) {
64-
gitBranchExpression = extractGitBranchExpression(plugin.getConfiguration());
65-
for (int i = 0; i < plugin.getExecutions().size() && gitBranchExpression == null; i++) {
66-
gitBranchExpression = extractGitBranchExpression(plugin.getExecutions().get(i).getConfiguration());
67-
}
64+
gitBranchExpression = extractPluginConfigValue("gitBranchExpression", plugin);
6865
}
6966

70-
// Don't drop the maven-deploy-plugin. Read it's config.
67+
// Don't drop the maven-deploy-plugin
7168
} else if (plugin.getKey().equals("org.apache.maven.plugins:maven-deploy-plugin")) {
7269
logger.debug("gitflow-helper-maven-plugin removing plugin: " + plugin + " from project: " + project.getName());
7370
} else {
@@ -108,17 +105,17 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti
108105
}
109106
}
110107

111-
private String extractMasterBranchPattern(Object configuration) {
112-
try {
113-
return ((Xpp3Dom) configuration).getChild("masterBranchPattern").getValue();
114-
} catch (Exception ex) {
108+
private String extractPluginConfigValue(String parameter, Plugin plugin) {
109+
String value = extractConfigValue(parameter, plugin.getConfiguration());
110+
for (int i = 0; i < plugin.getExecutions().size() && value == null; i++) {
111+
value = extractConfigValue(parameter, plugin.getExecutions().get(i).getConfiguration());
115112
}
116-
return null;
113+
return value;
117114
}
118115

119-
private String extractGitBranchExpression(Object configuration) {
116+
private String extractConfigValue(String parameter, Object configuration) {
120117
try {
121-
return ((Xpp3Dom) configuration).getChild("gitBranchExpression").getValue();
118+
return ((Xpp3Dom) configuration).getChild(parameter).getValue();
122119
} catch (Exception ex) {
123120
}
124121
return null;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ protected void execute(final GitBranchType type, final String gitBranch, final S
4343
break;
4444
}
4545
default: {
46-
getLog().info("Un-Setting artifact repositories");
46+
getLog().info("Un-Setting artifact repositories.");
4747
project.setSnapshotArtifactRepository(null);
4848
project.setReleaseArtifactRepository(null);
49+
project.getProperties().put("maven.deploy.skip", "true");
50+
getLog().info("Setting maven.deploy.skip = 'true'");
4951
break;
5052
}
5153
}

0 commit comments

Comments
 (0)