Skip to content

Commit

Permalink
Take 2 Global Settings and User Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nhojpatrick committed Mar 14, 2022
1 parent c7f8def commit c0648de
Showing 1 changed file with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
@Parameter(property = "argLine")
private String argLine;

/**
* Global setting file to pass to the underlying Maven commands.
* <br/>
* If not defined will default to global settings file of executing Maven command.
*
* @since 1.14.1
*/
@Parameter(property = "gitflow.maven.settings.global")
private String globalSettings;

/**
* User setting file to pass to the underlying Maven commands.
* <br/>
* If not defined will default to user settings file of executing Maven command.
*
* @since 1.14.1
*/
@Parameter(property = "gitflow.maven.settings.user")
private String userSettings;

/**
* Whether to make a GPG-signed commit.
*
Expand Down Expand Up @@ -279,6 +299,22 @@ private void initExecutables() {
}
}

/**
* Initializes maven defaults.
*/
private void initMavenDefaults() {
if (StringUtils.isBlank(this.globalSettings)) {
this.globalSettings = this.mavenSession.getRequest()
.getGlobalSettingsFile()
.getAbsolutePath();
}
if (StringUtils.isBlank(this.userSettings)) {
this.userSettings = this.mavenSession.getRequest()
.getUserSettingsFile()
.getAbsolutePath();
}
}

/**
* Validates plugin configuration. Throws exception if configuration is not
* valid.
Expand Down Expand Up @@ -1320,7 +1356,26 @@ private void executeGitCommand(final String... args)
*/
private void executeMvnCommand(final String... args)
throws CommandLineException, MojoFailureException {
executeCommand(cmdMvn, true, argLine, args);

initMavenDefaults();

final List<String> argLines = new ArrayList<String>();

if (StringUtils.isBlank(this.argLine)
|| !this.argLine.contains("-gs")) {
argLines.add("-gs");
argLines.add(this.globalSettings);
}
if (StringUtils.isBlank(this.argLine)
|| !this.argLine.contains("-s")) {
argLines.add("-s");
argLines.add(this.userSettings);
}
if (StringUtils.isNotBlank(this.argLine)) {
argLines.add(this.argLine);
}

executeCommand(cmdMvn, true, StringUtils.join(argLines.toArray(), " "), args);
}

/**
Expand Down

0 comments on commit c0648de

Please sign in to comment.