Skip to content

Commit 53fb831

Browse files
committed
Add end to end Maven guide and refactor Maven docs
1 parent edf6af1 commit 53fb831

File tree

6 files changed

+811
-168
lines changed

6 files changed

+811
-168
lines changed

docs/src/docs/asciidoc/end-to-end-gradle-guide.adoc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ all the way to some diagnostics tools that you can use to analyse native executa
99

1010
In case you only want to see how a simple application works in practise, you can check <<quickstart-gradle-plugin.adoc#,our demo>>.
1111

12-
== Prerequisites
1312
[[prerequisites]]
13+
== Prerequisites
1414

1515
- Before starting, make sure that you have GraalVM installed locally. You can https://www.graalvm.org/downloads/[download Oracle GraalVM from the official website].
1616
- In most cases you can run your Gradle project with almost any GraalVM version. All you have to do is to set `JAVA_HOME` environment variable to the release you want to use.
@@ -20,7 +20,7 @@ Note that in some cases, depending on the Gradle version you are using (https://
2020
You can run Gradle project with any GraalVM version you should set `GRAALVM_HOME` environment variable to point to whatever GraalVM release you want, and `JAVA_HOME` environment variable to some older version (like Java 17).
2121
This way, the Gradle plugin will build itself with Java specified in `JAVA_HOME` and your project with the version specified in `GRAALVM_HOME`.
2222

23-
23+
[[adding-plugin]]
2424
== Adding plugin
2525

2626
In order to use Native Image through gradle you must add the following block into your `build.gradle` file inside `plugins` block:
@@ -37,6 +37,7 @@ In order to use Native Image through gradle you must add the following block int
3737

3838
You can also check other versions of the plugin https://github.com/graalvm/native-build-tools/releases[here]
3939

40+
[[run-your-project]]
4041
== First runs of your project
4142

4243
This plugin works with the application plugin and will register a number of tasks that you may want to execute.
@@ -50,6 +51,7 @@ The main tasks you may want to use are:
5051
In the following sections you will find out how to use these tasks in practice.
5152

5253

54+
[[run-tests]]
5355
=== Run your tests
5456

5557
Running your tests should be a straight forward thing.
@@ -60,6 +62,7 @@ All you have to do is to write your tests under the test source (usually under _
6062
./gradlew nativeTest
6163
----
6264

65+
[[run-application]]
6366
=== Run your application
6467

6568
Once you added your plugin, you can try to build native image on a simple HelloWorld application (or with your main if you are not starting from the scratch).
@@ -102,6 +105,7 @@ Once the build is finished, run the following command to execute generated Nativ
102105
./gradlew nativeRun
103106
----
104107

108+
[[run-on-jvm]]
105109
==== Run on JVM
106110

107111
Note that **if you want to run your application (or maybe the native image agent later on your application) on the JVM** you should make the following changes in the `build.gradle`:
@@ -135,6 +139,7 @@ application {
135139
Note that the added block points to the main class placed under __/src/main/java/org.example.Main.java__. User should adjust this according to its application source set.
136140

137141

142+
[[configuration-options]]
138143
== Providing configuration options
139144

140145
The main configuring point of this plugin is the `graalvmNative` block that you added into `build.gradle` file.
@@ -158,7 +163,7 @@ graalvmNative {
158163

159164
Inside these blocks you can pass the following options:
160165

161-
- `imageName` -The name of the native image, defaults to the project name
166+
- `imageName` -The name of the native image
162167
- `mainClass` - The main class to use, defaults to the application.mainClass
163168
- `debug` - Determines if debug info should be generated, defaults to false (alternatively add --debug-native to the CLI)
164169
- `verbose` - Add verbose output (`false` by default)
@@ -244,8 +249,8 @@ graalvmNative {
244249
}
245250
----
246251

247-
== Collecting metadata
248252
[[collect-metadata]]
253+
== Collecting metadata
249254

250255
When your test/application starts to be a bit more complex things like **reflection**, **resources**, **serialization**, **proxies** or **jni** may be required.
251256
Since the Native Image has closed world assumption, all of these things must be known in advance during the image build.
@@ -354,6 +359,7 @@ Explanation of the `metadataCopy` block from above:
354359
- __outputDirectories.add("resources/META-INF/native-image/org.example")__ - means that we want to copy metadata into the given directory
355360
- __mergeWithExisting = false__ - means that we don't want to merge incoming metadata with the one that already exists on the location specified in `outputDirectories` (this makes sense since we don't have metadata on the given location already)
356361

362+
[[execute-metadata-copy-task]]
357363
==== Execute metadataCopy task
358364

359365
Once the metadata is generated and the `metadataCopy` task is configured, you can run the task with:
@@ -467,7 +473,8 @@ For example
467473
./gradlew -Pagent=direct nativeTest
468474
----
469475

470-
==== Common options
476+
[[common-agent-options]]
477+
==== Common agent options
471478

472479
All the mentioned modes shares certain common configuration options like:
473480

@@ -479,6 +486,7 @@ All the mentioned modes shares certain common configuration options like:
479486
- enableExperimentalUnsafeAllocationTracing
480487
- trackReflectionMetadata
481488

489+
[WARNING]
482490
**These options are for advanced usages, and you can read more about them https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/#agent-advanced-usage[here]**.
483491

484492
Complete example of the agent block should look like this:
@@ -686,6 +694,7 @@ After we regenerate the metadata with the new filter, `resource-config.json` gen
686694
As you can see there are no more entries that contain classes from `org.junit.platform.launcher` (as their condition) for example.
687695

688696

697+
[[maintain-generated-metadata]]
689698
== Maintain generated metadata
690699

691700
If you are a library maintainer, or your application became huge, you may consider covering most of your code with tests.
@@ -706,6 +715,7 @@ So if you modified existing metadata file(s) on the default location, please do
706715
This way you will keep your original metadata, and add a new one.
707716

708717

718+
[[reachability-metadata-repository]]
709719
== Reachability metadata repository
710720

711721
Native Build Tools (both Gradle and Maven plugins) picks metadata from Reachability metadata repository to ensure your application works out-of-box (if all metadata required by your app is already contributed to the metadata repository).
@@ -737,6 +747,7 @@ git clone [email protected]:oracle/graalvm-reachability-metadata.git
737747
- collect metadata as described https://github.com/oracle/graalvm-reachability-metadata/blob/master/docs/CollectingMetadata.md#collecting-metadata-for-a-library[here]
738748
- create a pull request and fill the checklist
739749

750+
[[track-diagnostics]]
740751
== Track diagnostics
741752

742753
If you want to explore details about native images you are generating, you can add:

0 commit comments

Comments
 (0)