diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/run/BootRunTask.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/run/BootRunTask.java index 01f451d24e..5c2c216eb4 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/run/BootRunTask.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/run/BootRunTask.java @@ -17,7 +17,6 @@ package org.springframework.boot.gradle.run; import java.io.File; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -26,11 +25,7 @@ import java.util.Set; import org.gradle.api.internal.file.collections.SimpleFileCollection; import org.gradle.api.tasks.JavaExec; import org.gradle.api.tasks.SourceSet; -import org.gradle.process.ExecResult; -import org.gradle.process.internal.DefaultJavaExecAction; -import org.gradle.process.internal.ExecHandle; import org.springframework.boot.loader.tools.FileUtils; -import org.springframework.util.ReflectionUtils; /** * Extension of the standard 'run' task with additional Spring Boot features. @@ -58,37 +53,7 @@ public class BootRunTask extends JavaExec { FileUtils.removeDuplicatesFromOutputDirectory(outputDir, directory); } } - try { - executeReflectively(); - } catch (Exception e) { - getLogger().info("Cannot execute action reflectively"); - super.exec(); - } - } - - private ExecResult executeReflectively() throws Exception { - Field builder = ReflectionUtils.findField(JavaExec.class, "javaExecHandleBuilder"); - builder.setAccessible(true); - DefaultJavaExecAction action = (DefaultJavaExecAction) builder.get(this); - setMain(getMain()); - final ExecHandle execHandle = action.build(); - try { - Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { - - @Override - public void run() { - getLogger().info("Aborting java sub-process"); - execHandle.abort(); - } - })); - } catch (Exception e) { - getLogger().warn("Could not attach shutdown hook (child process may be orphaned)"); - } - ExecResult execResult = execHandle.start().waitForFinish(); - if (!isIgnoreExitValue()) { - execResult.assertNormalExitValue(); - } - return execResult; + super.exec(); } }