Consider mvn spring-boot:run that exits with 130 (SIGINT) to be successful
Previously, if mvn spring-boot:run with a forked JVM was killed with CTRL+C, the run would be considered unsuccessful. This commits updates the run mojo to consider a forked JVM that exists with 130 (the exit code produced when exiting due to SIGINT which is what CTRL+C sends) to be successful. Closes gh-6498
This commit is contained in:
parent
79b0d14504
commit
b3e0b3a542
|
|
@ -39,6 +39,8 @@ import org.springframework.boot.loader.tools.RunProcess;
|
||||||
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
||||||
public class RunMojo extends AbstractRunMojo {
|
public class RunMojo extends AbstractRunMojo {
|
||||||
|
|
||||||
|
private static final int EXIT_CODE_SIGINT = 130;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
|
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
|
||||||
try {
|
try {
|
||||||
|
|
@ -46,11 +48,11 @@ public class RunMojo extends AbstractRunMojo {
|
||||||
Runtime.getRuntime()
|
Runtime.getRuntime()
|
||||||
.addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
|
.addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
|
||||||
int exitCode = runProcess.run(true, args.toArray(new String[args.size()]));
|
int exitCode = runProcess.run(true, args.toArray(new String[args.size()]));
|
||||||
|
if (exitCode == 0 || exitCode == EXIT_CODE_SIGINT) {
|
||||||
if (exitCode != 0) {
|
return;
|
||||||
throw new MojoExecutionException(
|
|
||||||
"Application finished with non-zero exit code: " + exitCode);
|
|
||||||
}
|
}
|
||||||
|
throw new MojoExecutionException(
|
||||||
|
"Application finished with exit code: " + exitCode);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw new MojoExecutionException("Could not exec java", ex);
|
throw new MojoExecutionException("Could not exec java", ex);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue