Skip to content

Commit 26c2c48

Browse files
committed
Refactor: Use io.smallrye.common.os.OS
Instead of org.apache.commons.lang3.SystemUtils;
1 parent ac3e7b3 commit 26c2c48

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.stream.Collectors;
1919
import java.util.stream.Stream;
2020

21-
import org.apache.commons.lang3.SystemUtils;
2221
import org.jboss.logging.Logger;
2322

2423
import io.quarkus.bootstrap.util.IoUtils;
@@ -53,6 +52,7 @@
5352
import io.quarkus.runtime.graal.DisableLoggingFeature;
5453
import io.quarkus.sbom.ApplicationComponent;
5554
import io.quarkus.sbom.ApplicationManifestConfig;
55+
import io.smallrye.common.os.OS;
5656

5757
public class NativeImageBuildStep {
5858

@@ -210,7 +210,7 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, LocalesBuildTimeCon
210210
String pie = "";
211211

212212
boolean isContainerBuild = nativeImageRunner.isContainerBuild();
213-
if (!isContainerBuild && SystemUtils.IS_OS_LINUX) {
213+
if (!isContainerBuild && OS.LINUX.isCurrent()) {
214214
if (nativeConfig.pie().isPresent() && nativeConfig.pie().get()) {
215215
pie = detectPIE();
216216
} else {
@@ -332,7 +332,7 @@ private String getNativeImageName(OutputTargetBuildItem outputTargetBuildItem, P
332332

333333
private String getResultingExecutableName(String nativeImageName, boolean isContainerBuild) {
334334
String resultingExecutableName = nativeImageName;
335-
if (SystemUtils.IS_OS_WINDOWS && !isContainerBuild) {
335+
if (OS.WINDOWS.isCurrent() && !isContainerBuild) {
336336
//once image is generated it gets added .exe on Windows
337337
resultingExecutableName = resultingExecutableName + ".exe";
338338
}
@@ -354,7 +354,7 @@ public NativeImageRunnerBuildItem resolveNativeImageBuildRunner(NativeConfig nat
354354
String executableName = getNativeImageExecutableName();
355355
String errorMessage = "Cannot find the `" + executableName
356356
+ "` in the GRAALVM_HOME, JAVA_HOME and System PATH.";
357-
if (!SystemUtils.IS_OS_LINUX) {
357+
if (!OS.LINUX.isCurrent()) {
358358
// Delay the error: if we're just building native sources, we may not need the build runner at all.
359359
return new NativeImageRunnerBuildItem(new NativeImageBuildRunnerError(errorMessage));
360360
}
@@ -474,7 +474,7 @@ private static void copySourcesToSourceCache(OutputTargetBuildItem outputTargetB
474474

475475
private RuntimeException imageGenerationFailed(int exitValue, boolean isContainerBuild) {
476476
if (exitValue == OOM_ERROR_VALUE) {
477-
if (isContainerBuild && !SystemUtils.IS_OS_LINUX) {
477+
if (isContainerBuild && !OS.LINUX.isCurrent()) {
478478
return new ImageGenerationFailureException("Image generation failed. Exit code was " + exitValue
479479
+ " 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 \""
480480
+ QUARKUS_XMX_PROPERTY + "\" property");
@@ -554,7 +554,7 @@ private static NativeImageBuildLocalRunner getNativeImageBuildLocalRunner(Native
554554
}
555555

556556
private static String getNativeImageExecutableName() {
557-
return SystemUtils.IS_OS_WINDOWS ? "native-image.cmd" : "native-image";
557+
return OS.WINDOWS.isCurrent() ? "native-image.cmd" : "native-image";
558558
}
559559

560560
private static String detectNoPIE() {
@@ -932,7 +932,7 @@ public NativeImageInvokerInfo build() {
932932
}
933933

934934
List<NativeConfig.MonitoringOption> monitoringOptions = new ArrayList<>();
935-
if (!SystemUtils.IS_OS_WINDOWS || containerBuild) {
935+
if (!OS.WINDOWS.isCurrent() || containerBuild) {
936936
// --enable-monitoring=heapdump is not supported on Windows
937937
monitoringOptions.add(NativeConfig.MonitoringOption.HEAPDUMP);
938938
}

0 commit comments

Comments
 (0)