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
This commit is contained in:
Stephane Nicoll 2019-05-25 12:27:52 +02:00
commit 15bdc12335
3 changed files with 24 additions and 2 deletions

View File

@ -0,0 +1 @@
invoker.goals=clean verify -X

View File

@ -1,3 +1,6 @@
def file = new File(basedir, "build.log") import static org.junit.Assert.assertTrue
return file.text.contains("I haz been run from '$basedir'")
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")

View File

@ -26,6 +26,7 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.annotations.ResolutionScope;
import org.springframework.boot.loader.tools.JavaExecutable; import org.springframework.boot.loader.tools.JavaExecutable;
@ -53,6 +54,13 @@ public class RunMojo extends AbstractRunMojo {
*/ */
private Boolean hasDevtools; private Boolean hasDevtools;
/**
* Whether the JVM's launch should be optimized.
* @since 2.2.0
*/
@Parameter(property = "optimizedLaunch", defaultValue = "true")
private boolean optimizedLaunch;
@Override @Override
@Deprecated @Deprecated
protected boolean enableForkByDefault() { 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 @Override
protected void runWithForkedJvm(File workingDirectory, List<String> args, protected void runWithForkedJvm(File workingDirectory, List<String> args,
Map<String, String> environmentVariables) throws MojoExecutionException { Map<String, String> environmentVariables) throws MojoExecutionException {