Skip to content

Commit

Permalink
Refactor: Use io.smallrye.common.os.OS
Browse files Browse the repository at this point in the history
Instead of org.apache.commons.lang3.SystemUtils;
  • Loading branch information
zakkak committed Oct 16, 2024
1 parent ad1aa62 commit 57f936f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.lang3.SystemUtils;
import io.smallrye.common.os.OS;
import org.jboss.logging.Logger;

import io.quarkus.bootstrap.util.IoUtils;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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";
}
Expand All @@ -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));
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -932,7 +932,7 @@ public NativeImageInvokerInfo build() {
}

List<NativeConfig.MonitoringOption> 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);
}
Expand Down

0 comments on commit 57f936f

Please sign in to comment.