diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/invoker.properties b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/invoker.properties new file mode 100644 index 0000000000..8056f772da --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean verify -X \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/verify.groovy b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/verify.groovy index 323ffc863b..54e7b17fa2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/verify.groovy +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/verify.groovy @@ -1,3 +1,6 @@ -def file = new File(basedir, "build.log") -return file.text.contains("I haz been run from '$basedir'") +import static org.junit.Assert.assertTrue + +def file = new File(basedir, "build.log") +assertTrue file.text.contains("I haz been run from '$basedir'") +assertTrue file.text.contains("JVM argument(s): -Xverify:none -XX:TieredStopAtLevel=1") diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java index 3119fbfeb4..29420c733b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java @@ -26,6 +26,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.springframework.boot.loader.tools.JavaExecutable; @@ -53,6 +54,13 @@ public class RunMojo extends AbstractRunMojo { */ private Boolean hasDevtools; + /** + * Whether the JVM's launch should be optimized. + * @since 2.2.0 + */ + @Parameter(property = "optimizedLaunch", defaultValue = "true") + private boolean optimizedLaunch; + @Override @Deprecated protected boolean enableForkByDefault() { @@ -67,6 +75,16 @@ public class RunMojo extends AbstractRunMojo { } } + @Override + protected RunArguments resolveJvmArguments() { + RunArguments jvmArguments = super.resolveJvmArguments(); + if (isFork() && this.optimizedLaunch) { + jvmArguments.getArgs().addFirst("-XX:TieredStopAtLevel=1"); + jvmArguments.getArgs().addFirst("-Xverify:none"); + } + return jvmArguments; + } + @Override protected void runWithForkedJvm(File workingDirectory, List args, Map environmentVariables) throws MojoExecutionException {