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
The plugin relies on Gradle's https://docs.gradle.org/7.1.1/userguide/toolchains.html[JVM toolchain support], allowing to decorrelate the tool used to run Gradle, the compiler used to build your application, and eventually the SDK used to generate a native image.
Copy file name to clipboardExpand all lines: docs/src/docs/asciidoc/index.adoc
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,13 +23,17 @@ If you are interested in contributing, please refer to our https://github.com/gr
23
23
* Introduced the `metadataCopy` task.
24
24
* Introduced the concept of agent modes.
25
25
** Under the hood, the agent mode dictates what options are passed to the agent and how metadata produced by multiple runs get merged.
26
-
* Added `excludeConfig` configuration option that allows skipping of configuration files that are present in classpath `jar` s.
26
+
* Added `excludeConfig` configuration option that allows skipping of configuration files that are present in dependencies.
27
27
* `useArgFile` is now set to true by default only on Windows.
28
+
* Added `quickBuild` configuration option.
28
29
29
30
==== Maven plugin
30
31
* Completely reworked Maven plugin (should fix many of previous issues and inconsistencies between main and test builds).
31
-
* Added `classesDirectory`, `debug`, `fallback`, `verbose`, `sharedLibrary`, `configurationFileDirectories`, `excludeConfig` and `jvmArgs` properties in order to match those present in the Gradle plugin.
32
+
* Added `classesDirectory`, `debug`, `fallback`, `verbose`, `sharedLibrary`, `configurationFileDirectories`, `excludeConfig`, `quickBuild`, and `jvmArgs` properties in order to match those present in the Gradle plugin. +
33
+
+
34
+
See <<maven-plugin.adoc#,docs>> for more information.
32
35
* `useArgFile` is now set to true by default only on Windows.
36
+
* Changed lookup order for `native-image` discovery -- `GRAALVM_HOME`, `JAVA_HOME`, `PATH`.
@@ -114,10 +114,118 @@ Build Configuration]. It is also possible to customize the plugin within a
114
114
image name is not supplied, the artifact ID of the project will be used by default.
115
115
`<buildArgs>`::
116
116
If you want to pass additional arguments to the native image builder, use `<buildArgs>`
117
-
in the configuration of the plugin.
117
+
in the configuration of the plugin:
118
+
[source,xml]
119
+
----
120
+
<buildArgs>
121
+
<arg>--argument</arg>
122
+
</buildArgs>
123
+
----
118
124
`<skipNativeBuild>`::
119
-
To skip generation of the native image, supply
120
-
`<skipNativeBuild>true</skipNativeBuild>` in the configuration of the plugin.
125
+
To skip generation of the native image, supply the following in the configuration of the plugin:
126
+
[source,xml]
127
+
----
128
+
<skipNativeBuild>true</skipNativeBuild>
129
+
----
130
+
`<skipNativeTests>`::
131
+
To skip generation and execution of the native image compiled tests, supply the following in the configuration of the plugin:
132
+
[source,xml]
133
+
----
134
+
<skipNativeTests>true</skipNativeTests>
135
+
----
136
+
`<debug>`::
137
+
If you want to enable generation of debugging information supply the following in the configuration of the plugin:
138
+
[source,xml]
139
+
----
140
+
<debug>true</debug>
141
+
----
142
+
`<verbose>`::
143
+
If you want to enable verbose output during native-image building supply the following in the configuration of the plugin:
144
+
[source,xml]
145
+
----
146
+
<verbose>true</verbose>
147
+
----
148
+
`<sharedLibrary>`::
149
+
If you want to build image as a shared library supply the following in the configuration of the plugin:
150
+
[source,xml]
151
+
----
152
+
<sharedLibrary>true</sharedLibrary>
153
+
----
154
+
`<useArgFile>`::
155
+
If you want to use argument file for native-image building supply the following in the configuration of the plugin:
156
+
[source,xml]
157
+
----
158
+
<useArgFile>true</useArgFile>
159
+
----
160
+
`<quickBuild>`::
161
+
If you want to build the image using https://blogs.oracle.com/java/post/graalvm-enterprise-221--faster-smarter-leaner[quick build mode], supply the following in the configuration of the plugin:
162
+
[source,xml]
163
+
----
164
+
<quickBuild>true</quickBuild>
165
+
----
166
+
`<excludeConfig>`::
167
+
In order to exclude configuration from present jar files, specify:
168
+
[source,xml]
169
+
----
170
+
<excludeConfig>
171
+
<entry>
172
+
<jarPath>dummy/path/to/file.jar</jarPath>
173
+
<resourcePattern>*</resourcePattern>
174
+
</entry>
175
+
</excludeConfig>
176
+
----
177
+
`<environment>`::
178
+
To set environment options for native-image building supply the following in the configuration of the plugin:
179
+
[source,xml]
180
+
----
181
+
<environment>
182
+
<variable>value</variable>
183
+
</environment>
184
+
----
185
+
`<systemPropertyVariables>`::
186
+
To specify system properties used for native-image building supply the following in the configuration of the plugin:
187
+
[source,xml]
188
+
----
189
+
<systemPropertyVariables>
190
+
<propertyName>value</propertyName>
191
+
</systemPropertyVariables>
192
+
----
193
+
`<jvmArgs>`::
194
+
To specify JVM arguments used for native-image building supply the following in the configuration of the plugin:
195
+
[source,xml]
196
+
----
197
+
<jvmArgs>
198
+
<arg>argument1</arg>
199
+
<arg>argument2</arg>
200
+
</jvmArgs>
201
+
----
202
+
`<configurationFileDirectories>`::
203
+
If you want to specify custom directories where configuration files should be looked up, supply the following in the configuration of the plugin:
204
+
[source,xml]
205
+
----
206
+
<configurationFileDirectories>
207
+
<dir>path/to/dir</dir>
208
+
</configurationFileDirectories>
209
+
----
210
+
`<classpath`::
211
+
Sets a custom classpath instead of plugin generated one. Usage:
212
+
[source,xml]
213
+
----
214
+
<classpath>
215
+
<entry>path/to/file.jar</entry>
216
+
<entry>path/to/classes</entry>
217
+
</classpath>
218
+
----
219
+
`<classesDirectory>`::
220
+
If you want to specify custom path to packed JAR, or a custom directory that contains
221
+
only application classes, but want the plugin to still automatically add classpath entries for
222
+
dependencies, simply add:
223
+
[source,xml]
224
+
----
225
+
<classesDirectory>
226
+
path/to/dir
227
+
</classesDirectory>
228
+
----
121
229
`<agent>`::
122
230
Configuration of the <<agent-support, native agent>>. See <<agent-support-enabling>>
123
231
and <<agent-support-configuring-options>> for details.
@@ -126,15 +234,17 @@ For example, to build a native image named `executable-name` that uses
126
234
`org.example.ClassName` as its main class with assertions enabled, add the following
127
235
`<configuration>` block for the `native-maven-plugin`.
128
236
129
-
```xml
237
+
[source,xml]
238
+
----
130
239
<configuration>
131
240
<imageName>executable-name</imageName>
132
241
<mainClass>org.example.ClassName</mainClass>
133
-
<buildArgs>
134
-
<buildArg>--no-fallback</buildArg>
135
-
</buildArgs>
242
+
<fallback>false</fallback>
243
+
<verbose>true</verbose>
136
244
</configuration>
137
-
```
245
+
----
246
+
247
+
NOTE: Most of the aforementioned properties can also be set from command line as a part of Maven invocation -- for example if you want to temporarily enable verbose mode you can append `-Dverbose` to your Maven invocation.
138
248
139
249
NOTE: If you use GraalVM Enterprise as the `JAVA_HOME` environment, the plugin builds a native image with enterprise features enabled -- for example, an executable will automatically be built with https://medium.com/graalvm/isolates-and-compressed-references-more-flexible-and-efficient-memory-management-for-graalvm-a044cc50b67e[compressed references] and other optimizations enabled.
140
250
@@ -152,7 +262,7 @@ The `<buildArgs>` element can be combined between parent and children POMs. Supp
152
262
<imageName>${project.artifactId}</imageName>
153
263
<mainClass>${exec.mainClass}</mainClass>
154
264
<buildArgs>
155
-
<buildArg>--no-fallback<buildArg>
265
+
<buildArg>--no-fallback</buildArg>
156
266
</buildArgs>
157
267
</configuration>
158
268
</plugin>
@@ -323,7 +433,6 @@ Depending on the other plugins your build uses (typically the Spring Boot plugin
323
433
...
324
434
----
325
435
326
-
327
436
To be able to <<testing-support,execute tests in native mode>>, you will need more setup:
328
437
329
438
- Create a `src/assembly/test-jar-with-dependencies.xml` file with the following contents:
Copy file name to clipboardExpand all lines: docs/src/docs/snippets/gradle/groovy/build.gradle
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
2
+
* Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
@@ -119,9 +119,11 @@ graalvmNative {
119
119
verbose =true// Add verbose output, defaults to false
120
120
fallback =true// Sets the fallback mode of native-image, defaults to false
121
121
sharedLibrary =false// Determines if image is a shared library, defaults to false if `java-library` plugin isn't included
122
+
quickBuild =false// Determines if image is being built in quick build mode
122
123
123
124
systemProperties = [name1: 'value1', name2: 'value2'] // Sets the system properties to use for the native image builder
124
125
configurationFileDirectories.from(file('src/my-config')) // Adds a native image configuration file directory, containing files like reflection configuration
126
+
excludeConfig.put("org.example.test", ["META-INF/native-image/*", "config/*"]) // Excludes configuration that matches one of given regexes from JAR of dependency with said coordinates.
125
127
126
128
// Advanced options
127
129
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
Copy file name to clipboardExpand all lines: docs/src/docs/snippets/gradle/kotlin/build.gradle.kts
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
2
+
* Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
@@ -77,9 +77,11 @@ graalvmNative {
77
77
verbose.set(true) // Add verbose output, defaults to false
78
78
fallback.set(true) // Sets the fallback mode of native-image, defaults to false
79
79
sharedLibrary.set(false) // Determines if image is a shared library, defaults to false if `java-library` plugin isn't included
80
+
quickBuild.set(false) // Determines if image is being built in quick build mode
80
81
81
82
systemProperties.putAll(mapOf("name1" to "value1", "name2" to "value2")) // Sets the system properties to use for the native image builder
82
83
configurationFileDirectories.from(file("src/my-config")) // Adds a native image configuration file directory, containing files like reflection configuration
84
+
excludeConfig.put("org.example.test", listOf("META-INF/native-image/*", "config/*")) // Excludes configuration that matches one of given regexes from JAR of dependency with said coordinates.
83
85
84
86
// Advanced options
85
87
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
0 commit comments