Skip to content

Update Maven spring-boot:run to launch JVM with flags to enable development-time optimisations #16941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collections;
import java.util.List;
import java.util.Map;

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;
Expand Down Expand Up @@ -53,6 +55,9 @@ public class RunMojo extends AbstractRunMojo {
*/
private Boolean hasDevtools;

@Parameter(property = "optimizedLaunch", defaultValue = "true")
private boolean optimizedLaunch = true;

@Override
protected boolean enableForkByDefault() {
return super.enableForkByDefault() || hasDevtools();
Expand All @@ -69,6 +74,10 @@ protected void logDisabledFork() {
@Override
protected void runWithForkedJvm(File workingDirectory, List<String> args,
Map<String, String> environmentVariables) throws MojoExecutionException {
if (this.optimizedLaunch) {
String[] optimizedLaunchArgs = { "-Xverify:none", "-XX:TieredStopAtLevel=1" };
Collections.addAll(args, optimizedLaunchArgs);
}
int exitCode = forkJvm(workingDirectory, args, environmentVariables);
if (exitCode == 0 || exitCode == EXIT_CODE_SIGINT) {
return;
Expand Down