From d6ff3e13e448e7e659bc04b1370a6483790083e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lazar=20Mitrovi=C4=87?= Date: Fri, 5 Aug 2022 20:41:21 +0200 Subject: [PATCH 1/3] Fix issue with "test-jar" type artifacts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lazar Mitrović --- .../buildtools/maven/AbstractNativeMojo.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/AbstractNativeMojo.java b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/AbstractNativeMojo.java index a55b604d6..67162aabd 100644 --- a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/AbstractNativeMojo.java +++ b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/AbstractNativeMojo.java @@ -277,7 +277,11 @@ protected List getBuildArgs() throws MojoExecutionException { return Collections.unmodifiableList(cliArgs); } - protected Path processArtifact(Artifact artifact, String artifactType) throws MojoExecutionException { + protected Path processSupportedArtifacts(Artifact artifact) throws MojoExecutionException { + return processArtifact(artifact, "jar", "test-jar", "war"); + } + + protected Path processArtifact(Artifact artifact, String... artifactTypes) throws MojoExecutionException { File artifactFile = artifact.getFile(); if (artifactFile == null) { @@ -285,8 +289,8 @@ protected Path processArtifact(Artifact artifact, String artifactType) throws Mo return null; } - if (!artifactType.equals(artifact.getType())) { - logger.warn("Ignoring non-jar type ImageClasspath Entry " + artifact); + if (Arrays.stream(artifactTypes).noneMatch(a -> a.equals(artifact.getType()))) { + logger.warn("Ignoring ImageClasspath Entry '" + artifact + "' with unsupported type '" + artifact.getType() + "'"); return null; } if (!artifactFile.exists()) { @@ -302,7 +306,7 @@ protected Path processArtifact(Artifact artifact, String artifactType) throws Mo } protected void addArtifactToClasspath(Artifact artifact) throws MojoExecutionException { - Optional.ofNullable(processArtifact(artifact, "jar")).ifPresent(imageClasspath::add); + Optional.ofNullable(processSupportedArtifacts(artifact)).ifPresent(imageClasspath::add); } protected void warnIfWrongMetaInfLayout(Path jarFilePath, Artifact artifact) throws MojoExecutionException { @@ -380,6 +384,7 @@ protected void populateClasspath() throws MojoExecutionException { populateApplicationClasspath(); addDependenciesToClasspath(); } + imageClasspath.removeIf(entry -> !entry.toFile().exists()); } protected String getClasspath() throws MojoExecutionException { From 1d7be6b1947f52fcd904b4bc45a7adc8f61b7a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lazar=20Mitrovi=C4=87?= Date: Mon, 8 Aug 2022 13:20:08 +0200 Subject: [PATCH 2/3] Deprecate `build` goal in favor of `compile-no-fork` goal. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lazar Mitrović --- docs/src/docs/asciidoc/announcement.adoc | 2 +- docs/src/docs/asciidoc/maven-plugin.adoc | 2 +- .../reproducers/issue-144/pom.xml | 2 +- .../maven/DeprecatedNativeBuildMojo.java | 65 +++++++++++++++++++ .../maven/NativeCompileNoForkMojo.java | 2 +- .../java-application-with-reflection/pom.xml | 2 +- .../java-application-with-resources/pom.xml | 2 +- samples/java-application-with-tests/pom.xml | 4 +- samples/java-application/pom.xml | 4 +- samples/java-library/pom.xml | 2 +- samples/metadata-repo-integration/pom.xml | 4 +- samples/native-config-integration/pom.xml | 4 +- 12 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/DeprecatedNativeBuildMojo.java diff --git a/docs/src/docs/asciidoc/announcement.adoc b/docs/src/docs/asciidoc/announcement.adoc index 1eab3490c..24f797cf1 100644 --- a/docs/src/docs/asciidoc/announcement.adoc +++ b/docs/src/docs/asciidoc/announcement.adoc @@ -144,7 +144,7 @@ Adding our new plugin to the existing _Maven_ project requires adding the follow build-native - build + compile-no-fork package diff --git a/docs/src/docs/asciidoc/maven-plugin.adoc b/docs/src/docs/asciidoc/maven-plugin.adoc index 5e6aa41fd..ba44a6b40 100644 --- a/docs/src/docs/asciidoc/maven-plugin.adoc +++ b/docs/src/docs/asciidoc/maven-plugin.adoc @@ -40,7 +40,7 @@ Add the following profile to your `pom.xml` file to register the `native-maven-p build-native - build + compile-no-fork package diff --git a/native-maven-plugin/reproducers/issue-144/pom.xml b/native-maven-plugin/reproducers/issue-144/pom.xml index e45bcdeca..0b1b3076b 100644 --- a/native-maven-plugin/reproducers/issue-144/pom.xml +++ b/native-maven-plugin/reproducers/issue-144/pom.xml @@ -92,7 +92,7 @@ build-native - build + compile-no-fork package diff --git a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/DeprecatedNativeBuildMojo.java b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/DeprecatedNativeBuildMojo.java new file mode 100644 index 000000000..60d86b80e --- /dev/null +++ b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/DeprecatedNativeBuildMojo.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.graalvm.buildtools.maven; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Mojo used to invoke native image building by attaching it to a phase. + * Deprecated in favor of compile-no-fork goal. + */ +@Deprecated +@Mojo(name = "build", defaultPhase = LifecyclePhase.PACKAGE, + requiresDependencyResolution = ResolutionScope.RUNTIME, + requiresDependencyCollection = ResolutionScope.RUNTIME) +public class DeprecatedNativeBuildMojo extends NativeCompileNoForkMojo { + + @Override + public void execute() throws MojoExecutionException { + logger.warn("'native:build' goal is deprecated. Use 'native:compile-no-fork' instead."); + super.execute(); + } + +} diff --git a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeCompileNoForkMojo.java b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeCompileNoForkMojo.java index 20074f534..7993159ac 100644 --- a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeCompileNoForkMojo.java +++ b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeCompileNoForkMojo.java @@ -63,7 +63,7 @@ * This goal runs native builds. It functions the same as the native:compile goal, but it * does not fork the build, so it is suitable for attaching to the build lifecycle. */ -@Mojo(name = "build", defaultPhase = LifecyclePhase.PACKAGE, +@Mojo(name = "compile-no-fork", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.RUNTIME, requiresDependencyCollection = ResolutionScope.RUNTIME) public class NativeCompileNoForkMojo extends AbstractNativeMojo { diff --git a/samples/java-application-with-reflection/pom.xml b/samples/java-application-with-reflection/pom.xml index 7c73bc338..c63d191ef 100644 --- a/samples/java-application-with-reflection/pom.xml +++ b/samples/java-application-with-reflection/pom.xml @@ -131,7 +131,7 @@ build-native - build + compile-no-fork package diff --git a/samples/java-application-with-resources/pom.xml b/samples/java-application-with-resources/pom.xml index 93cdbb560..ddcb7b99b 100644 --- a/samples/java-application-with-resources/pom.xml +++ b/samples/java-application-with-resources/pom.xml @@ -100,7 +100,7 @@ build-native generateResourceConfig - build + compile-no-fork package diff --git a/samples/java-application-with-tests/pom.xml b/samples/java-application-with-tests/pom.xml index a29173b56..7f3a1227c 100644 --- a/samples/java-application-with-tests/pom.xml +++ b/samples/java-application-with-tests/pom.xml @@ -95,7 +95,7 @@ build-native - build + compile-no-fork package @@ -191,7 +191,7 @@ build-native - build + compile-no-fork package diff --git a/samples/java-application/pom.xml b/samples/java-application/pom.xml index ad5140897..960ee2408 100644 --- a/samples/java-application/pom.xml +++ b/samples/java-application/pom.xml @@ -79,7 +79,7 @@ build-native - build + compile-no-fork package @@ -126,7 +126,7 @@ build-native - build + compile-no-fork package diff --git a/samples/java-library/pom.xml b/samples/java-library/pom.xml index 10554f59f..e23e77264 100644 --- a/samples/java-library/pom.xml +++ b/samples/java-library/pom.xml @@ -79,7 +79,7 @@ build-native - build + compile-no-fork package diff --git a/samples/metadata-repo-integration/pom.xml b/samples/metadata-repo-integration/pom.xml index 3cd5d8905..7d42540b5 100644 --- a/samples/metadata-repo-integration/pom.xml +++ b/samples/metadata-repo-integration/pom.xml @@ -80,7 +80,7 @@ build-native - build + compile-no-fork package @@ -109,7 +109,7 @@ build-native - build + compile-no-fork package diff --git a/samples/native-config-integration/pom.xml b/samples/native-config-integration/pom.xml index 6082d7ab8..258dd5d57 100644 --- a/samples/native-config-integration/pom.xml +++ b/samples/native-config-integration/pom.xml @@ -84,7 +84,7 @@ build-native - build + compile-no-fork package @@ -128,7 +128,7 @@ build-native - build + compile-no-fork package From 54aaf138767585f6dc102074b16544924f38ab4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lazar=20Mitrovi=C4=87?= Date: Wed, 10 Aug 2022 00:02:43 +0200 Subject: [PATCH 3/3] Fix failing tests CI tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lazar Mitrović --- .github/workflows/deploy-documentation.yml | 2 +- .github/workflows/deploy-snapshots.yml | 2 +- .github/workflows/test-native-gradle-plugin.yml | 10 ++++++---- .github/workflows/test-native-maven-plugin.yml | 4 ++-- .../maven/JavaApplicationFunctionalTest.groovy | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy-documentation.yml b/.github/workflows/deploy-documentation.yml index 88519ab65..780cf9550 100644 --- a/.github/workflows/deploy-documentation.yml +++ b/.github/workflows/deploy-documentation.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - graalvm-version: [ dev ] + graalvm-version: [ latest ] java-version: [ 11 ] os: [ ubuntu-20.04 ] steps: diff --git a/.github/workflows/deploy-snapshots.yml b/.github/workflows/deploy-snapshots.yml index cd460ed8f..196b77f2c 100644 --- a/.github/workflows/deploy-snapshots.yml +++ b/.github/workflows/deploy-snapshots.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - graalvm-version: [ dev ] + graalvm-version: [ latest ] java-version: [ 11 ] os: [ ubuntu-20.04 ] steps: diff --git a/.github/workflows/test-native-gradle-plugin.yml b/.github/workflows/test-native-gradle-plugin.yml index 2e6ceefdc..e2ddc2116 100644 --- a/.github/workflows/test-native-gradle-plugin.yml +++ b/.github/workflows/test-native-gradle-plugin.yml @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - graalvm-version: [ dev ] + graalvm-version: [ latest ] # dev java-version: [ 11 ] os: [ ubuntu-20.04 ] steps: @@ -53,8 +53,10 @@ jobs: strategy: fail-fast: false matrix: - gradle-version: ["current", "7.3.3", "7.2", "7.1", "6.8.3", "6.7.1"] - graalvm-version: [ dev ] + gradle-version: ["current", "6.7.1"] + # Following versions are disabled temporarily in order to speed up PR testing + # "7.3.3", "7.2", "7.1", "6.8.3" + graalvm-version: [ latest ] # dev java-version: [ 11 ] os: [ ubuntu-20.04 ] steps: @@ -81,7 +83,7 @@ jobs: strategy: fail-fast: false matrix: - graalvm-version: [ dev ] + graalvm-version: [ latest ] java-version: [ 11 ] os: [ windows-latest ] steps: diff --git a/.github/workflows/test-native-maven-plugin.yml b/.github/workflows/test-native-maven-plugin.yml index 4d9c96548..afff175c8 100644 --- a/.github/workflows/test-native-maven-plugin.yml +++ b/.github/workflows/test-native-maven-plugin.yml @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - graalvm-version: [ dev ] + graalvm-version: [ latest ] # dev java-version: [ 11 ] os: [ ubuntu-20.04 ] steps: @@ -55,7 +55,7 @@ jobs: strategy: fail-fast: false matrix: - graalvm-version: [ dev ] + graalvm-version: [ latest ] # dev java-version: [ 11 ] os: [ windows-latest ] steps: diff --git a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationFunctionalTest.groovy b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationFunctionalTest.groovy index 8f08c22b0..caa8b3b7c 100644 --- a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationFunctionalTest.groovy +++ b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationFunctionalTest.groovy @@ -49,13 +49,13 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest { when: mvn '-Pnative', '-DskipTests', '-DnativeDryRun', '-DuseArgFile=false', - '-Dclasspath=/testcp', '-Ddebug', '-Dfallback=false', '-Dverbose', '-DsharedLibrary', + '-Dclasspath=/', '-Ddebug', '-Dfallback=false', '-Dverbose', '-DsharedLibrary', '-DquickBuild', 'package' then: buildSucceeded - outputContains "native-image -cp /testcp -g --no-fallback --verbose --shared -Ob" + outputContains "native-image -cp / -g --no-fallback --verbose --shared -Ob" } def "can build and execute a native image with the Maven plugin"() {