diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 2bc4280bc8..0c4d1f9d1c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -256,17 +256,19 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { * @see #enableForkByDefault() */ protected void logDisabledFork() { - if (hasAgent()) { - getLog().warn("Fork mode disabled, ignoring agent"); - } - if (hasJvmArgs()) { - RunArguments runArguments = resolveJvmArguments(); - getLog().warn("Fork mode disabled, ignoring JVM argument(s) [" + Arrays - .stream(runArguments.asArray()).collect(Collectors.joining(" ")) - + "]"); - } - if (hasWorkingDirectorySet()) { - getLog().warn("Fork mode disabled, ignoring working directory configuration"); + if (getLog().isWarnEnabled()) { + if (hasAgent()) { + getLog().warn("Fork mode disabled, ignoring agent"); + } + if (hasJvmArgs()) { + RunArguments runArguments = resolveJvmArguments(); + getLog().warn("Fork mode disabled, ignoring JVM argument(s) [" + Arrays + .stream(runArguments.asArray()).collect(Collectors.joining(" ")) + + "]"); + } + if (hasWorkingDirectorySet()) { + getLog().warn("Fork mode disabled, ignoring working directory configuration"); + } } } @@ -338,7 +340,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { * @return a {@link RunArguments} defining the JVM arguments */ protected RunArguments resolveJvmArguments() { - final StringBuilder stringBuilder = new StringBuilder(); + StringBuilder stringBuilder = new StringBuilder(); if (this.systemPropertyVariables != null) { stringBuilder.append(this.systemPropertyVariables.entrySet().stream() .map((e) -> SystemPropertyFormatter.format(e.getKey(), e.getValue())) @@ -358,7 +360,9 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { private void addAgents(List args) { if (this.agent != null) { - getLog().info("Attaching agents: " + Arrays.asList(this.agent)); + if (getLog().isInfoEnabled()) { + getLog().info("Attaching agents: " + Arrays.asList(this.agent)); + } for (File agent : this.agent) { args.add("-javaagent:" + agent); } @@ -390,7 +394,9 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { .append((classpath.length() > 0 ? File.pathSeparator : "") + new File(ele.toURI())); } - getLog().debug("Classpath for forked process: " + classpath); + if (getLog().isDebugEnabled()) { + getLog().debug("Classpath for forked process: " + classpath); + } args.add("-cp"); args.add(classpath.toString()); } @@ -468,11 +474,9 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { } private void logArguments(String message, String[] args) { - StringBuilder sb = new StringBuilder(message); - for (String arg : args) { - sb.append(arg).append(" "); + if (getLog().isDebugEnabled()) { + getLog().debug(Arrays.stream(args).collect(Collectors.joining(" ", message, ""))); } - getLog().debug(sb.toString().trim()); } private static class TestArtifactFilter extends AbstractArtifactFeatureFilter { @@ -569,11 +573,11 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { */ static class SystemPropertyFormatter { - public static String format(Object key, Object value) { + public static String format(String key, String value) { if (key == null) { return ""; } - if (value == null || String.valueOf(value).isEmpty()) { + if (value == null || value.isEmpty()) { return String.format("-D%s", key); } return String.format("-D%s=\"%s\"", key, value); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-env-variables.apt.vm b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-env-variables.apt.vm index 0fc0f6934b..7a3b7e560a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-env-variables.apt.vm +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-env-variables.apt.vm @@ -40,7 +40,7 @@ Dmytro Nosan If the value is empty or not defined (i.e. <<<>>>), the env variable is set with an empty String as the value. Maven trims values specified in the pom so it is - not possible to specify a env variable who needs to start or end with a space. + not possible to specify an env variable which needs to start or end with a space. Any String typed Maven variable can be passed as system properties. Any attempt to pass any other Maven variable type (e.g. a <<>> or a <<>> variable) will cause the diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-system-properties.apt.vm b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-system-properties.apt.vm index 493edf8c64..1b3cb3aa1f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-system-properties.apt.vm +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-system-properties.apt.vm @@ -27,7 +27,7 @@ test ${my.value} - + ... @@ -41,7 +41,7 @@ If the value is empty or not defined (i.e. <<<>>>), the system property is set with an empty String as the value. Maven trims values specified in the pom so it - is not possible to specify a System property who needs to start or end with a space via + is not possible to specify a System property which needs to start or end with a space via this mechanism: consider using <<>> instead. Any String typed Maven variable can be passed as system properties. Any attempt to pass diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/SystemPropertyFormatterTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/SystemPropertyFormatterTests.java index 8a18a8a93f..0919e219a7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/SystemPropertyFormatterTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/SystemPropertyFormatterTests.java @@ -49,7 +49,7 @@ public class SystemPropertyFormatterTests { } @Test - public void parseKeyWithOnlySpace() { + public void parseKeyWithOnlySpaces() { assertThat(SystemPropertyFormatter.format("key1", " ")) .isEqualTo("-Dkey1=\" \""); }