Skip to content

Commit 10a8b51

Browse files
committed
Fix documentation according to the new DSL
1 parent c897eb0 commit 10a8b51

File tree

1 file changed

+78
-61
lines changed

1 file changed

+78
-61
lines changed

docs/src/docs/asciidoc/gradle-plugin.adoc

Lines changed: 78 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ This plugin works with the `application` plugin and will register a number of ta
129129

130130
The main tasks that you will want to execute are:
131131

132-
- `nativeBuild`, which will trigger the generation of a native executable of your application
132+
- `nativeAssemble`, which will trigger the generation of a native executable of your application
133133
- `nativeRun`, which executes the generated native executable
134-
- `nativeTestBuild`, which will build a native image with tests found in the `test` source set
134+
- `nativeTestAssemble`, which will build a native image with tests found in the `test` source set
135135
- `nativeTest`, which will <<testing,execute tests>> found in the `test` source set in native mode
136136

137-
Those tasks are configured with reasonable defaults respectively by the `nativeBuild` and `nativeTest` extensions, which are of type link:javadocs/native-gradle-plugin/org/graalvm/buildtools/gradle/dsl/NativeImageOptions.html[NativeImageOptions].
137+
Those tasks are configured with reasonable defaults using the `javaNative` extension `images` container of type link:javadocs/native-gradle-plugin/org/graalvm/buildtools/gradle/dsl/NativeImageOptions.html[NativeImageOptions].
138+
139+
The main executable is configured by the image named `main`, while the test executable is configured via the image named `test`.
138140

139141
=== Native image options
140142

@@ -148,21 +150,29 @@ If you want to use a different toolchain, for example a GraalVM Enterprise Editi
148150
.Selecting the GraalVM toolchain
149151
[role="multi-language-sample"]
150152
```groovy
151-
nativeBuild {
152-
javaLauncher = javaToolchains.launcherFor {
153-
languageVersion = JavaLanguageVersion.of(8)
154-
vendor = JvmVendorSpec.matching("GraalVM Enterprise")
155-
}
153+
javaNative {
154+
images {
155+
main {
156+
javaLauncher = javaToolchains.launcherFor {
157+
languageVersion = JavaLanguageVersion.of(8)
158+
vendor = JvmVendorSpec.matching("GraalVM Enterprise")
159+
}
160+
}
161+
}
156162
}
157163
```
158164

159165
[role="multi-language-sample"]
160166
```kotlin
161-
nativeBuild {
162-
javaLauncher.set(javaToolchains.launcherFor {
163-
languageVersion.set(JavaLanguageVersion.of(8))
164-
vendor.set(JvmVendorSpec.matching("GraalVM Enterprise"))
165-
})
167+
javaNative {
168+
images {
169+
main {
170+
javaLauncher.set(javaToolchains.launcherFor {
171+
languageVersion.set(JavaLanguageVersion.of(8))
172+
vendor.set(JvmVendorSpec.matching("GraalVM Enterprise"))
173+
})
174+
}
175+
}
166176
}
167177
```
168178

@@ -173,58 +183,65 @@ The following configuration options are available for building images:
173183
.NativeImageOption configuration
174184
[role="multi-language-sample"]
175185
```groovy
176-
nativeBuild {
177-
// Main options
178-
imageName = 'application' // The name of the native image, defaults to the project name
179-
mainClass = 'org.test.Main' // The main class to use, defaults to the application.mainClass
180-
debug = true // Determines if debug info should be generated, defaults to false
181-
verbose = true // Add verbose output, defaults to false
182-
fallback = true // Sets the fallback mode of native-image, defaults to false
183-
sharedLibrary = false // Determines if image is a shared library, defaults to false if `java-library` plugin isn't included
184-
185-
systemProperties = [name1: 'value1', name2: 'value2'] // Sets the system properties to use for the native image builder
186-
configurationFileDirectories.from(file('src/my-config')) // Adds a native image configuration file directory, containing files like reflection configuration
187-
188-
// Advanced options
189-
buildArgs.add('-H:Extra') // Passes '-H:Extra' to the native image builder options. This can be used to pass parameters which are not directly supported by this extension
190-
jvmArgs.add('flag') // Passes 'flag' directly to the JVM running the native image builder
191-
192-
// Runtime options
193-
runtimeArgs.add('--help') // Passes '--help' to built image, during "nativeRun" task
194-
195-
// Development options
196-
agent = true // Enables the reflection agent. Can be also set on command line using '-Pagent'
197-
198-
useFatJar = true // Instead of passing each jar individually, builds a fat jar
186+
javaNative {
187+
images {
188+
main {
189+
// Main options
190+
imageName = 'application' // The name of the native image, defaults to the project name
191+
mainClass = 'org.test.Main' // The main class to use, defaults to the application.mainClass
192+
debug = true // Determines if debug info should be generated, defaults to false
193+
verbose = true // Add verbose output, defaults to false
194+
fallback = true // Sets the fallback mode of native-image, defaults to false
195+
sharedLibrary = false // Determines if image is a shared library, defaults to false if `java-library` plugin isn't included
196+
197+
systemProperties = [name1: 'value1', name2: 'value2'] // Sets the system properties to use for the native image builder
198+
configurationFileDirectories.from(file('src/my-config')) // Adds a native image configuration file directory, containing files like reflection configuration
199+
200+
// Advanced options
201+
buildArgs.add('-H:Extra') // Passes '-H:Extra' to the native image builder options. This can be used to pass parameters which are not directly supported by this extension
202+
jvmArgs.add('flag') // Passes 'flag' directly to the JVM running the native image builder
203+
204+
// Runtime options
205+
runtimeArgs.add('--help') // Passes '--help' to built image, during "nativeRun" task
206+
207+
// Development options
208+
agent = true // Enables the reflection agent. Can be also set on command line using '-Pagent'
209+
210+
useFatJar = true // Instead of passing each jar individually, builds a fat jar
211+
}
212+
}
199213
}
200214
```
201215

