Fork application process with Maven by default

Closes gh-16945
This commit is contained in:
Stephane Nicoll
2019-05-23 14:36:16 +02:00
parent 3432044997
commit a5537bd2e1
15 changed files with 37 additions and 191 deletions

View File

@@ -75,8 +75,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private boolean addResources = false;
/**
* Path to agent jar. NOTE: the use of agents means that processes will be started by
* forking a new JVM.
* Path to agent jar. NOTE: a forked process is required to use this feature.
* @since 1.0
* @deprecated since 2.2.0 in favor of {@code agents}
*/
@@ -85,8 +84,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private File[] agent;
/**
* Path to agent jars. NOTE: the use of agents means that processes will be started by
* forking a new JVM.
* Path to agent jars. NOTE: a forked process is required to use this feature.
* @since 2.2
*/
@Parameter(property = "spring-boot.run.agents")
@@ -101,8 +99,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
/**
* Current working directory to use for the application. If not specified, basedir
* will be used. NOTE: the use of working directory means that processes will be
* started by forking a new JVM.
* will be used. NOTE: a forked process is required to use this feature.
* @since 1.5
*/
@Parameter(property = "spring-boot.run.workingDirectory")
@@ -111,16 +108,15 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
/**
* JVM arguments that should be associated with the forked process used to run the
* application. On command line, make sure to wrap multiple values between quotes.
* NOTE: the use of JVM arguments means that processes will be started by forking a
* new JVM.
* NOTE: a forked process is required to use this feature.
* @since 1.1
*/
@Parameter(property = "spring-boot.run.jvmArguments")
private String jvmArguments;
/**
* List of JVM system properties to pass to the process. NOTE: the use of system
* properties means that processes will be started by forking a new JVM.
* List of JVM system properties to pass to the process. NOTE: a forked process is
* required to use this feature.
* @since 2.1
*/
@Parameter
@@ -128,8 +124,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
/**
* List of Environment variables that should be associated with the forked process
* used to run the application. NOTE: the use of Environment variables means that
* processes will be started by forking a new JVM.
* used to run the application. NOTE: a forked process is required to use this
* feature.
* @since 2.1
*/
@Parameter
@@ -177,13 +173,13 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private File classesDirectory;
/**
* Flag to indicate if the run processes should be forked. {@code fork} is
* automatically enabled if an agent, jvmArguments or working directory are specified,
* or if devtools is present.
* Flag to indicate if the run processes should be forked. Disabling forking will
* disable some features such as an agent, custom JVM arguments, devtools or
* specifying the working directory to use.
* @since 1.2
*/
@Parameter(property = "spring-boot.run.fork")
private Boolean fork;
@Parameter(property = "spring-boot.run.fork", defaultValue = "true")
private boolean fork;
/**
* Flag to include the test classpath when running.
@@ -213,15 +209,16 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
* @return {@code true} if the application process should be forked
*/
protected boolean isFork() {
return (Boolean.TRUE.equals(this.fork)
|| (this.fork == null && enableForkByDefault()));
return this.fork;
}
/**
* Specify if fork should be enabled by default.
* @return {@code true} if fork should be enabled by default
* @see #logDisabledFork()
* @deprecated as of 2.2.0 in favour of enabling forking by default.
*/
@Deprecated
protected boolean enableForkByDefault() {
return hasAgent() || hasJvmArgs() || hasEnvVariables()
|| hasWorkingDirectorySet();
@@ -264,7 +261,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
/**
* Log a warning indicating that fork mode has been explicitly disabled while some
* conditions are present that require to enable it.
* @see #enableForkByDefault()
*/
protected void logDisabledFork() {
if (getLog().isWarnEnabled()) {
@@ -273,9 +269,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
if (hasJvmArgs()) {
RunArguments runArguments = resolveJvmArguments();
getLog().warn("Fork mode disabled, ignoring JVM argument(s) [" + Arrays
.stream(runArguments.asArray()).collect(Collectors.joining(" "))
+ "]");
getLog().warn("Fork mode disabled, ignoring JVM argument(s) ["
+ String.join(" ", runArguments.asArray()) + "]");
}
if (hasWorkingDirectorySet()) {
getLog().warn(

View File

@@ -54,6 +54,7 @@ public class RunMojo extends AbstractRunMojo {
private Boolean hasDevtools;
@Override
@Deprecated
protected boolean enableForkByDefault() {
return super.enableForkByDefault() || hasDevtools();
}

View File

@@ -67,8 +67,7 @@ public class StartMojo extends AbstractRunMojo {
private String jmxName = SpringApplicationAdminClient.DEFAULT_OBJECT_NAME;
/**
* The port to use to expose the platform MBeanServer if the application needs to be
* forked.
* The port to use to expose the platform MBeanServer if the application is forked.
*/
@Parameter
private int jmxPort = 9001;