Skip to content

Commit

Permalink
Refactor: move server shutdown out of getBuildCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Dec 18, 2020
1 parent a78ecfc commit 066adf4
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,17 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa
noPIE = detectNoPIE();
}
try {
List<String> buildCommand = getBuildCommand(nativeConfig, nativeImageProperties, processInheritIODisabled,
outputDir, runnerJarName, nativeImage, noPIE, isContainerBuild, graalVMVersion, executableName);
if (nativeConfig.cleanupServer && !graalVMVersion.isMandrel()) {
List<String> cleanup = new ArrayList<>(nativeImage);
cleanup.add("--server-shutdown");
final ProcessBuilder pb = new ProcessBuilder(cleanup);
pb.directory(outputDir.toFile());
final Process process = ProcessUtil.launchProcess(pb, processInheritIODisabled.isPresent());
process.waitFor();
}
List<String> buildCommand = getBuildCommand(nativeConfig, nativeImageProperties,
outputDir, runnerJarName, nativeImage, noPIE, isContainerBuild, graalVMVersion,
executableName);
log.info(String.join(" ", buildCommand).replace("$", "\\$"));
CountDownLatch errorReportLatch = new CountDownLatch(1);
final ProcessBuilder processBuilder = new ProcessBuilder(buildCommand).directory(outputDir.toFile());
Expand Down Expand Up @@ -191,19 +200,10 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa
}

private List<String> getBuildCommand(NativeConfig nativeConfig,
List<NativeImageSystemPropertyBuildItem> nativeImageProperties,
Optional<ProcessInheritIODisabled> processInheritIODisabled, Path outputDir, String runnerJarName,
List<NativeImageSystemPropertyBuildItem> nativeImageProperties, Path outputDir, String runnerJarName,
List<String> nativeImage, String noPIE, boolean isContainerBuild, GraalVM.Version graalVMVersion,
String executableName) throws IOException, InterruptedException {
String executableName) {
List<String> command = new ArrayList<>(nativeImage);
if (nativeConfig.cleanupServer && !graalVMVersion.isMandrel()) {
List<String> cleanup = new ArrayList<>(nativeImage);
cleanup.add("--server-shutdown");
final ProcessBuilder pb = new ProcessBuilder(cleanup.toArray(new String[0]));
pb.directory(outputDir.toFile());
final Process process = ProcessUtil.launchProcess(pb, processInheritIODisabled.isPresent());
process.waitFor();
}
boolean enableSslNative = false;
for (NativeImageSystemPropertyBuildItem prop : nativeImageProperties) {
//todo: this should be specific build items
Expand Down

0 comments on commit 066adf4

Please sign in to comment.