202216
[role="multi-language-sample"]
203217
```kotlin
204-
nativeBuild {
205-
// Main options
206-
imageName.set("application") // The name of the native image, defaults to the project name
207-
mainClass.set("org.test.Main") // The main class to use, defaults to the application.mainClass
208-
debug.set(true) // Determines if debug info should be generated, defaults to false
209-
verbose.set(true) // Add verbose output, defaults to false
210-
fallback.set(true) // Sets the fallback mode of native-image, defaults to false
211-
sharedLibrary.set(false) // Determines if image is a shared library, defaults to false if `java-library` plugin isn't included
212-
213-
systemProperties.putAll(mapOf(name1 to "value1", name2 to "value2")) // Sets the system properties to use for the native image builder
214-
configurationFileDirectories.from(file("src/my-config")) // Adds a native image configuration file directory, containing files like reflection configuration
215-
216-
// Advanced options
217-
buildArgs.add("-H:Extra") // Passes '-H:Extra' to the native image builder options. This can be used to pass parameters which are not directly supported by this extension
218-
jvmArgs.add("flag") // Passes 'flag' directly to the JVM running the native image builder
219-
220-
// Runtime options
221-
runtimeArgs.add("--help") // Passes '--help' to built image, during "nativeRun" task
222-
223-
// Development options
224-
agent.set(true) // Enables the reflection agent. Can be also set on command line using '-Pagent'
225-
226-
227-
useFatJar.set(true) // Instead of passing each jar individually, builds a fat jar
218+
javaNative {
219+
images {
220+
main {
221+
// Main options
222+
imageName.set("application") // The name of the native image, defaults to the project name
223+
mainClass.set("org.test.Main") // The main class to use, defaults to the application.mainClass
224+
debug.set(true) // Determines if debug info should be generated, defaults to false
225+
verbose.set(true) // Add verbose output, defaults to false
226+
fallback.set(true) // Sets the fallback mode of native-image, defaults to false
227+
sharedLibrary.set(false) // Determines if image is a shared library, defaults to false if `java-library` plugin isn't included
228+
229+
systemProperties.putAll(mapOf(name1 to "value1", name2 to "value2")) // Sets the system properties to use for the native image builder
230+
configurationFileDirectories.from(file("src/my-config")) // Adds a native image configuration file directory, containing files like reflection configuration
231+
232+
// Advanced options
233+
buildArgs.add("-H:Extra") // Passes '-H:Extra' to the native image builder options. This can be used to pass parameters which are not directly supported by this extension
234+
jvmArgs.add("flag") // Passes 'flag' directly to the JVM running the native image builder
235+
236+
// Runtime options
237+
runtimeArgs.add("--help") // Passes '--help' to built image, during "nativeRun" task
238+
239+
// Development options
240+
agent.set(true) // Enables the reflection agent. Can be also set on command line using '-Pagent'
241+
242+
useFatJar.set(true) // Instead of passing each jar individually, builds a fat jar
243+
}
244+
}
228245
}
229246
```
230247

@@ -293,7 +310,7 @@ This should be as easy as appending `-Pagent` to `run` and `nativeBuild`, or `te
293310

294311
```bash
295312
./gradlew -Pagent run # Runs on JVM with native-image-agent.
296-
./gradlew -Pagent nativeBuild # Builds image using configuration acquired by agent.
313+
./gradlew -Pagent nativeAssemble # Builds image using configuration acquired by agent.
297314

298315
# For testing
299316
./gradlew -Pagent test # Runs on JVM with native-image-agent.

0 commit comments

Comments
 (0)