From dd34f0911d655ea81926b8b014f34872937f367a Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Mon, 15 May 2023 11:45:18 +0300 Subject: [PATCH 1/2] Do not attempt to detect container runtime in native-sources build Closes: #33161 --- .../steps/NativeImageBuildRunnerDummy.java | 34 +++++++++++++++++++ .../pkg/steps/NativeImageBuildStep.java | 12 ++++++- .../main/asciidoc/building-native-image.adoc | 5 +-- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunnerDummy.java diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunnerDummy.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunnerDummy.java new file mode 100644 index 0000000000000..63ac4411aea39 --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunnerDummy.java @@ -0,0 +1,34 @@ +package io.quarkus.deployment.pkg.steps; + +import java.nio.file.Path; +import java.util.List; + +public class NativeImageBuildRunnerDummy extends NativeImageBuildRunner { + + private static final String MESSAGE = "NativeImageBuildRunnerDummy is note meant to be used to perform an actual build."; + private final boolean isContainer; + + public NativeImageBuildRunnerDummy(boolean isContainer) { + this.isContainer = isContainer; + } + + @Override + public boolean isContainer() { + return isContainer; + } + + @Override + protected String[] getGraalVMVersionCommand(List args) { + throw new RuntimeException(MESSAGE); + } + + @Override + protected String[] getBuildCommand(Path outputDir, List args) { + throw new RuntimeException(MESSAGE); + } + + @Override + protected void objcopy(Path outputDir, String... args) { + throw new RuntimeException(MESSAGE); + } +} 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 e4c313fcb650f..3885c3bb73598 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 @@ -329,7 +329,7 @@ private String getResultingExecutableName(String nativeImageName, boolean isCont /** * Resolves the runner factory. Happens quite early, *before* the build. */ - @BuildStep + @BuildStep(onlyIf = NativeBuild.class) public NativeImageRunnerBuildItem resolveNativeImageBuildRunner(NativeConfig nativeConfig) { boolean isExplicitContainerBuild = nativeConfig.containerBuild() .orElse(nativeConfig.containerRuntime().isPresent() || nativeConfig.remoteContainerBuild()); @@ -353,6 +353,16 @@ public NativeImageRunnerBuildItem resolveNativeImageBuildRunner(NativeConfig nat return new NativeImageRunnerBuildItem(new NativeImageBuildLocalContainerRunner(nativeConfig)); } + /** + * Creates a dummy runner for native-sources builds. This allows the creation of native-source jars without + * requiring podman/docker or a local native-image installation. + */ + @BuildStep(onlyIf = NativeSourcesBuild.class) + public NativeImageRunnerBuildItem dummyNativeImageBuildRunner(NativeConfig nativeConfig) { + boolean explicitContainerBuild = nativeConfig.isExplicitContainerBuild(); + return new NativeImageRunnerBuildItem(new NativeImageBuildRunnerDummy(explicitContainerBuild)); + } + private void copyJarSourcesToLib(OutputTargetBuildItem outputTargetBuildItem, CurateOutcomeBuildItem curateOutcomeBuildItem) { Path targetDirectory = outputTargetBuildItem.getOutputDirectory() diff --git a/docs/src/main/asciidoc/building-native-image.adoc b/docs/src/main/asciidoc/building-native-image.adoc index 8620002a85b7a..3e0243d52d816 100644 --- a/docs/src/main/asciidoc/building-native-image.adoc +++ b/docs/src/main/asciidoc/building-native-image.adoc @@ -786,10 +786,11 @@ $ ./mvnw clean package -Dquarkus.package.type=native-sources -Dquarkus.native.co cd target/native-sources docker run \ -it \ + --user $(id -ur):$(id -gr) \ --rm \ - --v $(pwd):/work \# <1> + -v $(pwd):/work \# <1> -w /work \# <2> - --entrypoint bin/sh \ + --entrypoint /bin/sh \ $(cat native-builder.image) \# <3> -c "native-image $(cat native-image.args) -J-Xmx4g"# <4> ---- From 95bcd7fe77c598a2dc4c729553e32d97c6b1667f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Jul 2023 22:42:48 +0000 Subject: [PATCH 2/2] Bump actions-cool/maintain-one-comment from 3.0.0 to 3.1.0 Bumps [actions-cool/maintain-one-comment](https://github.com/actions-cool/maintain-one-comment) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/actions-cool/maintain-one-comment/releases) - [Changelog](https://github.com/actions-cool/maintain-one-comment/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions-cool/maintain-one-comment/compare/v3.0.0...v3.1.0) --- updated-dependencies: - dependency-name: actions-cool/maintain-one-comment dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/preview-teardown.yml | 2 +- .github/workflows/preview.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview-teardown.yml b/.github/workflows/preview-teardown.yml index 6872052db0f3b..c489d75e9554f 100644 --- a/.github/workflows/preview-teardown.yml +++ b/.github/workflows/preview-teardown.yml @@ -15,7 +15,7 @@ jobs: id: deploy run: npx surge teardown https://quarkus-pr-main-${{ github.event.number }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }} || true - name: Update PR status comment - uses: actions-cool/maintain-one-comment@v3.0.0 + uses: actions-cool/maintain-one-comment@v3.1.0 with: token: ${{ secrets.GITHUB_TOKEN }} body: | diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index ce478d6d68ca5..07252233e295f 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -77,7 +77,7 @@ jobs: id: deploy run: npx surge ./_site --domain https://quarkus-pr-main-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }} - name: Update PR status comment on success - uses: actions-cool/maintain-one-comment@v3.0.0 + uses: actions-cool/maintain-one-comment@v3.1.0 with: token: ${{ secrets.GITHUB_TOKEN }} body: | @@ -88,7 +88,7 @@ jobs: number: ${{ steps.pr.outputs.id }} - name: Update PR status comment on failure if: ${{ failure() }} - uses: actions-cool/maintain-one-comment@v3.0.0 + uses: actions-cool/maintain-one-comment@v3.1.0 with: token: ${{ secrets.GITHUB_TOKEN }} body: |