From e4a4fcfbfee65accf4cb7df2b6908d47f3b7a12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20S=C3=A1nchez-Mariscal?= Date: Tue, 30 Jan 2024 17:59:35 +0100 Subject: [PATCH 1/4] Deprecate current mojo --- .../invoker.properties | 1 + .../mn-graalvm-resources-deprecated/pom.xml | 111 ++++++++++++++++++ .../micronaut/build/examples/Application.java | 9 ++ .../src/main/resources/application.yml | 3 + .../src/main/resources/logback.xml | 15 +++ .../verify.groovy | 5 + .../micronaut/maven/GraalVMResourcesMojo.java | 2 + 7 files changed, 146 insertions(+) create mode 100644 micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/invoker.properties create mode 100644 micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/pom.xml create mode 100644 micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/java/io/micronaut/build/examples/Application.java create mode 100644 micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/application.yml create mode 100644 micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/logback.xml create mode 100644 micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/verify.groovy diff --git a/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/invoker.properties b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/invoker.properties new file mode 100644 index 000000000..751aed0fe --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/invoker.properties @@ -0,0 +1 @@ +invoker.goals = -ntp mn:graalvm-resources \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/pom.xml b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/pom.xml new file mode 100644 index 000000000..76a54534a --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/pom.xml @@ -0,0 +1,111 @@ + + + 4.0.0 + io.micronaut.build.examples + mn-graalvm-resources-deprecated + 0.1 + ${packaging} + + + io.micronaut.platform + micronaut-parent + @it.micronaut.version@ + + + + jar + @it.micronaut.version@ + @project.version@ + netty + false + com.example.aot.generated + io.micronaut.build.examples.Application + + + + + central + https://repo.maven.apache.org/maven2 + + + + + + io.micronaut + micronaut-http-server-netty + compile + + + io.micronaut.serde + micronaut-serde-jackson + compile + + + ch.qos.logback + logback-classic + runtime + + + io.micronaut + micronaut-http-client + test + + + io.micronaut.test + micronaut-test-junit5 + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + + + + io.micronaut.maven + micronaut-maven-plugin + + aot-${packaging}.properties + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + + io.micronaut + micronaut-http-validation + ${micronaut.core.version} + + + io.micronaut.serde + micronaut-serde-processor + ${micronaut.serialization.version} + + + + -Amicronaut.processing.group=io.micronaut.build.examples + -Amicronaut.processing.module=mn-graalvm-resources-deprecated + + + + + + + \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/java/io/micronaut/build/examples/Application.java b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/java/io/micronaut/build/examples/Application.java new file mode 100644 index 000000000..af2c5c80e --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/java/io/micronaut/build/examples/Application.java @@ -0,0 +1,9 @@ +package io.micronaut.build.examples; + +import io.micronaut.runtime.Micronaut; + +public class Application { + public static void main(String[] args) { + Micronaut.run(Application.class); + } +} \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/application.yml b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/application.yml new file mode 100644 index 000000000..7c7c5a79d --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/application.yml @@ -0,0 +1,3 @@ +micronaut: + application: + name: mn-graalvm-resources-deprecated diff --git a/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/logback.xml b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/logback.xml new file mode 100644 index 000000000..822187082 --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/src/main/resources/logback.xml @@ -0,0 +1,15 @@ + + + + false + + + %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n + + + + + + + diff --git a/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/verify.groovy b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/verify.groovy new file mode 100644 index 000000000..ab80f2b4c --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/mn-graalvm-resources-deprecated/verify.groovy @@ -0,0 +1,5 @@ +File log = new File(basedir, 'build.log') +assert log.exists() +assert log.text.contains("BUILD SUCCESS") +assert log.text.contains("Goal 'graalvm-resources' is deprecated: Please use native:generateResourceConfig and/or native:generateTestResourceConfig instead.") + diff --git a/micronaut-maven-plugin/src/main/java/io/micronaut/maven/GraalVMResourcesMojo.java b/micronaut-maven-plugin/src/main/java/io/micronaut/maven/GraalVMResourcesMojo.java index d430ad86a..7bd178dba 100644 --- a/micronaut-maven-plugin/src/main/java/io/micronaut/maven/GraalVMResourcesMojo.java +++ b/micronaut-maven-plugin/src/main/java/io/micronaut/maven/GraalVMResourcesMojo.java @@ -38,8 +38,10 @@ * * @author Iván López * @since 2.0 + * @deprecated Please use native:generateResourceConfig and/or native:generateTestResourceConfig instead. */ @Mojo(name = GraalVMResourcesMojo.GRAALVM_RESOURCES) +@Deprecated(since = "4.4.0", forRemoval = true) public class GraalVMResourcesMojo extends ResourcesMojo { public static final String GRAALVM_RESOURCES = "graalvm-resources"; From 05be12ad3ec7493eb1cea6529baa983a206fb810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20S=C3=A1nchez-Mariscal?= Date: Thu, 1 Feb 2024 13:13:05 +0100 Subject: [PATCH 2/4] Fix tests --- micronaut-maven-integration-tests/pom.xml | 2 + .../Dockerfile | 2 + .../Dockerfile.aarch64 | 2 + .../Dockerfile.amd64 | 2 + .../Dockerfile | 2 + .../Dockerfile | 2 + .../dockerfile-docker-native-netty/Dockerfile | 2 + .../Dockerfile | 2 + .../Dockerfile | 2 + .../package native image aot/aot.properties | 37 ---- .../invoker.properties | 3 - .../openapi.properties | 1 - .../src/it/package native image aot/pom.xml | 170 ------------------ .../package native image aot/selector.groovy | 16 -- .../micronaut/build/examples/Application.java | 22 --- .../build/examples/greeter/Greeter.java | 8 - .../src/main/resources/application.yml | 3 - .../src/main/resources/logback.xml | 15 -- .../build/examples/ApplicationTest.java | 20 --- .../it/package native image aot/verify.groovy | 25 --- .../verify.groovy | 2 +- .../it/package-docker-native/verify.groovy | 2 +- .../aot-jar.properties | 33 ++++ .../aot-native-image.properties | 36 ++++ .../package-native-image-aot/aot.properties | 37 ---- .../openapi.properties | 5 + .../src/it/package-native-image-aot/pom.xml | 76 +++----- .../micronaut/build/examples/Application.java | 3 - .../build/examples/greeter/Greeter.java | 8 - .../it/package-native-image-aot/verify.groovy | 12 +- .../package-native-image/invoker.properties | 2 +- .../src/it/package-native-image/pom.xml | 78 +++----- .../micronaut/build/examples/Application.java | 3 - .../build/examples/greeter/Greeter.java | 8 - .../src/it/package-native-image/verify.groovy | 12 +- .../io/micronaut/maven/DockerfileMojo.java | 11 +- .../java/io/micronaut/maven/MojoUtils.java | 31 +++- .../resources/META-INF/plexus/components.xml | 65 ++++++- .../resources/dockerfiles/DockerfileNative | 2 + .../dockerfiles/DockerfileNativeDistroless | 2 + .../dockerfiles/DockerfileNativeLambda | 2 + .../dockerfiles/DockerfileNativeOracleCloud | 2 + .../dockerfiles/DockerfileNativeStatic | 2 + .../io/micronaut/maven/MojoUtilsTest.java | 26 +++ 44 files changed, 288 insertions(+), 510 deletions(-) delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/aot.properties delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/invoker.properties delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/openapi.properties delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/pom.xml delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/selector.groovy delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/Application.java delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/application.yml delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/logback.xml delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/src/test/java/io/micronaut/build/examples/ApplicationTest.java delete mode 100644 micronaut-maven-integration-tests/src/it/package native image aot/verify.groovy create mode 100644 micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-jar.properties create mode 100644 micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-native-image.properties delete mode 100644 micronaut-maven-integration-tests/src/it/package-native-image-aot/aot.properties delete mode 100644 micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java delete mode 100644 micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/greeter/Greeter.java create mode 100644 micronaut-maven-plugin/src/test/java/io/micronaut/maven/MojoUtilsTest.java diff --git a/micronaut-maven-integration-tests/pom.xml b/micronaut-maven-integration-tests/pom.xml index 81c75494a..55748e368 100644 --- a/micronaut-maven-integration-tests/pom.xml +++ b/micronaut-maven-integration-tests/pom.xml @@ -106,6 +106,8 @@ true ${java.specification.version} + + true diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-distroless/Dockerfile b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-distroless/Dockerfile index ae43d7a4c..6b4dcab09 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-distroless/Dockerfile +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-distroless/Dockerfile @@ -3,6 +3,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args -H:Class=io.micronaut.build.examples.Application -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.aarch64 b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.aarch64 index e12ecdc7b..91fcca884 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.aarch64 +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.aarch64 @@ -9,6 +9,8 @@ ENV PATH="/usr/lib/graalvm/bin:${PATH}" WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args -H:Class=io.micronaut.function.aws.runtime.MicronautLambdaRuntime -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.amd64 b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.amd64 index e09f23f7f..e466ef10b 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.amd64 +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-lambda/Dockerfile.amd64 @@ -9,6 +9,8 @@ ENV PATH="/usr/lib/graalvm/bin:${PATH}" WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args -H:Class=io.micronaut.function.aws.runtime.MicronautLambdaRuntime -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-base/Dockerfile b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-base/Dockerfile index 52d350797..469d1dc57 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-base/Dockerfile +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-base/Dockerfile @@ -3,6 +3,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args -H:Class=io.micronaut.build.examples.Application -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-ol/Dockerfile b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-ol/Dockerfile index 1f4a993de..b305f8fac 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-ol/Dockerfile +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty-custom-ol/Dockerfile @@ -3,6 +3,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args -H:Class=io.micronaut.build.examples.Application -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty/Dockerfile b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty/Dockerfile index 454e98ff0..971cc4027 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty/Dockerfile +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-netty/Dockerfile @@ -3,6 +3,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args -H:Class=io.micronaut.build.examples.Application -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-oracle-function/Dockerfile b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-oracle-function/Dockerfile index 4721d0213..4a91efbf3 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-oracle-function/Dockerfile +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-oracle-function/Dockerfile @@ -3,6 +3,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args --report-unsupported-elements-at-runtime -H:Class=com.fnproject.fn.runtime.EntryPoint -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-static/Dockerfile b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-static/Dockerfile index a6ec55e3e..347358c3a 100644 --- a/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-static/Dockerfile +++ b/micronaut-maven-integration-tests/src/it/dockerfile-docker-native-static/Dockerfile @@ -3,6 +3,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args --static --target=linux-amd64 --libc=musl -H:Class=io.micronaut.build.examples.Application -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/aot.properties b/micronaut-maven-integration-tests/src/it/package native image aot/aot.properties deleted file mode 100644 index 07479df25..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/aot.properties +++ /dev/null @@ -1,37 +0,0 @@ -# Caches environment property values: environment properties will be deemed immutable after application startup. -cached.environment.enabled = true - -# Deduces the environment at build time instead of runtime -deduce.environment.enabled = true - -# Generates GraalVM configuration files required to load the AOT optimizations -graalvm.config.enabled = true - -# Checks of existence of some types at build time instead of runtime -known.missing.types.enabled = true -# A list of types that the AOT analyzer needs to check for existence (comma separated) -known.missing.types.list = javax.inject.Inject - -# Replaces logback.xml with a pure Java configuration (NOT YET IMPLEMENTED!) -logback.xml.to.java.enabled = false - -# Precomputes Micronaut configuration property keys from the current environment variables -precompute.environment.properties.enabled = true - -# Scans reactive types at build time instead of runtime -scan.reactive.types.enabled = true - -# Scans for service types ahead-of-time, avoiding classpath scanning at startup -serviceloading.native.enabled = true - -# The list of environment names that this application can possibly use at runtime. -possible.environments = dev,prod,aws,gcs - -# Converts YAML configuration files to Java configuration -yaml.to.java.config.enabled = true - -# Precomputes property sources at build time -sealed.property.source.enabled = true - -# Configures the active environments when the AOT dynamic analysis is performed. -target.environments = lambda \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/invoker.properties b/micronaut-maven-integration-tests/src/it/package native image aot/invoker.properties deleted file mode 100644 index e22f84331..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/invoker.properties +++ /dev/null @@ -1,3 +0,0 @@ -invoker.goals = -ntp package -Dpackaging=native-image - -invoker.os.family = !windows \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/openapi.properties b/micronaut-maven-integration-tests/src/it/package native image aot/openapi.properties deleted file mode 100644 index 5686e641f..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/openapi.properties +++ /dev/null @@ -1 +0,0 @@ -swagger-ui.enabled=true diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/pom.xml b/micronaut-maven-integration-tests/src/it/package native image aot/pom.xml deleted file mode 100644 index 6bbdcbaf0..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/pom.xml +++ /dev/null @@ -1,170 +0,0 @@ - - 4.0.0 - io.micronaut.build.examples - package-native-image-aot-spaces - 0.1 - ${packaging} - - - io.micronaut.platform - micronaut-parent - @it.micronaut.version@ - - - - @it.micronaut.version@ - @project.version@ - io.micronaut.build.examples.Application - jar - netty - @micronaut.aot.version@ - true - io.micronaut.build.examples.generated - @native-maven-plugin.version@ - - - - - io.micronaut - micronaut-inject - compile - - - io.micronaut.validation - micronaut-validation - compile - - - io.micronaut - micronaut-http-server-netty - compile - - - io.micronaut - micronaut-http-client - compile - - - jakarta.annotation - jakarta.annotation-api - compile - - - ch.qos.logback - logback-classic - runtime - - - org.yaml - snakeyaml - runtime - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - io.micronaut.test - micronaut-test-junit5 - test - - - - - io.swagger.core.v3 - swagger-annotations - compile - - - - - - - - io.micronaut.maven - micronaut-maven-plugin - ${micronaut-maven-plugin.version} - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.5.1 - - - package - - shade - - - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - - io.micronaut - micronaut-http-validation - ${micronaut.core.version} - - - io.micronaut.openapi - micronaut-openapi - ${micronaut.openapi.version} - - - io.micronaut - micronaut-inject - - - - - - -Amicronaut.processing.group=io.micronaut.build.examples - -Amicronaut.processing.module=${project.artifactId} - - - - - - com.google.cloud.tools - jib-maven-plugin - - - docker.io/alvarosanchez/${project.artifactId}:${project.version} - - - - - - org.graalvm.buildtools - native-maven-plugin - true - - false - true - - - - - - - - - \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/selector.groovy b/micronaut-maven-integration-tests/src/it/package native image aot/selector.groovy deleted file mode 100644 index d5cdfd351..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/selector.groovy +++ /dev/null @@ -1,16 +0,0 @@ - -return isGraalJVM() - -static boolean isGraalJVM() { - return isGraal("jvmci.Compiler", "java.vendor.version") -} - -private static boolean isGraal(String... props) { - for (String prop : props) { - String vv = System.getProperty(prop) - if (vv != null && vv.toLowerCase(Locale.ENGLISH).contains("graal")) { - return true - } - } - return false -} \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/Application.java b/micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/Application.java deleted file mode 100644 index 642c8844d..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/Application.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.micronaut.build.examples; - -import io.micronaut.runtime.Micronaut; -import io.micronaut.build.examples.greeter.Greeter; - -import io.swagger.v3.oas.annotations.*; -import io.swagger.v3.oas.annotations.info.*; - -@OpenAPIDefinition( - info = @Info( - title = "app", - version = "0.0" - ) -) -public class Application { - - public static void main(String[] args) { - Greeter greeter = new Greeter(); - System.out.println(greeter.greet("world!")); - Micronaut.run(Application.class); - } -} \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java b/micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java deleted file mode 100644 index 06a811630..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.micronaut.build.examples.greeter; - -public class Greeter { - - public String greet(String name) { - return "HELLO " + name; - } -} diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/application.yml b/micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/application.yml deleted file mode 100644 index b51df2269..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/application.yml +++ /dev/null @@ -1,3 +0,0 @@ -micronaut: - application: - name: package-native-image-aot-spaces diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/logback.xml b/micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/logback.xml deleted file mode 100644 index 822187082..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/src/main/resources/logback.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - false - - - %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n - - - - - - - diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/src/test/java/io/micronaut/build/examples/ApplicationTest.java b/micronaut-maven-integration-tests/src/it/package native image aot/src/test/java/io/micronaut/build/examples/ApplicationTest.java deleted file mode 100644 index 010592b8b..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/src/test/java/io/micronaut/build/examples/ApplicationTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.micronaut.build.examples; - -import io.micronaut.runtime.EmbeddedApplication; -import io.micronaut.test.extensions.junit5.annotation.MicronautTest; -import jakarta.inject.Inject; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -@MicronautTest -public class ApplicationTest { - - @Inject - EmbeddedApplication application; - - @Test - void testItWorks() { - Assertions.assertTrue(application.isRunning()); - } - -} diff --git a/micronaut-maven-integration-tests/src/it/package native image aot/verify.groovy b/micronaut-maven-integration-tests/src/it/package native image aot/verify.groovy deleted file mode 100644 index 269223de4..000000000 --- a/micronaut-maven-integration-tests/src/it/package native image aot/verify.groovy +++ /dev/null @@ -1,25 +0,0 @@ -import java.util.jar.JarFile - -File log = new File(basedir, 'build.log') -assert log.exists() -assert log.text.contains("native:${nativeMavenPluginVersion}:compile") -assert log.text.contains("mn:${pluginVersion}:graalvm-resources") - -File resourceConfigFile = new File(basedir, 'target/classes/META-INF/native-image/io.micronaut.build.examples/package-native-image-aot-spaces/resource-config.json') -def resourceConfigJson = new groovy.json.JsonSlurper().parse(resourceConfigFile) - -assert resourceConfigJson.resources.pattern.any { it == "\\Qapplication.yml\\E" } -assert resourceConfigJson.resources.pattern.any { it == "\\QMETA-INF/swagger/app-0.0.yml\\E" } -assert resourceConfigJson.resources.pattern.any { it == "\\QMETA-INF/swagger/views/swagger-ui/index.html\\E" } - -File fatJar = new File(basedir, "target/package-native-image-aot-spaces-0.1.jar") -assert fatJar.exists() - -JarFile jarFile = new JarFile(fatJar) - -//Generated -assert jarFile.stream().anyMatch{ e -> e.name == 'io/micronaut/build/examples/generated/AOTApplicationContextConfigurer.class' } -assert jarFile.stream().anyMatch{ e -> e.name == 'META-INF/native-image/io.micronaut.build.examples.generated/native-image.properties' } - -// Resource filtering -assert jarFile.stream().noneMatch{ e -> e.name == 'application.yml' } \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-docker-native-lambda/verify.groovy b/micronaut-maven-integration-tests/src/it/package-docker-native-lambda/verify.groovy index 49b074f32..4caaa67b8 100644 --- a/micronaut-maven-integration-tests/src/it/package-docker-native-lambda/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-docker-native-lambda/verify.groovy @@ -1,6 +1,6 @@ File log = new File(basedir, 'build.log') assert log.exists() assert log.text.contains("BUILD SUCCESS") -assert log.text.contains("mn:${pluginVersion}:graalvm-resources") +assert log.text.contains("native:${nativeMavenPluginVersion}:generateTestResourceConfig") assert log.text.contains("Successfully built") assert log.text.contains("AWS Lambda Custom Runtime ZIP:") \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-docker-native/verify.groovy b/micronaut-maven-integration-tests/src/it/package-docker-native/verify.groovy index 325ecc986..952cb7b1c 100644 --- a/micronaut-maven-integration-tests/src/it/package-docker-native/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-docker-native/verify.groovy @@ -1,7 +1,7 @@ File log = new File(basedir, 'build.log') assert log.exists() -assert log.text.contains("mn:${pluginVersion}:graalvm-resources") +assert log.text.contains("native:${nativeMavenPluginVersion}:generateTestResourceConfig") assert log.text.contains("Using BASE_IMAGE_RUN: cgr.dev/chainguard/wolfi-base:latest") assert log.text.contains("Successfully tagged alvarosanchez/package-docker-native:0.1") assert log.text.contains("io.micronaut.runtime.Micronaut - Startup completed") \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-jar.properties b/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-jar.properties new file mode 100644 index 000000000..722fad411 --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-jar.properties @@ -0,0 +1,33 @@ +# AOT configuration properties for jar packaging +# Please review carefully the optimizations enabled below +# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details + +# Caches environment property values: environment properties will be deemed immutable after application startup. +cached.environment.enabled=true + +# Precomputes Micronaut configuration property keys from the current environment variables +precompute.environment.properties.enabled=true + +# Converts YAML configuration files to Java configuration +yaml.to.java.config.enabled=true + +# Scans for service types ahead-of-time, avoiding classpath scanning at startup +serviceloading.jit.enabled=true + +# Scans reactive types at build time instead of runtime +scan.reactive.types.enabled=true + +# Deduces the environment at build time instead of runtime +deduce.environment.enabled=true + +# Checks of existence of some types at build time instead of runtime +known.missing.types.enabled=true + +# Precomputes property sources at build time +sealed.property.source.enabled=true + +# The list of service types to be scanned (comma separated) +service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver + +# A list of types that the AOT analyzer needs to check for existence (comma separated) +known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-native-image.properties b/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-native-image.properties new file mode 100644 index 000000000..d584e3ce3 --- /dev/null +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot-native-image.properties @@ -0,0 +1,36 @@ +# AOT configuration properties for native-image packaging +# Please review carefully the optimizations enabled below +# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details + +# Caches environment property values: environment properties will be deemed immutable after application startup. +cached.environment.enabled=true + +# Precomputes Micronaut configuration property keys from the current environment variables +precompute.environment.properties.enabled=true + +# Converts YAML configuration files to Java configuration +yaml.to.java.config.enabled=true + +# Generates GraalVM configuration files required to load the AOT optimizations +graalvm.config.enabled=true + +# Scans for service types ahead-of-time, avoiding classpath scanning at startup +serviceloading.native.enabled=true + +# Scans reactive types at build time instead of runtime +scan.reactive.types.enabled=true + +# Deduces the environment at build time instead of runtime +deduce.environment.enabled=true + +# Checks of existence of some types at build time instead of runtime +known.missing.types.enabled=true + +# Precomputes property sources at build time +sealed.property.source.enabled=true + +# The list of service types to be scanned (comma separated) +service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver + +# A list of types that the AOT analyzer needs to check for existence (comma separated) +known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot.properties b/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot.properties deleted file mode 100644 index 07479df25..000000000 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/aot.properties +++ /dev/null @@ -1,37 +0,0 @@ -# Caches environment property values: environment properties will be deemed immutable after application startup. -cached.environment.enabled = true - -# Deduces the environment at build time instead of runtime -deduce.environment.enabled = true - -# Generates GraalVM configuration files required to load the AOT optimizations -graalvm.config.enabled = true - -# Checks of existence of some types at build time instead of runtime -known.missing.types.enabled = true -# A list of types that the AOT analyzer needs to check for existence (comma separated) -known.missing.types.list = javax.inject.Inject - -# Replaces logback.xml with a pure Java configuration (NOT YET IMPLEMENTED!) -logback.xml.to.java.enabled = false - -# Precomputes Micronaut configuration property keys from the current environment variables -precompute.environment.properties.enabled = true - -# Scans reactive types at build time instead of runtime -scan.reactive.types.enabled = true - -# Scans for service types ahead-of-time, avoiding classpath scanning at startup -serviceloading.native.enabled = true - -# The list of environment names that this application can possibly use at runtime. -possible.environments = dev,prod,aws,gcs - -# Converts YAML configuration files to Java configuration -yaml.to.java.config.enabled = true - -# Precomputes property sources at build time -sealed.property.source.enabled = true - -# Configures the active environments when the AOT dynamic analysis is performed. -target.environments = lambda \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/openapi.properties b/micronaut-maven-integration-tests/src/it/package-native-image-aot/openapi.properties index 5686e641f..eefd1cf23 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/openapi.properties +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/openapi.properties @@ -1 +1,6 @@ swagger-ui.enabled=true +redoc.enabled=false +rapidoc.enabled=false +rapidoc.bg-color=#14191f +rapidoc.text-color=#aec2e0 +rapidoc.sort-endpoints-by=method \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/pom.xml b/micronaut-maven-integration-tests/src/it/package-native-image-aot/pom.xml index 1973e1a5c..540a9bddf 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/pom.xml +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/pom.xml @@ -25,29 +25,14 @@ - - io.micronaut - micronaut-inject - compile - - - io.micronaut.validation - micronaut-validation - compile - io.micronaut micronaut-http-server-netty compile - io.micronaut - micronaut-http-client - compile - - - jakarta.annotation - jakarta.annotation-api + io.micronaut.serde + micronaut-serde-jackson compile @@ -61,13 +46,13 @@ runtime - org.junit.jupiter - junit-jupiter-api - test + io.micronaut.openapi + micronaut-openapi-annotations + provided - org.junit.jupiter - junit-jupiter-engine + io.micronaut + micronaut-http-client test @@ -75,14 +60,16 @@ micronaut-test-junit5 test - - - io.swagger.core.v3 - swagger-annotations - compile + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test - @@ -90,27 +77,15 @@ io.micronaut.maven micronaut-maven-plugin - ${micronaut-maven-plugin.version} + + aot-${packaging}.properties + - - - org.apache.maven.plugins - maven-shade-plugin - 3.5.1 - - - prepare-package - - shade - - - true - - - + maven-enforcer-plugin + org.apache.maven.plugins maven-compiler-plugin @@ -127,12 +102,11 @@ io.micronaut.openapi micronaut-openapi ${micronaut.openapi.version} - - - io.micronaut - micronaut-inject - - + + + io.micronaut.serde + micronaut-serde-processor + ${micronaut.serialization.version} diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/Application.java b/micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/Application.java index 642c8844d..a8cfd8fd1 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/Application.java +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/Application.java @@ -1,7 +1,6 @@ package io.micronaut.build.examples; import io.micronaut.runtime.Micronaut; -import io.micronaut.build.examples.greeter.Greeter; import io.swagger.v3.oas.annotations.*; import io.swagger.v3.oas.annotations.info.*; @@ -15,8 +14,6 @@ public class Application { public static void main(String[] args) { - Greeter greeter = new Greeter(); - System.out.println(greeter.greet("world!")); Micronaut.run(Application.class); } } \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java b/micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java deleted file mode 100644 index 06a811630..000000000 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/src/main/java/io/micronaut/build/examples/greeter/Greeter.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.micronaut.build.examples.greeter; - -public class Greeter { - - public String greet(String name) { - return "HELLO " + name; - } -} diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy b/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy index d2b2839a7..0c2923158 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy @@ -2,15 +2,15 @@ import java.util.jar.JarFile File log = new File(basedir, 'build.log') assert log.exists() -assert log.text.contains("native:${nativeMavenPluginVersion}:compile") -assert log.text.contains("mn:${pluginVersion}:graalvm-resources") +assert log.text.contains("native:${nativeMavenPluginVersion}:compile-no-fork") +assert log.text.contains("native:${nativeMavenPluginVersion}:generateTestResourceConfig") -File resourceConfigFile = new File(basedir, 'target/classes/META-INF/native-image/io.micronaut.build.examples/package-native-image-aot/resource-config.json') +File resourceConfigFile = new File(basedir, 'target/native/generated/generateResourceConfig/resource-config.json') def resourceConfigJson = new groovy.json.JsonSlurper().parse(resourceConfigFile) -assert resourceConfigJson.resources.pattern.any { it == "\\Qapplication.yml\\E" } -assert resourceConfigJson.resources.pattern.any { it == "\\QMETA-INF/swagger/app-0.0.yml\\E" } -assert resourceConfigJson.resources.pattern.any { it == "\\QMETA-INF/swagger/views/swagger-ui/index.html\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern == "\\Qapplication.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/app-0.0.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/views/swagger-ui/index.html\\E" } File fatJar = new File(basedir, "target/package-native-image-aot-0.1.jar") assert fatJar.exists() diff --git a/micronaut-maven-integration-tests/src/it/package-native-image/invoker.properties b/micronaut-maven-integration-tests/src/it/package-native-image/invoker.properties index fd616890f..3b398a745 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image/invoker.properties +++ b/micronaut-maven-integration-tests/src/it/package-native-image/invoker.properties @@ -1 +1 @@ -invoker.goals = -ntp package -Dpackaging=native-image \ No newline at end of file +invoker.goals = -ntp -e package -Dpackaging=native-image \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image/pom.xml b/micronaut-maven-integration-tests/src/it/package-native-image/pom.xml index aa617a6b5..0991ee674 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image/pom.xml +++ b/micronaut-maven-integration-tests/src/it/package-native-image/pom.xml @@ -24,38 +24,38 @@ io.micronaut - micronaut-inject + micronaut-http-server-netty compile - io.micronaut.validation - micronaut-validation + io.micronaut.serde + micronaut-serde-jackson compile - io.micronaut - micronaut-http-server-netty - compile + ch.qos.logback + logback-classic + runtime - io.micronaut - micronaut-http-client - compile + org.yaml + snakeyaml + runtime - io.micronaut - micronaut-runtime - compile + io.micronaut.openapi + micronaut-openapi-annotations + provided - jakarta.annotation - jakarta.annotation-api - compile + io.micronaut + micronaut-http-client + test - ch.qos.logback - logback-classic - runtime + io.micronaut.test + micronaut-test-junit5 + test org.junit.jupiter @@ -67,19 +67,6 @@ junit-jupiter-engine test - - io.micronaut.test - micronaut-test-junit5 - test - - - - - io.swagger.core.v3 - swagger-annotations - compile - - @@ -89,25 +76,9 @@ micronaut-maven-plugin ${micronaut-maven-plugin.version} - - - org.apache.maven.plugins - maven-shade-plugin - 3.5.1 - - - default-shade - prepare-package - - shade - - - true - - - + maven-enforcer-plugin org.graalvm.buildtools @@ -133,12 +104,11 @@ io.micronaut.openapi micronaut-openapi ${micronaut.openapi.version} - - - io.micronaut - micronaut-inject - - + + + io.micronaut.serde + micronaut-serde-processor + ${micronaut.serialization.version} diff --git a/micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/Application.java b/micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/Application.java index 642c8844d..a8cfd8fd1 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/Application.java +++ b/micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/Application.java @@ -1,7 +1,6 @@ package io.micronaut.build.examples; import io.micronaut.runtime.Micronaut; -import io.micronaut.build.examples.greeter.Greeter; import io.swagger.v3.oas.annotations.*; import io.swagger.v3.oas.annotations.info.*; @@ -15,8 +14,6 @@ public class Application { public static void main(String[] args) { - Greeter greeter = new Greeter(); - System.out.println(greeter.greet("world!")); Micronaut.run(Application.class); } } \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/greeter/Greeter.java b/micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/greeter/Greeter.java deleted file mode 100644 index 06a811630..000000000 --- a/micronaut-maven-integration-tests/src/it/package-native-image/src/main/java/io/micronaut/build/examples/greeter/Greeter.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.micronaut.build.examples.greeter; - -public class Greeter { - - public String greet(String name) { - return "HELLO " + name; - } -} diff --git a/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy b/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy index b8e19d5af..e3d624acf 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy @@ -1,14 +1,14 @@ File log = new File(basedir, 'build.log') assert log.exists() -assert log.text.contains("native:${nativeMavenPluginVersion}:compile") -assert log.text.contains("mn:${pluginVersion}:graalvm-resources") +assert log.text.contains("native:${nativeMavenPluginVersion}:compile-no-fork") +assert log.text.contains("native:${nativeMavenPluginVersion}:generateResourceConfig") -File resourceConfigFile = new File(basedir, 'target/classes/META-INF/native-image/io.micronaut.build.examples/package-native-image/resource-config.json') +File resourceConfigFile = new File(basedir, 'target/native/generated/generateResourceConfig/resource-config.json') def resourceConfigJson = new groovy.json.JsonSlurper().parse(resourceConfigFile) -assert resourceConfigJson.resources.pattern.any { it == "\\Qapplication.yml\\E" } -assert resourceConfigJson.resources.pattern.any { it == "\\QMETA-INF/swagger/app-0.0.yml\\E" } -assert resourceConfigJson.resources.pattern.any { it == "\\QMETA-INF/swagger/views/swagger-ui/index.html\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern == "\\Qapplication.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/app-0.0.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/views/swagger-ui/index.html\\E" } File fatJar = new File(basedir, "target/package-native-image-0.1.jar") assert fatJar.exists() \ No newline at end of file diff --git a/micronaut-maven-plugin/src/main/java/io/micronaut/maven/DockerfileMojo.java b/micronaut-maven-plugin/src/main/java/io/micronaut/maven/DockerfileMojo.java index b52cfe07c..df9c6eee0 100644 --- a/micronaut-maven-plugin/src/main/java/io/micronaut/maven/DockerfileMojo.java +++ b/micronaut-maven-plugin/src/main/java/io/micronaut/maven/DockerfileMojo.java @@ -18,6 +18,7 @@ import io.micronaut.maven.core.MicronautRuntime; import io.micronaut.maven.jib.JibMicronautExtension; import io.micronaut.maven.services.ApplicationConfigurationService; +import io.micronaut.maven.services.CompilerService; import io.micronaut.maven.services.DockerService; import io.micronaut.maven.jib.JibConfigurationService; import io.micronaut.maven.services.ExecutorService; @@ -25,6 +26,7 @@ import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; @@ -55,7 +57,7 @@ * @since 1.1 */ @Mojo(name = "dockerfile", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) -@Execute(goal = GraalVMResourcesMojo.GRAALVM_RESOURCES) +@Execute(phase = LifecyclePhase.PROCESS_CLASSES) public class DockerfileMojo extends AbstractDockerMojo { public static final String DOCKERFILE = "Dockerfile"; @@ -69,15 +71,18 @@ public class DockerfileMojo extends AbstractDockerMojo { public static final String DOCKERFILE_NATIVE_DISTROLESS = "DockerfileNativeDistroless"; public static final String DOCKERFILE_NATIVE_STATIC = "DockerfileNativeStatic"; public static final String DOCKERFILE_NATIVE_ORACLE_CLOUD = "DockerfileNativeOracleCloud"; + public static final String NATIVE_BUILD_TOOLS_MAVEN_PLUGIN = "org.graalvm.buildtools:native-maven-plugin"; private final ExecutorService executorService; + private final CompilerService compilerService; @Inject public DockerfileMojo(MavenProject mavenProject, DockerService dockerService, JibConfigurationService jibConfigurationService, ApplicationConfigurationService applicationConfigurationService, ExecutorService executorService, - MavenSession mavenSession, MojoExecution mojoExecution) { + MavenSession mavenSession, MojoExecution mojoExecution, CompilerService compilerService) { super(mavenProject, jibConfigurationService, applicationConfigurationService, dockerService, mavenSession, mojoExecution); this.executorService = executorService; + this.compilerService = compilerService; } @Override @@ -154,7 +159,7 @@ private void processOracleFunctionDockerfile(File dockerfile) throws IOException private Optional buildDockerfileNative(MicronautRuntime runtime) throws IOException, MavenInvocationException { getLog().info("Generating GraalVM args file"); - executorService.invokeGoal("org.graalvm.buildtools:native-maven-plugin", "write-args-file"); + executorService.invokeGoal(NATIVE_BUILD_TOOLS_MAVEN_PLUGIN, "write-args-file"); File dockerfile; switch (runtime.getBuildStrategy()) { case LAMBDA -> dockerfile = dockerService.loadDockerfileAsResource(DOCKERFILE_AWS_CUSTOM_RUNTIME); diff --git a/micronaut-maven-plugin/src/main/java/io/micronaut/maven/MojoUtils.java b/micronaut-maven-plugin/src/main/java/io/micronaut/maven/MojoUtils.java index 5c903895d..99a7e497e 100644 --- a/micronaut-maven-plugin/src/main/java/io/micronaut/maven/MojoUtils.java +++ b/micronaut-maven-plugin/src/main/java/io/micronaut/maven/MojoUtils.java @@ -27,6 +27,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import java.util.stream.Stream; import static io.micronaut.maven.AbstractDockerMojo.MOSTLY_STATIC_NATIVE_IMAGE_GRAALVM_FLAG; @@ -92,7 +93,7 @@ private static Stream parseNativeImageArgsFile(String argsFile) { .filter(arg -> !arg.startsWith("-H:Name")) .filter(arg -> !arg.startsWith("-H:Class")) .filter(arg -> !arg.startsWith("-H:Path")) - .filter(arg -> !arg.startsWith("-H:ConfigurationFileDirectories")) +// .filter(arg -> !arg.startsWith("-H:ConfigurationFileDirectories")) .flatMap(arg -> { if (arg.startsWith("@")) { String fileName = arg.substring(1); @@ -101,6 +102,8 @@ private static Stream parseNativeImageArgsFile(String argsFile) { // start the search at length - 3 to skip \Q or \E at the end int lastIndexOfSlash = arg.lastIndexOf(File.separator, arg.length() - 3); return Stream.of("\\Q/home/app/libs/" + arg.substring(lastIndexOfSlash + 1)); + } else if (arg.startsWith("-H:ConfigurationFileDirectories")) { + return Stream.of(parseConfigurationFilesDirectoriesArg(arg)); } else { return Stream.of(arg); } @@ -109,4 +112,30 @@ private static Stream parseNativeImageArgsFile(String argsFile) { throw new RuntimeException("Unable to find args file: " + argsFilePath); } } + + static String parseConfigurationFilesDirectoriesArg(String arg) { + String[] split = arg.split("="); + String[] directories = split[1].split(","); + if (arg.contains("generateResourceConfig") || arg.contains("generateTestResourceConfig")) { + return Stream.of(directories) + .map(directory -> { + String[] splitDirectory = directory.split("/"); + return "/home/app/" + splitDirectory[splitDirectory.length - 1]; + }) + .collect(Collectors.joining(",")) + .transform(s -> "-H:ConfigurationFileDirectories=" + s); + } else { + return Stream.of(directories) + .map(directory -> { + String[] splitDirectory = directory.split("/"); + String last4Directories = splitDirectory[splitDirectory.length - 4] + "/" + + splitDirectory[splitDirectory.length - 3] + "/" + + splitDirectory[splitDirectory.length - 2] + "/" + + splitDirectory[splitDirectory.length - 1]; + return "/home/app/graalvm-reachability-metadata/" + last4Directories; + }) + .collect(Collectors.joining(",")) + .transform(s -> "-H:ConfigurationFileDirectories=" + s); + } + } } diff --git a/micronaut-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/micronaut-maven-plugin/src/main/resources/META-INF/plexus/components.xml index 599b1f720..68c5f39dd 100644 --- a/micronaut-maven-plugin/src/main/resources/META-INF/plexus/components.xml +++ b/micronaut-maven-plugin/src/main/resources/META-INF/plexus/components.xml @@ -36,8 +36,7 @@ org.apache.maven.plugins:maven-surefire-plugin:test - ${project.groupId}:${project.artifactId}:${project.version}:aot-analysis, - ${project.groupId}:${project.artifactId}:${project.version}:graalvm-resources + ${project.groupId}:${project.artifactId}:${project.version}:aot-analysis org.apache.maven.plugins:maven-jar-plugin:jar, @@ -78,9 +77,24 @@ org.apache.maven.plugins:maven-compiler-plugin:compile + + org.graalvm.buildtools:native-maven-plugin:generateResourceConfig + + + org.apache.maven.plugins:maven-resources-plugin:testResources + + + org.apache.maven.plugins:maven-compiler-plugin:testCompile + + + org.graalvm.buildtools:native-maven-plugin:generateTestResourceConfig + + + ${project.groupId}:${project.artifactId}:${project.version}:start-testresources-service, + org.apache.maven.plugins:maven-surefire-plugin:test + ${project.groupId}:${project.artifactId}:${project.version}:aot-analysis, - ${project.groupId}:${project.artifactId}:${project.version}:graalvm-resources, org.apache.maven.plugins:maven-jar-plugin:jar @@ -115,6 +129,16 @@ org.apache.maven.plugins:maven-compiler-plugin:compile + + org.apache.maven.plugins:maven-resources-plugin:testResources + + + org.apache.maven.plugins:maven-compiler-plugin:testCompile + + + ${project.groupId}:${project.artifactId}:${project.version}:start-testresources-service, + org.apache.maven.plugins:maven-surefire-plugin:test + ${project.groupId}:${project.artifactId}:${project.version}:aot-analysis @@ -154,6 +178,16 @@ org.apache.maven.plugins:maven-compiler-plugin:compile + + org.apache.maven.plugins:maven-resources-plugin:testResources + + + org.apache.maven.plugins:maven-compiler-plugin:testCompile + + + ${project.groupId}:${project.artifactId}:${project.version}:start-testresources-service, + org.apache.maven.plugins:maven-surefire-plugin:test + ${project.groupId}:${project.artifactId}:${project.version}:aot-analysis @@ -181,18 +215,35 @@ default - - org.graalvm.buildtools:native-maven-plugin:add-reachability-metadata - + + ${project.groupId}:${project.artifactId}:${project.version}:generate-openapi-generic, + ${project.groupId}:${project.artifactId}:${project.version}:generate-openapi-client, + ${project.groupId}:${project.artifactId}:${project.version}:generate-openapi-server + org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile + + org.graalvm.buildtools:native-maven-plugin:generateResourceConfig + + + org.apache.maven.plugins:maven-resources-plugin:testResources + + + org.apache.maven.plugins:maven-compiler-plugin:testCompile + + + org.graalvm.buildtools:native-maven-plugin:generateTestResourceConfig + + + ${project.groupId}:${project.artifactId}:${project.version}:start-testresources-service, + org.apache.maven.plugins:maven-surefire-plugin:test + ${project.groupId}:${project.artifactId}:${project.version}:aot-analysis, - ${project.groupId}:${project.artifactId}:${project.version}:graalvm-resources, org.graalvm.buildtools:native-maven-plugin:write-args-file diff --git a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNative b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNative index 5b94cf0f1..af0bec3a6 100644 --- a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNative +++ b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNative @@ -5,6 +5,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args ARG CLASS_NAME RUN native-image @/home/app/graalvm-native-image.args -H:Class=${CLASS_NAME} -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeDistroless b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeDistroless index 5b94cf0f1..af0bec3a6 100644 --- a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeDistroless +++ b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeDistroless @@ -5,6 +5,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args ARG CLASS_NAME RUN native-image @/home/app/graalvm-native-image.args -H:Class=${CLASS_NAME} -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeLambda b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeLambda index 823aacb2b..7ea52dff0 100644 --- a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeLambda +++ b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeLambda @@ -11,6 +11,8 @@ ENV PATH="/usr/lib/graalvm/bin:${PATH}" WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args ARG CLASS_NAME RUN native-image @/home/app/graalvm-native-image.args -H:Class=${CLASS_NAME} -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeOracleCloud b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeOracleCloud index 45d102619..37679d75f 100644 --- a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeOracleCloud +++ b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeOracleCloud @@ -5,6 +5,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args RUN native-image @/home/app/graalvm-native-image.args --report-unsupported-elements-at-runtime -H:Class=com.fnproject.fn.runtime.EntryPoint -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeStatic b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeStatic index b0b56669b..8aa0906ff 100644 --- a/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeStatic +++ b/micronaut-maven-plugin/src/main/resources/dockerfiles/DockerfileNativeStatic @@ -5,6 +5,8 @@ WORKDIR /home/app COPY classes /home/app/classes COPY dependency/* /home/app/libs/ +COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata +COPY nativ[e]/generated /home/app/ COPY *.args /home/app/graalvm-native-image.args ARG CLASS_NAME RUN native-image @/home/app/graalvm-native-image.args --static --target=linux-amd64 --libc=musl -H:Class=${CLASS_NAME} -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" diff --git a/micronaut-maven-plugin/src/test/java/io/micronaut/maven/MojoUtilsTest.java b/micronaut-maven-plugin/src/test/java/io/micronaut/maven/MojoUtilsTest.java new file mode 100644 index 000000000..36c4579ab --- /dev/null +++ b/micronaut-maven-plugin/src/test/java/io/micronaut/maven/MojoUtilsTest.java @@ -0,0 +1,26 @@ +package io.micronaut.maven; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class MojoUtilsTest { + + @Test + void testParseReachabilityMetadataConfigFiles() { + String arg = "-H:ConfigurationFileDirectories=/someDir/graalvm-reachability-metadata/someOtherDir/io.netty/netty-common/4.1.80.Final,/someDir/graalvm-reachability-metadata/someOtherDir/io.netty/netty-buffer/4.1.80.Final,/someDir/graalvm-reachability-metadata/someOtherDir/io.netty/netty-handler/4.1.80.Final,/someDir/graalvm-reachability-metadata/someOtherDir/ch.qos.logback/logback-classic/1.4.1,/someDir/graalvm-reachability-metadata/someOtherDir/io.netty/netty-transport/4.1.80.Final,/someDir/graalvm-reachability-metadata/someOtherDir/io.netty/netty-codec-http/4.1.80.Final,/someDir/graalvm-reachability-metadata/someOtherDir/io.netty/netty-codec-http2/4.1.80.Final"; + + String result = MojoUtils.parseConfigurationFilesDirectoriesArg(arg); + + assertEquals("-H:ConfigurationFileDirectories=/home/app/graalvm-reachability-metadata/someOtherDir/io.netty/netty-common/4.1.80.Final,/home/app/graalvm-reachability-metadata/someOtherDir/io.netty/netty-buffer/4.1.80.Final,/home/app/graalvm-reachability-metadata/someOtherDir/io.netty/netty-handler/4.1.80.Final,/home/app/graalvm-reachability-metadata/someOtherDir/ch.qos.logback/logback-classic/1.4.1,/home/app/graalvm-reachability-metadata/someOtherDir/io.netty/netty-transport/4.1.80.Final,/home/app/graalvm-reachability-metadata/someOtherDir/io.netty/netty-codec-http/4.1.80.Final,/home/app/graalvm-reachability-metadata/someOtherDir/io.netty/netty-codec-http2/4.1.80.Final", result); + } + + @Test + void testParseGenerateResourceConfigFiles() { + String arg = "-H:ConfigurationFileDirectories=/someDir/native/generated/generateTestResourceConfig,/someDir/native/generated/generateResourceConfig"; + + String result = MojoUtils.parseConfigurationFilesDirectoriesArg(arg); + + assertEquals("-H:ConfigurationFileDirectories=/home/app/generateTestResourceConfig,/home/app/generateResourceConfig", result); + } +} From d0c7fbb2f007ae19acd60b702940a049da5a75e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20S=C3=A1nchez-Mariscal?= Date: Thu, 1 Feb 2024 14:38:10 +0100 Subject: [PATCH 3/4] Fix tests --- .../src/it/deploy/pom.xml | 52 +++++++++---------- .../micronaut/build/examples/Application.java | 3 -- .../build/examples/greeter/Greeter.java | 8 --- .../it/package-native-image-aot/verify.groovy | 4 +- .../src/it/package-native-image/verify.groovy | 4 +- 5 files changed, 29 insertions(+), 42 deletions(-) delete mode 100644 micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/greeter/Greeter.java diff --git a/micronaut-maven-integration-tests/src/it/deploy/pom.xml b/micronaut-maven-integration-tests/src/it/deploy/pom.xml index 6997bf900..2e5b4204c 100644 --- a/micronaut-maven-integration-tests/src/it/deploy/pom.xml +++ b/micronaut-maven-integration-tests/src/it/deploy/pom.xml @@ -24,39 +24,34 @@ io.micronaut - micronaut-inject + micronaut-http-server-netty compile - io.micronaut.validation - micronaut-validation + io.micronaut.serde + micronaut-serde-jackson compile - io.micronaut - micronaut-http-server-netty - compile + ch.qos.logback + logback-classic + runtime - io.micronaut - micronaut-http-client - compile + org.yaml + snakeyaml + runtime - jakarta.annotation - jakarta.annotation-api - compile + io.micronaut + micronaut-http-client + test - ch.qos.logback - logback-classic - runtime + io.micronaut.test + micronaut-test-junit5 + test - - - - - org.junit.jupiter junit-jupiter-api @@ -67,11 +62,6 @@ junit-jupiter-engine test - - io.micronaut.test - micronaut-test-junit5 - test - @@ -81,6 +71,10 @@ micronaut-maven-plugin ${micronaut-maven-plugin.version} + + org.apache.maven.plugins + maven-enforcer-plugin + org.apache.maven.plugins maven-compiler-plugin @@ -90,9 +84,14 @@ io.micronaut - micronaut-graal + micronaut-http-validation ${micronaut.core.version} + + io.micronaut.serde + micronaut-serde-processor + ${micronaut.serialization.version} + -Amicronaut.processing.group=io.micronaut.build.examples @@ -113,5 +112,4 @@ - \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/Application.java b/micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/Application.java index 7167c8618..b1b8b5fa5 100644 --- a/micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/Application.java +++ b/micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/Application.java @@ -1,13 +1,10 @@ package io.micronaut.build.examples; import io.micronaut.runtime.Micronaut; -import io.micronaut.build.examples.greeter.Greeter; public class Application { public static void main(String[] args) { - Greeter greeter = new Greeter(); - System.out.println(greeter.greet("world!")); Micronaut.run(Application.class); } } \ No newline at end of file diff --git a/micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/greeter/Greeter.java b/micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/greeter/Greeter.java deleted file mode 100644 index 06a811630..000000000 --- a/micronaut-maven-integration-tests/src/it/deploy/src/main/java/io/micronaut/build/examples/greeter/Greeter.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.micronaut.build.examples.greeter; - -public class Greeter { - - public String greet(String name) { - return "HELLO " + name; - } -} diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy b/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy index 0c2923158..186dc84a7 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy @@ -9,8 +9,8 @@ File resourceConfigFile = new File(basedir, 'target/native/generated/generateRes def resourceConfigJson = new groovy.json.JsonSlurper().parse(resourceConfigFile) assert resourceConfigJson.resources.includes.any { it.pattern == "\\Qapplication.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/app-0.0.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/views/swagger-ui/index.html\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains == "app-0.0.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains == "index.html\\E" } File fatJar = new File(basedir, "target/package-native-image-aot-0.1.jar") assert fatJar.exists() diff --git a/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy b/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy index e3d624acf..c32778636 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy @@ -7,8 +7,8 @@ File resourceConfigFile = new File(basedir, 'target/native/generated/generateRes def resourceConfigJson = new groovy.json.JsonSlurper().parse(resourceConfigFile) assert resourceConfigJson.resources.includes.any { it.pattern == "\\Qapplication.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/app-0.0.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern == "\\QMETA-INF/swagger/views/swagger-ui/index.html\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains == "app-0.0.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains == "index.html\\E" } File fatJar = new File(basedir, "target/package-native-image-0.1.jar") assert fatJar.exists() \ No newline at end of file From 6ae0e1b474ad6d494a283c290173fb72f27ed223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20S=C3=A1nchez-Mariscal?= Date: Thu, 1 Feb 2024 15:33:48 +0100 Subject: [PATCH 4/4] Fix tests --- .../src/it/package-native-image-aot/verify.groovy | 4 ++-- .../src/it/package-native-image/verify.groovy | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy b/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy index 186dc84a7..9bfafa7fe 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-native-image-aot/verify.groovy @@ -9,8 +9,8 @@ File resourceConfigFile = new File(basedir, 'target/native/generated/generateRes def resourceConfigJson = new groovy.json.JsonSlurper().parse(resourceConfigFile) assert resourceConfigJson.resources.includes.any { it.pattern == "\\Qapplication.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern.contains == "app-0.0.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern.contains == "index.html\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains "app-0.0.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains "index.html\\E" } File fatJar = new File(basedir, "target/package-native-image-aot-0.1.jar") assert fatJar.exists() diff --git a/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy b/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy index c32778636..01206b720 100644 --- a/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy +++ b/micronaut-maven-integration-tests/src/it/package-native-image/verify.groovy @@ -7,8 +7,8 @@ File resourceConfigFile = new File(basedir, 'target/native/generated/generateRes def resourceConfigJson = new groovy.json.JsonSlurper().parse(resourceConfigFile) assert resourceConfigJson.resources.includes.any { it.pattern == "\\Qapplication.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern.contains == "app-0.0.yml\\E" } -assert resourceConfigJson.resources.includes.any { it.pattern.contains == "index.html\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains "app-0.0.yml\\E" } +assert resourceConfigJson.resources.includes.any { it.pattern.contains "index.html\\E" } File fatJar = new File(basedir, "target/package-native-image-0.1.jar") assert fatJar.exists() \ No newline at end of file