forked from graalvm/native-build-tools
/
NativeImageOptions.java
326 lines (288 loc) · 10.2 KB
/
NativeImageOptions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.graalvm.buildtools.gradle.dsl;
import org.graalvm.buildtools.gradle.dsl.agent.DeprecatedAgentOptions;
import org.gradle.api.Action;
import org.gradle.api.Named;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional;
import org.gradle.jvm.toolchain.JavaLauncher;
import java.util.List;
import java.util.Map;
/**
* Class that declares native image options.
*
* @author gkrocher
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public interface NativeImageOptions extends Named {
@Override
@Internal
String getName();
/**
* Gets the name of the native executable to be generated.
*
* @return The image name property.
*/
@Input
Property<String> getImageName();
/**
* Returns the fully qualified name of the Main class to be executed.
* <p>
* This does not need to be set if using an <a href="https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html">Executable Jar</a> with a {@code Main-Class} attribute.
* </p>
*
* @return mainClass The main class.
*/
@Input
@Optional
Property<String> getMainClass();
/**
* Returns the arguments for the native-image invocation.
*
* @return Arguments for the native-image invocation.
*/
@Input
ListProperty<String> getBuildArgs();
/**
* Returns the system properties which will be used by the native-image builder process.
*
* @return The system properties. Returns an empty map when there are no system properties.
*/
@Input
MapProperty<String, Object> getSystemProperties();
/**
* Returns the environment variables which will be used by the native-image builder process.
* @return the environment variables. Returns an empty map when there are no environment variables.
*
* @since 0.9.14
*/
@Input
MapProperty<String, Object> getEnvironmentVariables();
/**
* Returns the classpath for the native-image building.
*
* @return classpath The classpath for the native-image building.
*/
@InputFiles
@Classpath
ConfigurableFileCollection getClasspath();
/**
* Returns the extra arguments to use when launching the JVM for the native-image building process.
* Does not include system properties and the minimum/maximum heap size.
*
* @return The arguments. Returns an empty list if there are no arguments.
*/
@Input
ListProperty<String> getJvmArgs();
/**
* Returns the arguments to use when launching the built image.
*
* @return The arguments. Returns an empty list if there are no arguments.
*/
@Input
ListProperty<String> getRuntimeArgs();
/**
* Gets the value which toggles native-image debug symbol output.
*
* @return Is debug enabled
*/
@Input
Property<Boolean> getDebug();
/**
* @return Whether to enable fallbacks (defaults to false).
*/
@Input
Property<Boolean> getFallback();
/**
* Gets the value which toggles native-image verbose output.
*
* @return Is verbose output
*/
@Input
Property<Boolean> getVerbose();
/**
* Gets the value which determines if shared library is being built.
*
* @return The value which determines if shared library is being built.
*/
@Input
Property<Boolean> getSharedLibrary();
/**
* Gets the value which determines if image is being built in quick build mode.
*
* @return The value which determines if image is being built in quick build mode.
*/
@Input
Property<Boolean> getQuickBuild();
/**
* Gets the value which determines if image is being built with rich output.
*
* @return The value which determines if image is being built with rich output.
*/
@Input
Property<Boolean> getRichOutput();
/**
* Returns the toolchain used to invoke native-image. Currently pointing
* to a Java launcher due to Gradle limitations.
*
* @return the detected java launcher
*/
@Nested
@Optional
Property<JavaLauncher> getJavaLauncher();
/**
* Returns the list of configuration file directories (e.g. resource-config.json, ...) which need
* to be passed to native-image.
*
* @return a collection of directories
*/
@InputFiles
ConfigurableFileCollection getConfigurationFileDirectories();
/**
* Returns the MapProperty that contains information about configuration that should be excluded
* during image building. It consists of a dependency coordinates and a list of
* regular expressions that match resources that should be excluded as a value.
*
* @return a map of filters for configuration exclusion
*/
@Input
MapProperty<Object, List<String>> getExcludeConfig();
@Nested
NativeResourcesOptions getResources();
void resources(Action<? super NativeResourcesOptions> spec);
/**
* Adds arguments for the native-image invocation.
*
* @param buildArgs Arguments for the native-image invocation.
* @return this
*/
NativeImageOptions buildArgs(Object... buildArgs);
/**
* Adds arguments for the native-image invocation.
*
* @param buildArgs Arguments for the native-image invocation.
* @return this
*/
NativeImageOptions buildArgs(Iterable<?> buildArgs);
/**
* Adds some system properties to be used by the native-image builder process.
*
* @param properties The system properties. Must not be null.
* @return this
*/
@SuppressWarnings("unused")
NativeImageOptions systemProperties(Map<String, ?> properties);
/**
* Adds a system property to be used by the native-image builder process.
*
* @param name The name of the property
* @param value The value for the property. May be null.
* @return this
*/
NativeImageOptions systemProperty(String name, Object value);
/**
* Adds elements to the classpath for the native-image building.
*
* @param paths The classpath elements.
* @return this
*/
NativeImageOptions classpath(Object... paths);
/**
* Adds some arguments to use when launching the JVM for the native-image building process.
*
* @param arguments The arguments.
* @return this
*/
NativeImageOptions jvmArgs(Object... arguments);
/**
* Adds some arguments to use when launching the JVM for the native-image building process.
*
* @param arguments The arguments. Must not be null.
* @return this
*/
NativeImageOptions jvmArgs(Iterable<?> arguments);
/**
* Adds some arguments to use when launching the built image.
*
* @param arguments The arguments.
* @return this
*/
NativeImageOptions runtimeArgs(Object... arguments);
/**
* Adds some arguments to use when launching the built image.
*
* @param arguments The arguments. Must not be null.
* @return this
*/
NativeImageOptions runtimeArgs(Iterable<?> arguments);
/**
* If set to true, this will build a fat jar of the image classpath
* instead of passing each jar individually to the classpath. This
* option can be used in case the classpath is too long and that
* invoking native image fails, which can happen on Windows.
*
* @return true if a fatjar should be used. Defaults to true for Windows, and false otherwise.
*/
@Input
Property<Boolean> getUseFatJar();
@Nested
DeprecatedAgentOptions getAgent();
void agent(Action<? super DeprecatedAgentOptions> spec);
@Input
ListProperty<String> getExcludeConfigArgs();
/**
* Specify the minimal GraalVM version, can be {@code MAJOR}, {@code MAJOR.MINOR} or {@code MAJOR.MINOR.PATCH}.
*
* @return the required version property.
*/
@Input
@Optional
Property<String> getRequiredVersion();
}