Skip to content

Commit 26e1238

Browse files
committed
Take 2 Global Settings and User Settings
1 parent b04c0ae commit 26e1238

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

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,26 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
117117
@Parameter(property = "argLine")
118118
private String argLine;
119119

120+
/**
121+
* Global setting file to pass to the underlying Maven commands.
122+
* <br/>
123+
* If not defined will default to global settings file of executing Maven command.
124+
*
125+
* @since 1.14.1
126+
*/
127+
@Parameter(property = "gitflow.maven.settings.global")
128+
private String globalSettings;
129+
130+
/**
131+
* User setting file to pass to the underlying Maven commands.
132+
* <br/>
133+
* If not defined will default to user settings file of executing Maven command.
134+
*
135+
* @since 1.14.1
136+
*/
137+
@Parameter(property = "gitflow.maven.settings.user")
138+
private String userSettings;
139+
120140
/**
121141
* Whether to make a GPG-signed commit.
122142
*
@@ -203,6 +223,22 @@ private void initExecutables() {
203223
}
204224
}
205225

226+
/**
227+
* Initializes maven defaults.
228+
*/
229+
private void initMavenDefaults() {
230+
if (StringUtils.isBlank(this.globalSettings)) {
231+
this.globalSettings = this.mavenSession.getRequest()
232+
.getGlobalSettingsFile()
233+
.getAbsolutePath();
234+
}
235+
if (StringUtils.isBlank(this.userSettings)) {
236+
this.userSettings = this.mavenSession.getRequest()
237+
.getUserSettingsFile()
238+
.getAbsolutePath();
239+
}
240+
}
241+
206242
/**
207243
* Validates plugin configuration. Throws exception if configuration is not
208244
* valid.
@@ -1134,7 +1170,26 @@ private void executeGitCommand(final String... args)
11341170
*/
11351171
private void executeMvnCommand(final String... args)
11361172
throws CommandLineException, MojoFailureException {
1137-
executeCommand(cmdMvn, true, argLine, args);
1173+
1174+
initMavenDefaults();
1175+
1176+
final List<String> argLines = new ArrayList<String>();
1177+
1178+
if (StringUtils.isBlank(this.argLine)
1179+
|| !this.argLine.contains("-gs")) {
1180+
argLines.add("-gs");
1181+
argLines.add(this.globalSettings);
1182+
}
1183+
if (StringUtils.isBlank(this.argLine)
1184+
|| !this.argLine.contains("-s")) {
1185+
argLines.add("-s");
1186+
argLines.add(this.userSettings);
1187+
}
1188+
if (StringUtils.isNotBlank(this.argLine)) {
1189+
argLines.add(this.argLine);
1190+
}
1191+
1192+
executeCommand(cmdMvn, true, StringUtils.join(argLines.toArray(), " "), args);
11381193
}
11391194

11401195
/**

0 commit comments

Comments
 (0)