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/gradle-plugin.adoc
+78-61Lines changed: 78 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,12 +129,14 @@ This plugin works with the `application` plugin and will register a number of ta
129
129
130
130
The main tasks that you will want to execute are:
131
131
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
133
133
- `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
135
135
- `nativeTest`, which will <<testing,execute tests>> found in the `test` source set in native mode
136
136
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`.
138
140
139
141
=== Native image options
140
142
@@ -148,21 +150,29 @@ If you want to use a different toolchain, for example a GraalVM Enterprise Editi
@@ -173,58 +183,65 @@ The following configuration options are available for building images:
173
183
.NativeImageOption configuration
174
184
[role="multi-language-sample"]
175
185
```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
+
}
199
213
}
200
214
```
201
215
202
216
[role="multi-language-sample"]
203
217
```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
+
}
228
245
}
229
246
```
230
247
@@ -293,7 +310,7 @@ This should be as easy as appending `-Pagent` to `run` and `nativeBuild`, or `te
293
310
294
311
```bash
295
312
./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.
297
314
298
315
# For testing
299
316
./gradlew -Pagent test # Runs on JVM with native-image-agent.
0 commit comments