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
Copy file name to clipboardexpand all lines: docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc
+182-90
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ The GraalVM team
6
6
This guide leads you through the process of integrating Native Gradle Plugin with your project.
7
7
It starts from adding the plugin to your project, goes through some of the main functionalities that you may use (like collecting the metadata),
8
8
all the way to some diagnostics tools that you can use to analyse native executables you have made.
9
+
You can see an example of tests on which we tested whole guide <<example,here>>.
9
10
10
11
In case you only want to see how a simple application works in practise, you can check <<quickstart-gradle-plugin.adoc#,our demo>>.
11
12
@@ -178,10 +179,10 @@ Inside these blocks you can pass the following options:
178
179
- `jvmArgs` - Passes the given argument directly to the JVM running the native image builder
179
180
- `useFatJar` - Instead of passing each jar individually, builds a fat jar
180
181
181
-
You can also pass **build-time** and **run-time** options to the Native Image using:
182
+
You can also pass **build-time** and **run-time** arguments:
182
183
183
-
- `buildArgs.add('<buildArg>')` - You can find more about possible build arguments https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/[here]
184
-
- `runtimeArgs.add('<runtimeArg>')` - You can find more about possible runtime arguments https://www.graalvm.org/latest/reference-manual/native-image/overview/Options/[here]
184
+
- `buildArgs.add('<buildArg>')` - You can find more about possible build arguments https://www.graalvm.org/latest/reference-manual/native-image/overview/Options/[here] and https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildConfiguration/[here]
185
+
- `runtimeArgs.add('<runtimeArg>')` - Runtime arguments consumed by your application
185
186
186
187
Here is an example of additional options usage:
187
188
@@ -258,9 +259,9 @@ The easiest way how this information can be passed to the Native Image is throug
258
259
a single `reachability-metadata.json` file (for newer GraalVM versions) or multiple json files (`reflect-config.json`, `resource-config.json`, `proxy-config.json`, `serialization-config.json`, `jni-config.json`).
259
260
To learn more about metadata that Native Image consumes, https://www.graalvm.org/latest/reference-manual/native-image/metadata/[see this].
260
261
261
-
For example, if you run the test that tries to load resource `resource.txt`, and you don't have entry for that resource in the metadata config file, the resource can't be loaded (will be null).
262
+
For example, if you run the test that uses the reflection, and you don't have entry for that reflection call in the metadata config file, your test will fail.
262
263
263
-
To make your test/application work while using resources (like in this example) or other metadata, you should either generate metadata configurations or write them manually.
264
+
To make your test/application work while using reflection (like in this example) or other metadata, you should either generate metadata configurations or write them manually.
264
265
To generate metadata automatically, you can run your tests (or the main application) with the Native Image Agent, that will collect all the metadata your test/application require.
265
266
To enable the agent (through Native Gradle Plugin) you should either:
266
267
@@ -291,8 +292,6 @@ agent {
291
292
[.underline]#To generate the metadata file(s) for your `application` just run:#
292
293
293
294
- `./gradlew run` if you added the agent block to the configuration or `./gradlew -Pagent run` if you didn't. This command runs on JVM with native-image-agent and collects the metadata.
294
-
- `./gradlew nativeRun` if you added the agent block to the configuration or `./gradlew -Pagent nativeRun` if you didn't. This command runs on JVM with the native-image agent, collects the metadata and uses it for testing on native-image.
295
-
296
295
297
296
[WARNING]
298
297
====
@@ -380,7 +379,7 @@ Besides that, you can configure `metadataCopy` task through the command line as
380
379
381
380
Here is an example of a valid `metadataCopy` usage:
./gradlew metadataCopy --task test --dir resources/META-INF/native-image/org.example
386
385
----
@@ -414,9 +413,9 @@ First thing that you can configure is the agent mode.
414
413
There are three possible agent modes:
415
414
416
415
* `standard` - only generates metadata without any special processing (this is the default mode). No additional options available.
417
-
* `conditional` - entries of the generated metadata will be included in the Native Image only if the condition in the entry is satisfied. Consumes following additional options:
416
+
* `conditional` - entries of the generated metadata will be included in the Native Image only if the condition in the entry is satisfied. Consumes following options:
418
417
** `userCodeFilterPath` - specifies a filter file used to classify classes as user application classes. Generated conditions will only reference these classes See <<agent-filter-file, the following section>>
419
-
** `extraFilterPath` - extra filter used to further filter the collected metadata. See <<agent-filter-file, the following section>>
418
+
** `extraFilterPath` - (optional) extra filter used to further filter the collected metadata. See <<agent-filter-file, the following section>>
420
419
* `direct` - in this mode user configures the agent completely manually by adding all options with:
421
420
** `options.add("<option>")`
422
421
@@ -581,7 +580,6 @@ These filter files that agent consumes have the following structure:
581
580
The process how you can pass the config files to the agent is described in the <<additional-agent-options,previous section>>.
582
581
583
582
We can see on the example how different filter files affect generated metadata:
584
-
**Note that the following example was created with GraalVM 21 and that the format of the generated metadata can vary from version to version.**
585
583
586
584
We are starting with the simple filter file:
587
585
@@ -594,104 +592,143 @@ We are starting with the simple filter file:
594
592
}
595
593
----
596
594
597
-
This filter file will instruct the agent to include everything and therefore, you will get a massive config files.
598
-
For example this is how `resource-config.json` looks like:
595
+
This filter file will instruct the agent to include everything and therefore, you will get a massive config file.
596
+
For example this is how `reachability-metadata.json` looks like:
0 commit comments