|
17 | 17 | package org.springframework.boot.gradle.run;
|
18 | 18 |
|
19 | 19 | import java.io.File;
|
20 |
| -import java.lang.reflect.Field; |
21 | 20 | import java.util.ArrayList;
|
22 | 21 | import java.util.LinkedHashSet;
|
23 | 22 | import java.util.List;
|
|
26 | 25 | import org.gradle.api.internal.file.collections.SimpleFileCollection;
|
27 | 26 | import org.gradle.api.tasks.JavaExec;
|
28 | 27 | import org.gradle.api.tasks.SourceSet;
|
29 |
| -import org.gradle.process.ExecResult; |
30 |
| -import org.gradle.process.internal.DefaultJavaExecAction; |
31 |
| -import org.gradle.process.internal.ExecHandle; |
32 | 28 | import org.springframework.boot.loader.tools.FileUtils;
|
33 |
| -import org.springframework.util.ReflectionUtils; |
34 | 29 |
|
35 | 30 | /**
|
36 | 31 | * Extension of the standard 'run' task with additional Spring Boot features.
|
@@ -58,37 +53,7 @@ public void exec() {
|
58 | 53 | FileUtils.removeDuplicatesFromOutputDirectory(outputDir, directory);
|
59 | 54 | }
|
60 | 55 | }
|
61 |
| - try { |
62 |
| - executeReflectively(); |
63 |
| - } catch (Exception e) { |
64 |
| - getLogger().info("Cannot execute action reflectively"); |
65 |
| - super.exec(); |
66 |
| - } |
67 |
| - } |
68 |
| - |
69 |
| - private ExecResult executeReflectively() throws Exception { |
70 |
| - Field builder = ReflectionUtils.findField(JavaExec.class, "javaExecHandleBuilder"); |
71 |
| - builder.setAccessible(true); |
72 |
| - DefaultJavaExecAction action = (DefaultJavaExecAction) builder.get(this); |
73 |
| - setMain(getMain()); |
74 |
| - final ExecHandle execHandle = action.build(); |
75 |
| - try { |
76 |
| - Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { |
77 |
| - |
78 |
| - @Override |
79 |
| - public void run() { |
80 |
| - getLogger().info("Aborting java sub-process"); |
81 |
| - execHandle.abort(); |
82 |
| - } |
83 |
| - })); |
84 |
| - } catch (Exception e) { |
85 |
| - getLogger().warn("Could not attach shutdown hook (child process may be orphaned)"); |
86 |
| - } |
87 |
| - ExecResult execResult = execHandle.start().waitForFinish(); |
88 |
| - if (!isIgnoreExitValue()) { |
89 |
| - execResult.assertNormalExitValue(); |
90 |
| - } |
91 |
| - return execResult; |
| 56 | + super.exec(); |
92 | 57 | }
|
93 | 58 |
|
94 | 59 | }
|
0 commit comments