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 Jan 17, 2021
1 parent 8613f0a commit 03d5e10
Showing 1 changed file with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,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 @@ -203,6 +223,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 @@ -1123,7 +1159,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 03d5e10

Please sign in to comment.