Skip to content

Commit

Permalink
plexus-utils 3.X does not like adding empty args and will throw "... …
Browse files Browse the repository at this point in the history
…Unknown lifecycle phase "". You must specify a valid lifecycle phase or a goal ...", was fine in plexus-utils 1.X

or for git, Failed cmd ['git'] with args [[merge, --no-ff, , release/0.0.3, , ]], bad exit code [1]. Out: [merge:  - not something we can merge

my guess: handling of empty args changes between plexus-utils major versions
  • Loading branch information
DRoppelt committed May 3, 2023
1 parent c250f5a commit 885b015
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -854,12 +856,12 @@ protected void gitCommit(String message, Map<String, String> messageProperties)
protected void gitMerge(final String branchName, boolean rebase, boolean noff, boolean ffonly, String message,
Map<String, String> messageProperties)
throws MojoFailureException, CommandLineException {
String sign = "";
String sign = null;
if (gpgSignCommit) {
sign = "-S";
}
String msgParam = "";
String msg = "";
String msgParam = null;
String msg = null;
if (StringUtils.isNotBlank(message)) {
if (StringUtils.isNotBlank(commitMessagePrefix)) {
message = commitMessagePrefix + message;
Expand Down Expand Up @@ -1129,15 +1131,9 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
getLog().info("Updating version(s) to '" + version + "'.");

String newVersion = "-DnewVersion=" + version;
String grp = "";
String art = "";
if (versionsForceUpdate) {
grp = "-DgroupId=";
art = "-DartifactId=";
}

if (tychoBuild) {
String prop = "";
String prop = null;
if (StringUtils.isNotBlank(versionProperty)) {
prop = "-Dproperties=" + versionProperty;
getLog().info("Updating property '" + versionProperty + "' to '" + version + "'.");
Expand All @@ -1153,8 +1149,10 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
if (!skipUpdateVersion) {
runCommand = true;
args.add(VERSIONS_MAVEN_PLUGIN + ":" + versionsMavenPluginVersion + ":" + VERSIONS_MAVEN_PLUGIN_SET_GOAL);
args.add(grp);
args.add(art);
if (versionsForceUpdate) {
args.add("-DgroupId=");
args.add("-DartifactId=");
}
}

if (StringUtils.isNotBlank(versionProperty)) {
Expand Down Expand Up @@ -1330,7 +1328,8 @@ private CommandResult executeCommand(final Commandline cmd, final boolean failOn
}

cmd.clearArgs();
cmd.addArguments(args);
String[] nonEmptyArgs = Arrays.stream(args).filter(Objects::nonNull).toArray(String[]::new);
cmd.addArguments(nonEmptyArgs);

if (StringUtils.isNotBlank(argStr)) {
cmd.createArg().setLine(argStr);
Expand Down

0 comments on commit 885b015

Please sign in to comment.