Merge branch '2.7.x'

This commit is contained in:
Stephane Nicoll 2022-04-01 11:35:48 +02:00
commit c21b4a5280
4 changed files with 19 additions and 6 deletions

View File

@ -9,13 +9,13 @@ The plugin includes a run goal which can be used to launch your application from
Application arguments can be specified using the `arguments` parameter, see <<run.examples.using-application-arguments,using application arguments>> for more details. Application arguments can be specified using the `arguments` parameter, see <<run.examples.using-application-arguments,using application arguments>> for more details.
By default the application is executed in a forked process and setting properties on the command-line will not affect the application. The application is executed in a forked process and setting properties on the command-line will not affect the application.
If you need to specify some JVM arguments (that is for debugging purposes), you can use the `jvmArguments` parameter, see <<run.examples.debug,Debug the application>> for more details. If you need to specify some JVM arguments (that is for debugging purposes), you can use the `jvmArguments` parameter, see <<run.examples.debug,Debug the application>> for more details.
There is also explicit support for <<run.examples.system-properties,system properties>> and <<run.examples.environment-variables,environment variables>>. There is also explicit support for <<run.examples.system-properties,system properties>> and <<run.examples.environment-variables,environment variables>>.
As enabling a profile is quite common, there is dedicated `profiles` property that offers a shortcut for `-Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev"`, see <<run.examples.specify-active-profiles,Specify active profiles>>. As enabling a profile is quite common, there is dedicated `profiles` property that offers a shortcut for `-Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev"`, see <<run.examples.specify-active-profiles,Specify active profiles>>.
Although this is not recommended, it is possible to execute the application directly from the Maven JVM by disabling the `fork` property. Although this is not recommended (and deprecated), it is possible to execute the application directly from the Maven JVM by disabling the `fork` property.
Doing so means that the `jvmArguments`, `systemPropertyVariables`, `environmentVariables` and `agents` options are ignored. Doing so means that the `jvmArguments`, `systemPropertyVariables`, `environmentVariables` and `agents` options are ignored.
Spring Boot `devtools` is a module to improve the development-time experience when working on Spring Boot applications. Spring Boot `devtools` is a module to improve the development-time experience when working on Spring Boot applications.
@ -73,7 +73,7 @@ include::goals/run.adoc[leveloffset=+1]
[[run.examples.debug]] [[run.examples.debug]]
=== Debug the Application === Debug the Application
By default, the `run` goal runs your application in a forked process. The `run` goal runs your application in a forked process.
If you need to debug it, you should add the necessary JVM arguments to enable remote debugging. If you need to debug it, you should add the necessary JVM arguments to enable remote debugging.
The following configuration suspend the process until a debugger has joined on port 5005: The following configuration suspend the process until a debugger has joined on port 5005:

View File

