Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Native image update #7711

Merged
merged 10 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,22 @@ jobs:
- name: Test archetypes
run: etc/scripts/test-archetypes.sh
packaging:
timeout-minutes: 30
timeout-minutes: 60
strategy:
matrix:
os: [ ubuntu-20.04, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: graalvm/setup-graalvm@v1
with:
version: 23.1.0
java-version: 21
components: native-image
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: true
set-java-home: false
cache: maven
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/[email protected]
with:
Expand All @@ -159,3 +168,5 @@ jobs:
run: etc/scripts/test-packaging-jar.sh
- name: JLink packaging
run: etc/scripts/test-packaging-jlink.sh
- name: Native-Image packaging
run: etc/scripts/test-packaging-native.sh
2 changes: 1 addition & 1 deletion applications/parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<version.plugin.helidon>4.0.0-M2</version.plugin.helidon>
<version.plugin.helidon-cli>4.0.0-M2</version.plugin.helidon-cli>
<version.plugin.jar>3.0.2</version.plugin.jar>
<version.plugin.nativeimage>0.9.16</version.plugin.nativeimage>
<version.plugin.nativeimage>0.9.27</version.plugin.nativeimage>
<version.plugin.os>1.5.0.Final</version.plugin.os>
<version.plugin.protobuf>0.6.1</version.plugin.protobuf>
<version.plugin.resources>3.3.1</version.plugin.resources>
Expand Down
5 changes: 5 additions & 0 deletions applications/se/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<goal>compile</goal>
</goals>
<phase>package</phase>
<!-- configuration>
<buildArgs>
tomas-langer marked this conversation as resolved.
Show resolved Hide resolved
<arg>-strict-image-heap</arg>
</buildArgs>
</configuration -->
</execution>
</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

# 1st stage, build the app
FROM ghcr.io/graalvm/graalvm-ce:ol9-java21-22.3.1 as build

# Install native-image
RUN gu install native-image
FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build

WORKDIR /usr/share

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"resources": [
{
"pattern": "META-INF/helidon/media-types.properties"
},
{
"pattern": "io/helidon/common/media/type/default-media-types.properties"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"resources": [
{
"pattern": "mp-meta-config.yaml"
},
{
"pattern": "mp-meta-config.properties"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,51 @@
{
"pattern": "application.properties"
},
{
"pattern": "application.yaml"
},
{
"pattern": "application.json"
},
{
"pattern": "application.conf"
},
{
"pattern": "application.yml"
},
{
"pattern": "meta-config.properties"
},
{
"pattern": "meta-config.json"
},
{
"pattern": "meta-config.yaml"
},
{
"pattern": "meta-config.yml"
},
{
"pattern": "meta-config.conf"
},
{
"pattern": "config-profile.yaml"
},

{
"pattern": "config-profile.properties"
},

{
"pattern": "config-profile.json"
},

{
"pattern": "config-profile.conf"
},

{
"pattern": "config-profile.yml"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Oracle and/or its affiliates.
# Copyright (c) 2020, 2023 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,4 +14,4 @@
# limitations under the License.
#

Args=--initialize-at-build-time=org.slf4j -H:EnableURLProtocols=https
Args=--enable-https

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
},
{
"pattern": "config-profile-.*\\.yaml$"
},
{
"pattern": "application.yml"
},
{
"pattern": "meta-config.yml"
},
{
"pattern": "config-profile.yml"
},
{
"pattern": "config-profile-.*\\.yml$"
}
]
}

This file was deleted.

4 changes: 2 additions & 2 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<version.lib.google-oauth-client>1.33.3</version.lib.google-oauth-client>
<version.lib.google-error-prone>2.3.3</version.lib.google-error-prone>
<version.lib.google-protobuf>3.21.7</version.lib.google-protobuf>
<version.lib.graalvm>22.3.0</version.lib.graalvm>
<version.lib.graalvm>23.1.0</version.lib.graalvm>
<version.lib.graphql-java>18.6</version.lib.graphql-java>
<version.lib.graphql-java.extended.scalars>18.3</version.lib.graphql-java.extended.scalars>
<version.lib.gson>2.9.0</version.lib.gson>
Expand Down Expand Up @@ -915,7 +915,7 @@
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<artifactId>nativeimage</artifactId>
<version>${version.lib.graalvm}</version>
</dependency>
<dependency>
Expand Down
14 changes: 4 additions & 10 deletions docs/includes/guides/graalnative.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,16 @@ include::{rootdir}/includes/prerequisites.adoc[tag=prerequisites-graal]
== Install GraalVM and the Native Image Command

After {graalvm-doc-url}/docs/getting-started/[downloading and installing] GraalVM,
set the `GRAALVM_HOME` environment variable to point at your GraalVM installation.
set the `GRAALVM_HOME` environment variable to point at your GraalVM installation,
or use the GraalVM installation as your Java home.

[source,bash]
----
# Your path might be different
export GRAALVM_HOME=/usr/local/graalvm-jdk-21+35.1/Contents/Home/
----

Then install the optional `native-image` command:

[source,bash]
----
$GRAALVM_HOME/bin/gu install native-image
----

And verify:
Then verify:

[source,bash]
----
Expand Down Expand Up @@ -130,7 +124,7 @@ mvn package -Pnative-image
----

[TIP]
This uses the `helidon-maven-plugin` to perform the native compilation using your installed
This uses the `org.graalvm.buildtools:native-maven-plugin` to perform the native compilation using your installed
copy of GraalVM. It might take a while to complete.

Once it completes start the application using the native executable (no JVM!):
Expand Down
16 changes: 14 additions & 2 deletions docs/mp/aot.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2021, 2022 Oracle and/or its affiliates.
Copyright (c) 2021, 2023 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,10 +31,22 @@ application pom as a parent of your module, you can use the following steps to
build a native image from your application:

1. Create an environment variable `GRAALVM_HOME` pointing to your installation of
GraalVM with `native-image` installed
GraalVM, or use a GraalVM JDK to build your project
2. Add configuration to initialize your packages at build time (see below)
2. Run Maven command `mvn clean package -Pnative-image`
3. Execute the native executable created in `target` directory of your project

== Initialize at build time
Due to restrictions of our current implementation of integration with native image for CDI,
we must initialize a subset of types at build time.
As a result, all beans created within CDI need to be also initialized at build time.
tomas-langer marked this conversation as resolved.
Show resolved Hide resolved
Easiest approach to support such compilation is to:
1. Create `src/main/resources/META-INF/native-image/groupId/artifactId/native-image.properties` file (`groupId` and `artifactId` of the module you are building should be used)
2. Add the following line to the file:
```properties
Args=--initialize-at-build-time=your.application.package
```

== AOT supported modules

Some Helidon components are not (yet) supported in native image, some have
Expand Down
2 changes: 1 addition & 1 deletion etc/dependency-check-suppression.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
-->
<suppress>
<notes><![CDATA[
file name: graal-sdk-22.3.0.jar
file name: nativeimage-23.1.0.jar
]]></notes>
<packageUrl regex="true">^pkg:maven/org\.graalvm\.sdk/graal\-sdk@.*$</packageUrl>
<vulnerabilityName>CVE-2023-22006</vulnerabilityName>
Expand Down
Loading