Skip to content

Commit

Permalink
Fix support for GraalVM 22.2 (#507)
Browse files Browse the repository at this point in the history
* Fix support for GraalVM 22.2

This commit adds a workaround for GraalVM 22.2 native-image builder running
on module path. Because Micronaut uses features which use internal APIs (and
no workaround for that), building on 22.2 fails. This commit adds a flag
which will let users build by adding a module export.

See oracle/graal#4468

* Test against latest GraalVM
  • Loading branch information
melix authored Jul 20, 2022
1 parent e60176d commit 17ee298
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/graalvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
strategy:
matrix:
java: ['11']
graalvm: ['latest', 'dev']
steps:
# https://github.com/actions/virtual-environments/issues/709
- name: Free disk space
Expand All @@ -38,7 +39,7 @@ jobs:
- name: Setup GraalVM CE
uses: graalvm/setup-graalvm@v1
with:
version: '22.1.0'
version: ${{ matrix.graalvm }}
java-version: ${{ matrix.java }}
components: 'native-image'
- name: Build with Gradle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ COPY layers/resources /home/app/resources
COPY layers/application.jar /home/app/application.jar
RUN mkdir /home/app/config-dirs
COPY config-dirs/generateResourcesConfigFile /home/app/config-dirs/generateResourcesConfigFile
RUN native-image -cp /home/app/libs/*.jar:/home/app/resources:/home/app/application.jar --no-fallback -H:Name=application -H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile -H:Class=demo.app.Application
RUN native-image -cp /home/app/libs/*.jar:/home/app/resources:/home/app/application.jar --no-fallback -H:Name=application -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED -H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile -H:Class=demo.app.Application
FROM frolvlad/alpine-glibc:alpine-3.12
RUN apk update && apk add libstdc++
COPY --from=graalvm /home/app/application /app/application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ COPY layers/resources /home/alternate/resources
COPY layers/application.jar /home/alternate/application.jar
RUN mkdir /home/alternate/config-dirs
COPY config-dirs/generateResourcesConfigFile /home/alternate/config-dirs/generateResourcesConfigFile
RUN native-image -cp /home/alternate/libs/*.jar:/home/alternate/resources:/home/alternate/application.jar --no-fallback -H:Name=application -H:ConfigurationFileDirectories=/home/alternate/config-dirs/generateResourcesConfigFile -H:Class=example.Application
RUN native-image -cp /home/alternate/libs/*.jar:/home/alternate/resources:/home/alternate/application.jar --no-fallback -H:Name=application -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED -H:ConfigurationFileDirectories=/home/alternate/config-dirs/generateResourcesConfigFile -H:Class=example.Application
FROM frolvlad/alpine-glibc:alpine-3.12
RUN apk update && apk add libstdc++
HEALTHCHECK CMD curl -s localhost:8090/health | grep '"status":"UP"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void apply(Project project) {
inf.getIgnoreExistingResourcesConfigFile().convention(true);
inf.getRestrictToProjectDependencies().convention(true);
}));
options.jvmArgs("--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED");
Provider<String> richOutput = project.getProviders().systemProperty(RICH_OUTPUT_PROPERTY);
if (richOutput.isPresent()) {
options.getRichOutput().convention(richOutput.map(Boolean::parseBoolean));
Expand Down

0 comments on commit 17ee298

Please sign in to comment.