Skip to content

Commit aff19f6

Browse files
committed
Take 2 Global Settings and User Settings
1 parent 0636a45 commit aff19f6

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
@@ -135,6 +135,26 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
135135
@Parameter(property = "argLine")
136136
private String argLine;
137137

138+
/**
139+
* Global setting file to pass to the underlying Maven commands.
140+
* <br/>
141+
* If not defined will default to global settings file of executing Maven command.
142+
*
143+
* @since 1.14.1
144+
*/
145+
@Parameter(property = "gitflow.maven.settings.global")
146+
private String globalSettings;
147+
148+
/**
149+
* User setting file to pass to the underlying Maven commands.
150+
* <br/>
151+
* If not defined will default to user settings file of executing Maven command.
152+
*
153+
* @since 1.14.1
154+
*/
155+
@Parameter(property = "gitflow.maven.settings.user")
156+
private String userSettings;
157+
138158
/**
139159
* Whether to make a GPG-signed commit.
140160
*
@@ -279,6 +299,22 @@ private void initExecutables() {
279299
}
280300
}
281301

302+
/**
303+
* Initializes maven defaults.
304+
*/
305+
private void initMavenDefaults() {
306+
if (StringUtils.isBlank(this.globalSettings)) {
307+
this.globalSettings = this.mavenSession.getRequest()
308+
.getGlobalSettingsFile()
309+
.getAbsolutePath();
310+
}
311+
if (StringUtils.isBlank(this.userSettings)) {
312+
this.userSettings = this.mavenSession.getRequest()
313+
.getUserSettingsFile()
314+
.getAbsolutePath();
315+
}
316+
}
317+
282318
/**
283319
* Validates plugin configuration. Throws exception if configuration is not
284320
* 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)