diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index c58488852dce3..e83284028ee1a 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -18,7 +18,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.commons.lang3.SystemUtils; import org.jboss.logging.Logger; import io.quarkus.bootstrap.util.IoUtils; @@ -53,6 +52,7 @@ import io.quarkus.runtime.graal.DisableLoggingFeature; import io.quarkus.sbom.ApplicationComponent; import io.quarkus.sbom.ApplicationManifestConfig; +import io.smallrye.common.os.OS; public class NativeImageBuildStep { @@ -210,7 +210,7 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, LocalesBuildTimeCon String pie = ""; boolean isContainerBuild = nativeImageRunner.isContainerBuild(); - if (!isContainerBuild && SystemUtils.IS_OS_LINUX) { + if (!isContainerBuild && OS.LINUX.isCurrent()) { if (nativeConfig.pie().isPresent() && nativeConfig.pie().get()) { pie = detectPIE(); } else { @@ -332,7 +332,7 @@ private String getNativeImageName(OutputTargetBuildItem outputTargetBuildItem, P private String getResultingExecutableName(String nativeImageName, boolean isContainerBuild) { String resultingExecutableName = nativeImageName; - if (SystemUtils.IS_OS_WINDOWS && !isContainerBuild) { + if (OS.WINDOWS.isCurrent() && !isContainerBuild) { //once image is generated it gets added .exe on Windows resultingExecutableName = resultingExecutableName + ".exe"; } @@ -354,7 +354,7 @@ public NativeImageRunnerBuildItem resolveNativeImageBuildRunner(NativeConfig nat String executableName = getNativeImageExecutableName(); String errorMessage = "Cannot find the `" + executableName + "` in the GRAALVM_HOME, JAVA_HOME and System PATH."; - if (!SystemUtils.IS_OS_LINUX) { + if (!OS.LINUX.isCurrent()) { // Delay the error: if we're just building native sources, we may not need the build runner at all. return new NativeImageRunnerBuildItem(new NativeImageBuildRunnerError(errorMessage)); } @@ -474,7 +474,7 @@ private static void copySourcesToSourceCache(OutputTargetBuildItem outputTargetB private RuntimeException imageGenerationFailed(int exitValue, boolean isContainerBuild) { if (exitValue == OOM_ERROR_VALUE) { - if (isContainerBuild && !SystemUtils.IS_OS_LINUX) { + if (isContainerBuild && !OS.LINUX.isCurrent()) { return new ImageGenerationFailureException("Image generation failed. Exit code was " + exitValue + " which indicates an out of memory error. The most likely cause is Docker not being given enough memory. Also consider increasing the Xmx value for native image generation by setting the \"" + QUARKUS_XMX_PROPERTY + "\" property"); @@ -554,7 +554,7 @@ private static NativeImageBuildLocalRunner getNativeImageBuildLocalRunner(Native } private static String getNativeImageExecutableName() { - return SystemUtils.IS_OS_WINDOWS ? "native-image.cmd" : "native-image"; + return OS.WINDOWS.isCurrent() ? "native-image.cmd" : "native-image"; } private static String detectNoPIE() { @@ -932,7 +932,7 @@ public NativeImageInvokerInfo build() { } List monitoringOptions = new ArrayList<>(); - if (!SystemUtils.IS_OS_WINDOWS || containerBuild) { + if (!OS.WINDOWS.isCurrent() || containerBuild) { // --enable-monitoring=heapdump is not supported on Windows monitoringOptions.add(NativeConfig.MonitoringOption.HEAPDUMP); }