You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Use Gradle to Build a Native Executable from a Java Application
9
9
10
10
You can use the Gradle plugin for GraalVM Native Image to build a native executable from a Java application in one step, in addition to a runnable JAR.
11
-
The plugin is provided as part of the [Native Build Tools project](https://graalvm.github.io/native-build-tools/latest/index.html) and uses the [Gradle build tool](https://gradle.org/).
11
+
The plugin is provided as part of the [Native Build Tools project](https://graalvm.github.io/native-build-tools/latest/index.html).
12
12
13
-
The Gradle plugin for GraalVM Native Image works with the `application` plugin and registers a number of tasks and extensions for you. For more information, see the [plugin documentation](https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html).
13
+
The Gradle plugin for GraalVM Native Image works with the `application` plugin and registers a number of tasks and extensions for you.
14
+
For more information, see the [plugin documentation](https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html).
14
15
15
16
This guide shows you how to use the Native Image Gradle plugin to build a native executable from a Java application, add support for dynamic features, and run JUnit tests.
16
17
@@ -26,7 +27,7 @@ We recommend that you follow the instructions and create the application step-by
> You must have [GraalVM installed with Native Image support](../README.md#install-native-image).
30
+
> Note: To use the Native Build Tools, first install GraalVM. The easiest way to install GraalVM is to use the [GraalVM JDK Downloader](https://github.com/graalvm/graalvm-jdk-downloader): `bash <(curl -sL https://get.graalvm.org/jdk)`.
30
31
31
32
## Prepare a Demo Application
32
33
@@ -160,15 +161,15 @@ git clone https://github.com/graalvm/graalvm-demos && cd graalvm-demos/fortune-d
160
161
161
162
Also, remove the dependency on `guava` that will not be used.
162
163
163
-
The next steps will be focused what you should do to enable the Native Image Gradle plugin.
164
+
The next steps demonstrate what you should do to enable the [Native Image Gradle plugin](https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html).
164
165
165
166
7. Register the Native Image Gradle plugin. Add the following to `plugins` section of your project’s _build.gradle_ file:
166
167
167
168
```xml
168
169
plugins {
169
170
// ...
170
171
171
-
id 'org.graalvm.buildtools.native' version '0.9.12'
172
+
id 'org.graalvm.buildtools.native' version '0.9.18'
172
173
}
173
174
```
174
175
The plugin discovers which JAR files it needs to pass to the `native-image` builder and what the executable main class should be.
> You must have [GraalVM installed with Native Image support](../README.md#install-native-image).
23
+
> Note: To use the Native Build Tools, first install GraalVM. The easiest way to install GraalVM is to use the [GraalVM JDK Downloader](https://github.com/graalvm/graalvm-jdk-downloader): `bash <(curl -sL https://get.graalvm.org/jdk)`.
24
24
25
25
## Prepare a Demo Application
26
26
@@ -204,16 +204,16 @@ git clone https://github.com/graalvm/graalvm-demos && cd graalvm-demos/fortune-d
The statements "hardcoded" plugin versions and the entry point classto your application.
216
-
The next steps will show you how enable the Maven plugin for GraalVM Native Image.
215
+
The statements "hardcoded" plugin versions and the entry point classto your application.
216
+
The next steps demonstrate what you should do to enable the [Native Image Maven plugin](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html).
217
217
218
218
6. Register the Maven plugin for GraalVM Native Image, `native-maven-plugin`, in the profile called `native` by adding the following to the _pom.xml_ file:
219
219
```xml
@@ -263,7 +263,7 @@ git clone https://github.com/graalvm/graalvm-demos && cd graalvm-demos/fortune-d
263
263
```
264
264
The plugin discovers which JAR files it needs to pass to the `native-image` builder and what the executable main classshould be. With this plugin you can already build a native executable directly with Maven by running `mvn -Pnative package` (if your application does not call any methods reflectively at run time).
265
265
266
-
This demo application is a little more complicated than `HelloWorld`, and and [requires metadata](../ReachabilityMetadata.md) before building a native executable. You do not have to configure anything manually: the Native Image Maven plugin can generate the required metadata for you by injecting the [Java agent](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#agent-support) at package time. The agent is disabled by default, and can be enabled in project's _pom.xml_ file or via the command line.
266
+
This demo application is a little more complicated than `HelloWorld`, and [requires metadata](../ReachabilityMetadata.md) before building a native executable. You do not have to configure anything manually: the Native Image Maven plugin can generate the required metadata for you by injecting the [Java agent](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#agent-support) at package time. The agent is disabled by default, and can be enabled in project's _pom.xml_ file or via the command line.
267
267
- To enable the agent via the _pom.xml_ file, specify `<enabled>true</enabled>` in the `native-maven-plugin` plugin configuration:
268
268
269
269
```xml
@@ -336,7 +336,7 @@ git clone https://github.com/graalvm/graalvm-demos && cd graalvm-demos/fortune-d
336
336
```
337
337
When the command completes a native executable, _fortune_, is created in the _/target_ directory of the project and ready for use.
338
338
339
-
The executable's name is derived from the artifact ID, but you can specify any custom name in the `native-maven-plugin` plugin within a <configuration> node:
339
+
The executable's name is derived from the artifact ID, but you can specify any custom name in `native-maven-plugin` within a `<configuration>` node:
0 commit comments