Skip to content

Commit 15bdc12

Browse files
committed
Merge pull request #16941 from dosdebug
* pr/16941: Polish "Default to optimized launch of the JVM when using spring-boot:run" Default to optimized launch of the JVM when using spring-boot:run
2 parents 1c14079 + 4cdb5a8 commit 15bdc12

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invoker.goals=clean verify -X
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import static org.junit.Assert.assertTrue
2+
13
def file = new File(basedir, "build.log")
2-
return file.text.contains("I haz been run from '$basedir'")
4+
assertTrue file.text.contains("I haz been run from '$basedir'")
5+
assertTrue file.text.contains("JVM argument(s): -Xverify:none -XX:TieredStopAtLevel=1")
36

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.maven.plugins.annotations.Execute;
2727
import org.apache.maven.plugins.annotations.LifecyclePhase;
2828
import org.apache.maven.plugins.annotations.Mojo;
29+
import org.apache.maven.plugins.annotations.Parameter;
2930
import org.apache.maven.plugins.annotations.ResolutionScope;
3031

3132
import org.springframework.boot.loader.tools.JavaExecutable;
@@ -53,6 +54,13 @@ public class RunMojo extends AbstractRunMojo {
5354
*/
5455
private Boolean hasDevtools;
5556

57+
/**
58+
* Whether the JVM's launch should be optimized.
59+
* @since 2.2.0
60+
*/
61+
@Parameter(property = "optimizedLaunch", defaultValue = "true")
62+
private boolean optimizedLaunch;
63+
5664
@Override
5765
@Deprecated
5866
protected boolean enableForkByDefault() {
@@ -67,6 +75,16 @@ protected void logDisabledFork() {
6775
}
6876
}
6977

78+
@Override
79+
protected RunArguments resolveJvmArguments() {
80+
RunArguments jvmArguments = super.resolveJvmArguments();
81+
if (isFork() && this.optimizedLaunch) {
82+
jvmArguments.getArgs().addFirst("-XX:TieredStopAtLevel=1");
83+
jvmArguments.getArgs().addFirst("-Xverify:none");
84+
}
85+
return jvmArguments;
86+
}
87+
7088
@Override
7189
protected void runWithForkedJvm(File workingDirectory, List<String> args,
7290
Map<String, String> environmentVariables) throws MojoExecutionException {

0 commit comments

Comments
 (0)