@ -192,12 +192,14 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private File classesDirectory; private File classesDirectory;
/** /**
* Flag to indicate if the run processes should be forked. Disabling forking will * Deprecated. Flag to indicate if the run processes should be forked. Disabling
* disable some features such as an agent, custom JVM arguments, devtools or * forking will disable some features such as an agent, custom JVM arguments, devtools
* specifying the working directory to use. * or specifying the working directory to use.
* @since 1.2.0 * @since 1.2.0
* @deprecated since 2.7.0 for removal in 3.0.0 with no replacement
*/ */
@Parameter(property = "spring-boot.run.fork", defaultValue = "true") @Parameter(property = "spring-boot.run.fork", defaultValue = "true")
@Deprecated
private boolean fork; private boolean fork;
/** /**
@ -226,7 +228,9 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
/** /**
* Specify if the application process should be forked. * Specify if the application process should be forked.
* @return {@code true} if the application process should be forked * @return {@code true} if the application process should be forked
* @deprecated since 2.7.0 for removal in 3.0.0 with no replacement
*/ */
@Deprecated
protected boolean isFork() { protected boolean isFork() {
return this.fork; return this.fork;
} }
@ -244,6 +248,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
return this.workingDirectory != null; return this.workingDirectory != null;
} }
@SuppressWarnings("deprecation")
private void run(String startClassName) throws MojoExecutionException, MojoFailureException { private void run(String startClassName) throws MojoExecutionException, MojoFailureException {
boolean fork = isFork(); boolean fork = isFork();
this.project.getProperties().setProperty("_spring.boot.fork.enabled", Boolean.toString(fork)); this.project.getProperties().setProperty("_spring.boot.fork.enabled", Boolean.toString(fork));
@ -304,7 +309,9 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
* @param arguments the class arguments * @param arguments the class arguments
* @throws MojoExecutionException in case of MOJO execution errors * @throws MojoExecutionException in case of MOJO execution errors
* @throws MojoFailureException in case of MOJO failures * @throws MojoFailureException in case of MOJO failures
* @deprecated since 2.7.0 for removal in 3.0.0 with no replacement
*/ */
@Deprecated
protected abstract void runWithMavenJvm(String startClassName, String... arguments) protected abstract void runWithMavenJvm(String startClassName, String... arguments)
throws MojoExecutionException, MojoFailureException; throws MojoExecutionException, MojoFailureException;

View File

@ -71,6 +71,7 @@ public class RunMojo extends AbstractRunMojo {
} }
@Override @Override
@SuppressWarnings("deprecation")
protected RunArguments resolveJvmArguments() { protected RunArguments resolveJvmArguments() {
RunArguments jvmArguments = super.resolveJvmArguments(); RunArguments jvmArguments = super.resolveJvmArguments();
if (isFork() && this.optimizedLaunch) { if (isFork() && this.optimizedLaunch) {
@ -114,6 +115,7 @@ public class RunMojo extends AbstractRunMojo {
} }
@Override @Override
@Deprecated
protected void runWithMavenJvm(String startClassName, String... arguments) throws MojoExecutionException { protected void runWithMavenJvm(String startClassName, String... arguments) throws MojoExecutionException {
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName); IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName);
Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName, arguments), "main"); Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName, arguments), "main");

View File

@ -113,6 +113,7 @@ public class StartMojo extends AbstractRunMojo {
} }
@Override @Override
@SuppressWarnings("deprecation")
protected RunArguments resolveApplicationArguments() { protected RunArguments resolveApplicationArguments() {
RunArguments applicationArguments = super.resolveApplicationArguments(); RunArguments applicationArguments = super.resolveApplicationArguments();
applicationArguments.getArgs().addLast(ENABLE_MBEAN_PROPERTY); applicationArguments.getArgs().addLast(ENABLE_MBEAN_PROPERTY);
@ -123,6 +124,7 @@ public class StartMojo extends AbstractRunMojo {
} }
@Override @Override
@SuppressWarnings("deprecation")
protected RunArguments resolveJvmArguments() { protected RunArguments resolveJvmArguments() {
RunArguments jvmArguments = super.resolveJvmArguments(); RunArguments jvmArguments = super.resolveJvmArguments();
if (isFork()) { if (isFork()) {
@ -138,6 +140,7 @@ public class StartMojo extends AbstractRunMojo {
} }
@Override @Override
@Deprecated
protected void runWithMavenJvm(String startClassName, String... arguments) throws MojoExecutionException { protected void runWithMavenJvm(String startClassName, String... arguments) throws MojoExecutionException {
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName); IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName);
Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName, arguments), Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName, arguments),
@ -171,6 +174,7 @@ public class StartMojo extends AbstractRunMojo {
"Spring application did not start before the configured timeout (" + (wait * maxAttempts) + "ms"); "Spring application did not start before the configured timeout (" + (wait * maxAttempts) + "ms");
} }
@SuppressWarnings("deprecation")
private void waitForSpringApplication() throws MojoFailureException, MojoExecutionException { private void waitForSpringApplication() throws MojoFailureException, MojoExecutionException {
try { try {
if (isFork()) { if (isFork()) {