mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-27 07:55:25 +00:00
Move the code to set system properties to its own method, make sure it's called from JvmTestClient
This commit is contained in:
@@ -30,7 +30,6 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
@@ -82,22 +81,7 @@ public class DefaultClient implements Client {
|
||||
boolean batchMode = Environment.MAVEN_BATCH_MODE.hasCommandLineOption(args);
|
||||
|
||||
// System properties
|
||||
for (Iterator<String> it = args.iterator(); it.hasNext();) {
|
||||
String arg = it.next();
|
||||
String val = Environment.MAVEN_DEFINE.removeCommandLineOption(new ArrayList<>(Collections.singletonList(arg)));
|
||||
if (val != null) {
|
||||
if (val.isEmpty()) {
|
||||
throw new IllegalArgumentException("Missing argument for option " + arg);
|
||||
}
|
||||
/* This needs to be done very early, otherwise various DaemonParameters do not work properly */
|
||||
final int eqPos = val.indexOf('=');
|
||||
if (eqPos >= 0) {
|
||||
System.setProperty(val.substring(2, eqPos), val.substring(eqPos + 1));
|
||||
} else {
|
||||
System.setProperty(val.substring(2), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
setSystemPropertiesFromCommandLine(args);
|
||||
|
||||
DaemonParameters parameters = new DaemonParameters();
|
||||
if (parameters.serial()) {
|
||||
@@ -122,6 +106,24 @@ public class DefaultClient implements Client {
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
public static void setSystemPropertiesFromCommandLine(List<String> args) {
|
||||
for (String arg : args) {
|
||||
String val = Environment.MAVEN_DEFINE.removeCommandLineOption(new ArrayList<>(Collections.singletonList(arg)));
|
||||
if (val != null) {
|
||||
if (val.isEmpty()) {
|
||||
throw new IllegalArgumentException("Missing argument for option " + arg);
|
||||
}
|
||||
/* This needs to be done very early, otherwise various DaemonParameters do not work properly */
|
||||
final int eqPos = val.indexOf('=');
|
||||
if (eqPos >= 0) {
|
||||
System.setProperty(val.substring(0, eqPos), val.substring(eqPos + 1));
|
||||
} else {
|
||||
System.setProperty(val, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultClient(DaemonParameters parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ public class JvmTestClient extends DefaultClient {
|
||||
|
||||
@Override
|
||||
public ExecutionResult execute(ClientOutput output, List<String> argv) {
|
||||
setSystemPropertiesFromCommandLine(argv);
|
||||
final ExecutionResult delegate = super.execute(output, argv);
|
||||
if (output instanceof TestClientOutput) {
|
||||
return new JvmTestResult(delegate, ((TestClientOutput) output).messagesToString());
|
||||
|
Reference in New Issue
Block a user