Add a simple command option to toggle maven-like behavior, fixes #248

This commit is contained in:
Guillaume Nodet
2020-12-09 15:01:24 +01:00
parent 732a8e1a83
commit b6a1f40b1b
3 changed files with 24 additions and 0 deletions

View File

@@ -267,6 +267,17 @@ public class DaemonParameters {
.asBoolean();
}
/**
*
* @return if mvnd should behave as maven
*/
public boolean serial() {
return value(Environment.SERIAL)
.orSystemProperty()
.orDefault()
.asBoolean();
}
/**
* @param newUserDir where to change the current directory to
* @return a new {@link DaemonParameters} with {@code userDir} set to the given {@code newUserDir}

View File

@@ -72,6 +72,11 @@ public class DefaultClient implements Client {
}
}
// Serial
if (Environment.SERIAL.removeCommandLineOption(args) != null) {
System.setProperty(Environment.SERIAL.getProperty(), Boolean.toString(true));
}
// Batch mode
boolean batchMode = Environment.MAVEN_BATCH_MODE.hasCommandOption(args);
@@ -100,6 +105,12 @@ public class DefaultClient implements Client {
}
DaemonParameters parameters = new DaemonParameters();
if (parameters.serial()) {
System.setProperty(Environment.MVND_THREADS.getProperty(), Integer.toString(1));
System.setProperty(Environment.MVND_BUILDER.getProperty(), "singlethreaded");
System.setProperty(Environment.MVND_NO_BUFERING.getProperty(), Boolean.toString(true));
}
int exitCode = 0;
boolean noBuffering = batchMode || parameters.noBuffering();
try (TerminalOutput output = new TerminalOutput(noBuffering, parameters.rollingWindowSize(), logFile)) {

View File

@@ -50,6 +50,8 @@ public enum Environment {
STATUS(null, null, null, OptionType.VOID, Flags.OPTIONAL, "--status"),
/** Stop all daemon instances registered in the registry specified by <code>mvnd.registry</code> */
STOP(null, null, null, OptionType.VOID, Flags.OPTIONAL, "--stop"),
/** Use one thread, no log buffering and the default project builder to behave like a standard maven */
SERIAL("mvnd.serial", null, Boolean.FALSE, OptionType.BOOLEAN, Flags.OPTIONAL, "--serial"),
//
// Log properties