Revert BootRunTask changes since they don't add anything

(Was an attempt to get Cygwin to recognise the interrupt, but it seems
to be doomed so not worth having the extra code in there really.)
This commit is contained in:
Dave Syer
2014-06-20 13:28:46 +01:00
parent e088ecd1bc
commit 3411995736

View File

@@ -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();
}
}