From 00392e75baaa66f0bc5ed9c36e7e25d3d7f66407 Mon Sep 17 00:00:00 2001 From: Michal Karm Babacek Date: Wed, 5 Oct 2022 20:47:54 +0200 Subject: [PATCH] Allow Linux extensions on Windows with containers --- .../nativeimage/UnsupportedOSBuildItem.java | 12 ++++++++++++ .../deployment/pkg/steps/NativeImageBuildStep.java | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/UnsupportedOSBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/UnsupportedOSBuildItem.java index 04ba9d9ab526e..159e406ecef18 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/UnsupportedOSBuildItem.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/UnsupportedOSBuildItem.java @@ -5,6 +5,7 @@ import static io.quarkus.dev.console.QuarkusConsole.IS_WINDOWS; import io.quarkus.builder.item.MultiBuildItem; +import io.quarkus.deployment.pkg.NativeConfig; /** * Native-image might not be supported for a particular @@ -30,4 +31,15 @@ public UnsupportedOSBuildItem(Os os, String error) { this.os = os; this.error = error; } + + public boolean triggerError(NativeConfig nativeConfig) { + return + // When the host OS is unsupported, it could have helped to + // run in a Linux builder image (e.g. an extension unsupported on Windows). + (os.active && !nativeConfig.isContainerBuild()) || + // If Linux is the OS the extension does not support, + // it fails in a container build regardless the host OS, + // because we have only Linux based builder images. + (nativeConfig.isContainerBuild() && os == Os.LINUX); + } } 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 be61fb022f7de..dbedfb8aee9d8 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 @@ -891,7 +891,9 @@ public NativeImageInvokerInfo build() { } if (unsupportedOSes != null && !unsupportedOSes.isEmpty()) { - final String errs = unsupportedOSes.stream().filter(o -> o.os.active).map(o -> o.error) + final String errs = unsupportedOSes.stream() + .filter(o -> o.triggerError(nativeConfig)) + .map(o -> o.error) .collect(Collectors.joining(", ")); if (!errs.isEmpty()) { throw new UnsupportedOperationException(errs);