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
By default, the plugin will try to use the `native-image` tool that is bundled with the JDK that is used to run Gradle.
73
+
By default, the plugin attempts to use the `native-image` tool bundled with the JDK running Gradle. Therefore, you must ensure that Gradle runs on a GraalVM JDK.
74
74
This means you must make sure that you run Gradle with a GraalVM JDK.
75
75
76
76
Alternatively, you may choose to:
77
77
78
-
1. Set up a `GRAALVM_HOME` environment variable pointing to your GraalVM installation, in which case the JDK pointed at this location will be used for Native Image builds instead
78
+
1. Set the `GRAALVM_HOME` environment variable to point to your GraalVM installation. When this variable is configured, the JDK specified at this location will be used for Native Image builds.
@@ -134,7 +134,7 @@ Again, be aware that the toolchain detection _cannot_ distinguish between GraalV
134
134
[[configuration]]
135
135
== Configuration
136
136
137
-
This plugin works with the `application` plugin and will register a number of tasks and extensions for you to configure.
137
+
This plugin works with the `application` plugin and registers a number of tasks and extensions for you to configure.
138
138
139
139
=== Available tasks
140
140
@@ -149,7 +149,7 @@ Those tasks are configured with reasonable defaults using the `graalvmNative` ex
149
149
150
150
The main executable is configured by the image named `main`, while the test executable is configured via the image named `test`.
151
151
152
-
=== Native image options
152
+
=== Configure Native Image
153
153
154
154
The link:javadocs/native-gradle-plugin/org/graalvm/buildtools/gradle/dsl/NativeImageOptions.html[NativeImageOptions] allows you to tweak how the native image is going to be built.
155
155
The plugin allows configuring the final binary, the <<test-binary-config,tests>> one, as well as apply options to both.
- `imageName` -The name of the native image, defaults to the project name
188
-
- `mainClass` - The main class to use, defaults to the application.mainClass
189
-
- `debug` - Determines if debug info should be generated, defaults to false (alternatively add --debug-native to the CLI)
190
-
- `verbose` - Add verbose output (`false` by default)
191
-
- `fallback` - Sets the fallback mode of native-image (`false` by default)
192
-
- `sharedLibrary` - Determines if image is a shared library
193
-
- `quickBuild` - Determines if image is being built in quick build mode
194
-
- `richOutput` - Determines if native-image building should be done with rich output
195
-
- `requiredVersion` - The minimal GraalVM version, can be `MAJOR`, `MAJOR.MINOR` or `MAJOR.MINOR.PATCH`
196
-
- `systemProperties` - Sets the system properties to use for the native image builder
197
-
- `configurationFileDirectories` - Adds a native image configuration file directory, containing files like reflection configuration
198
-
- `excludeConfig` - Excludes configuration that matches one of given regexes from JAR of dependency with said coordinates.
199
-
- `jvmArgs` - Passes the given argument directly to the JVM running the native image builder
200
-
- `useFatJar` - Instead of passing each jar individually, builds a fat jar
187
+
- `imageName` - The name of the native image, defaults to the project name
188
+
- `mainClass` - The main class to use, defaults to the _application.mainClass_
189
+
- `debug` - Determines if debug info should be generated; defaults to `false` (alternatively add `--debug-native` to the CLI)
190
+
- `verbose` - Adds verbose output (`false` by default)
191
+
- `fallback` - Sets the fallback mode of `native-image` (`false` by default)
192
+
- `sharedLibrary` - Determines if the image is a shared library
193
+
- `quickBuild` - Determines if the image is being built in quick build mode
194
+
- `richOutput` - Determines whether `native-image` building should produce rich output
195
+
- `systemProperties`: Defines the system properties to use for the `native-image` builder
196
+
- `configurationFileDirectories`: Adds a directory containing configuration files for `native-image`, such as reflection configuration
197
+
-`excludeConfig`: Excludes configuration that matches any of the specified regex patterns from the JAR of a dependency with the given coordinates
198
+
- `jvmArgs`: Passes the specified arguments directly to the JVM running the `native-image` builder
199
+
- `useFatJar`: Builds a fat JAR instead of passing each JAR individually
201
200
202
201
You can also pass **build-time** and **run-time** arguments:
203
202
203
+
- `buildArgs.add('<buildArg>')`: Learn more about possible build arguments https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/[here].
204
+
- `runtimeArgs.add('<runtimeArg>')`: Specifies runtime arguments consumed by your application.
205
+
204
206
- `buildArgs.add('<buildArg>')` - You can find more about possible build arguments https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/[here]
205
207
- `runtimeArgs.add('<runtimeArg>')` - Runtime arguments consumed by your application
206
208
207
209
208
210
NOTE: For options that can be set using command-line, if both DSL and command-line options are present, command-line options take precedence.
209
211
210
-
Native Image Agent options:
212
+
==== Native Image Tracing Agent options
211
213
212
-
* `defaultMode` - Default agent mode if one isn't specified using `-Pagent=mode_name`
214
+
* `defaultMode` - Specifies the default agent mode if one isn't specified using `-Pagent=mode_name`
213
215
* `enabled` - Enables the agent
214
-
* `modes`- you can configure following agent modes:
216
+
* `modes`- Configures the following agent modes::
215
217
** `standard` -The standard agent mode generates metadata without conditions
216
218
** `conditional` - The conditional agent mode generates metadata with conditions
217
-
*** `userCodeFilterPath` - Path to a filter file that determines classes which will be used in the metadata conditions
218
-
*** `extraFilterPath` - Optional, extra filter used to further filter the collected metadata
219
+
*** `userCodeFilterPath` - Path to a filter file that specifies which classes to include in metadata conditions
220
+
*** `extraFilterPath` - (Optional) An additional filter file to further refine the collected metadata
219
221
** `direct` - The direct agent mode allows users to directly pass options to the agent
220
-
*** `{output_dir}` - a special string expanded by the plugin to where the agent files would usually be output
221
-
* `tasksToInstrumentPredicate` - By default, if `-Pagent` is specified, all tasks that extend JavaForkOptions are instrumented.
222
+
*** `{output_dir}` - The output directory to store agent files
223
+
* `tasksToInstrumentPredicate` - By default, when `-Pagent` is specified, all tasks extending `JavaForkOptions` are instrumented.
222
224
This can be limited to only specific tasks that match this predicate.
223
225
224
226
[TIP]
225
227
Options like `callerFilterFiles`, `accessFilterFiles`, `builtinCallerFilter`, `builtinHeuristicFilter`, `enableExperimentalPredefinedClasses`, `enableExperimentalUnsafeAllocationTracing` and `trackReflectionMetadata`
226
228
are common for all agent modes and intended to be used for more advanced purposes. You can read more about those options https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/#agent-advanced-usage[here].
227
229
228
230
[[agent-support]]
229
-
==== Reflection support and running with the native agent
231
+
==== Reflection Registration with the Tracing Agent
230
232
231
-
If your project requires reflection, classpath resources, dynamic proxies or other features requiring explicit native configuration, it may prove helpful to first run your application or tests using the https://www.graalvm.org/reference-manual/native-image/metadata/AutomaticMetadataCollection/[native-image-agent].
233
+
If your project requires reflection, classpath resources, dynamic proxies, or other features that need explicit configuration, it may be helpful to first run your application or tests using the https://www.graalvm.org/reference-manual/native-image/metadata/AutomaticMetadataCollection/[Native Image Tracing Agent].
232
234
233
235
The Native Image Gradle plugin simplifies generation of the required metadata files by injecting the agent automatically for you (this includes, but is not limited to the reflection file).
234
236
235
-
Any task that extends `JavaForkOptions` (like `test`, `run` etc) can be instrumented by passing `-Pagent` to gradle when running said tasks.
237
+
Any task that extends `JavaForkOptions` (such as `test`, `run`, etc.) can be instrumented by passing `-Pagent` to Gradle when running those tasks.
236
238
237
239
The agent can run in multiple modes that dictate how the metadata is collected and merged.
238
240
239
241
Once the metadata is collected, it can be copied into the project using the `metadataCopy` task.
240
242
241
243
[source,bash, role="multi-language-sample"]
242
244
----
243
-
./gradlew -Pagent run # Runs on JVM with native-image-agent.
245
+
./gradlew -Pagent run # Runs on HotSpot with the agent
244
246
./gradlew metadataCopy --task run --dir src/main/resources/META-INF/native-image # Copies the metadata collected by the agent into the project sources
245
-
./gradlew nativeCompile # Builds image using metadata acquired by the agent.
247
+
./gradlew nativeCompile # Builds an image using the metadata acquired by the agent.
246
248
247
249
# For testing
248
250
./gradlew -Pagent nativeTest # Runs on JVM with the native-image agent, collects the metadata and uses it for testing on native-image.
249
251
----
250
252
251
-
The generated configuration files will be found in the `${buildDir}/native/agent-output/${taskName}` directory, for example, `build/native/agent-output/run`.
252
-
The plugin will also substitute `{output_dir}` in the agent options to point to this directory during the agent run.
253
+
The generated configuration files can be found in the `${buildDir}/native/agent-output/${taskName}` directory, for example, _build/native/agent-output/run_.
254
+
The plugin also substitutes `{output_dir}` in the agent options to point to this directory during the agent run.
253
255
254
256
[[max_parallel_builds]]
255
257
==== Max parallel builds
@@ -502,7 +504,7 @@ In order to generate a binary with instrumentation enabled, you should run the `
502
504
503
505
`./gradlew nativeCompile --pgo-instrument`
504
506
505
-
This will generate a binary under `build/native/nativeCompile` with the `-instrumented` suffix.
507
+
This will generate a binary under _build/native/nativeCompile_ with the `-instrumented` suffix.
The {doctitle} project provides plugins for different build tools to add support for building and testing native applications written in Java
5
-
(or any other language compiled to JVM bytecode) using the https://www.graalvm.org/reference-manual/native-image/[GraalVM Native Image].
6
-
At the moment, you can build your native projects using our Gradle or Maven plugin.
4
+
5
+
The {doctitle} project provides plugins for various build tools, enabling support for building and testing native applications written in Java (or any other language compiled to JVM bytecode) using https://www.graalvm.org/reference-manual/native-image/[GraalVM Native Image].
6
+
Currently, you can build your native applications using our Gradle or Maven plugins.
7
7
8
8
Each plugin takes metadata for available libraries from the https://github.com/oracle/graalvm-reachability-metadata[GraalVM reachability metadata repository]
9
9
to provide better experience during the development of your native project.
@@ -13,25 +13,25 @@ If you are using alternative build systems, see <<alternative-build-systems.adoc
13
13
[discrete]
14
14
=== Documentation
15
15
16
-
In case you are new to the Native Build Tools (either as an end user or a library author), read our:
16
+
If you're new to the Native Build Tools, whether as an end user or a library author, check out our:
You can see the full changelog <<changelog.adoc#,here>>.
26
+
For updates to the Native Build Tools between releases, see the full changelog <<changelog.adoc#,here>>.
27
27
28
28
[discrete]
29
29
=== Contributing
30
30
31
31
If you are interested in contributing or reporting an issue related to the plugins, please refer to the https://github.com/graalvm/native-build-tools[Native Build Tools repository].
32
-
Also, be aware that all contributors must sign the https://oca.opensource.oracle.com/[Oracle Contributor Agreement] (OCA).
32
+
Please note that all contributors must sign the https://oca.opensource.oracle.com/[Oracle Contributor Agreement] (OCA).
33
33
34
34
[TIP]
35
35
--
36
-
Please be aware that this repository should be used to report issues related to the Maven or Gradle plugins for GraalVM.
37
-
Please report issues which are specific to the framework itself (for example https://spring.io/[Spring Framework] or the https://micronaut.io/[Micronaut framework]) to their specific repositories.
36
+
This repository should be used for reporting issues related specifically to the Maven or Gradle plugins for GraalVM Native Image.
37
+
For issues related to frameworks such as https://spring.io/[Spring Framework] or https://micronaut.io/[Micronaut framework], please report them to their respective repositories.
0 commit comments