Skip to content

Commit e8d1796

Browse files
committed
Take 2 Global Settings and User Settings
1 parent 20c2530 commit e8d1796

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java

+56-1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
139139
@Parameter(property = "argLine")
140140
private String argLine;
141141

142+
/**
143+
* Global setting file to pass to the underlying Maven commands.
144+
* <br/>
145+
* If not defined will default to global settings file of executing Maven command.
146+
*
147+
* @since 1.14.1
148+
*/
149+
@Parameter(property = "gitflow.maven.settings.global")
150+
private String globalSettings;
151+
152+
/**
153+
* User setting file to pass to the underlying Maven commands.
154+
* <br/>
155+
* If not defined will default to user settings file of executing Maven command.
156+
*
157+
* @since 1.14.1
158+
*/
159+
@Parameter(property = "gitflow.maven.settings.user")
160+
private String userSettings;
161+
142162
/**
143163
* Whether to make a GPG-signed commit.
144164
*
@@ -297,6 +317,22 @@ private void initExecutables() {
297317
}
298318
}
299319

320+
/**
321+
* Initializes maven defaults.
322+
*/
323+
private void initMavenDefaults() {
324+
if (StringUtils.isBlank(this.globalSettings)) {
325+
this.globalSettings = this.mavenSession.getRequest()
326+
.getGlobalSettingsFile()
327+
.getAbsolutePath();
328+
}
329+
if (StringUtils.isBlank(this.userSettings)) {
330+
this.userSettings = this.mavenSession.getRequest()
331+
.getUserSettingsFile()
332+
.getAbsolutePath();
333+
}
334+
}
335+
300336
/**
301337
* Validates plugin configuration. Throws exception if configuration is not
302338
* valid.
@@ -1320,7 +1356,26 @@ private void executeGitCommand(final String... args)
13201356
*/
13211357
private void executeMvnCommand(final String... args)
13221358
throws CommandLineException, MojoFailureException {
1323-
executeCommand(cmdMvn, true, argLine, args);
1359+
1360+
initMavenDefaults();
1361+
1362+
final List<String> argLines = new ArrayList<String>();
1363+
1364+
if (StringUtils.isBlank(this.argLine)
1365+
|| !this.argLine.contains("-gs")) {
1366+
argLines.add("-gs");
1367+
argLines.add(this.globalSettings);
1368+
}
1369+
if (StringUtils.isBlank(this.argLine)
1370+
|| !this.argLine.contains("-s")) {
1371+
argLines.add("-s");
1372+
argLines.add(this.userSettings);
1373+
}
1374+
if (StringUtils.isNotBlank(this.argLine)) {
1375+
argLines.add(this.argLine);
1376+
}
1377+
1378+
executeCommand(cmdMvn, true, StringUtils.join(argLines.toArray(), " "), args);
13241379
}
13251380

13261381
/**

0 commit comments

Comments
 (0)