45
45
import org .graalvm .buildtools .gradle .tasks .CreateLayerOptions ;
46
46
import org .graalvm .buildtools .gradle .tasks .LayerOptions ;
47
47
import org .graalvm .buildtools .gradle .tasks .UseLayerOptions ;
48
+ import org .graalvm .buildtools .model .resources .NativeImageFlags ;
48
49
import org .graalvm .buildtools .utils .NativeImageUtils ;
49
50
import org .gradle .api .Transformer ;
50
51
import org .gradle .api .file .ConfigurableFileCollection ;
@@ -129,7 +130,7 @@ public List<String> asArguments() {
129
130
ConfigurableFileCollection jarsClasspath = null ;
130
131
if (hasLayers ) {
131
132
LOGGER .warn ("Experimental support for layered images enabled. DSL may change at any time." );
132
- cliArgs .add ("-H:+UnlockExperimentalVMOptions" );
133
+ cliArgs .add (NativeImageFlags . UNLOCK_EXPERIMENTAL_VMOPTIONS );
133
134
var layers = options .getLayers ();
134
135
var arg = new StringBuilder ();
135
136
for (LayerOptions layer : layers ) {
@@ -139,14 +140,13 @@ public List<String> asArguments() {
139
140
if (layer instanceof CreateLayerOptions ) {
140
141
var create = (CreateLayerOptions ) layer ;
141
142
layerCreateName = layer .getLayerName ().get ();
142
- arg .append ("-H:LayerCreate =" );
143
+ arg .append (NativeImageFlags . LAYER_CREATE + " =" );
143
144
arg .append (layerCreateName ).append (".nil" );
144
145
var modules = create .getModules ().get ();
145
146
jarsClasspath = create .getJars ();
146
147
boolean hasModules = !modules .isEmpty ();
147
148
boolean hasPackage = create .getPackages ().isPresent () && !create .getPackages ().get ().isEmpty ();
148
- var createLayerJars = jarsClasspath .getFiles ();
149
- boolean hasJars = !createLayerJars .isEmpty ();
149
+ boolean hasJars = !jarsClasspath .getFiles ().isEmpty ();
150
150
if (hasModules || hasPackage || hasJars ) {
151
151
var packages = create .getPackages ().get ();
152
152
arg .append ("," );
@@ -168,7 +168,7 @@ public List<String> asArguments() {
168
168
}
169
169
} else {
170
170
var layerUse = (UseLayerOptions ) layer ;
171
- arg .append ("-H:LayerUse =" );
171
+ arg .append (NativeImageFlags . LAYER_USE + " =" );
172
172
arg .append (layerUse .getLayerFile ().getAsFile ().get ().getAbsolutePath ());
173
173
}
174
174
}
@@ -187,14 +187,14 @@ public List<String> asArguments() {
187
187
cliArgs .add (jarsClasspath .getAsPath ());
188
188
}
189
189
appendBooleanOption (cliArgs , options .getDebug (), "-g" );
190
- appendBooleanOption (cliArgs , options .getFallback ().map (NEGATE ), "--no-fallback" );
191
- appendBooleanOption (cliArgs , options .getVerbose (), "--verbose" );
192
- appendBooleanOption (cliArgs , options .getSharedLibrary (), "--shared" );
193
- appendBooleanOption (cliArgs , options .getQuickBuild (), "-Ob" );
190
+ appendBooleanOption (cliArgs , options .getFallback ().map (NEGATE ), NativeImageFlags . NO_FALLBACK );
191
+ appendBooleanOption (cliArgs , options .getVerbose (), NativeImageFlags . VERBOSE );
192
+ appendBooleanOption (cliArgs , options .getSharedLibrary (), NativeImageFlags . SHARED );
193
+ appendBooleanOption (cliArgs , options .getQuickBuild (), NativeImageFlags . QUICK_BUILD );
194
194
if (useColors .get ()) {
195
- appendBooleanOption (cliArgs , options .getRichOutput (), majorJDKVersion .getOrElse (-1 ) >= 21 ? "--color" : "-H:+BuildOutputColorful" );
195
+ appendBooleanOption (cliArgs , options .getRichOutput (), majorJDKVersion .getOrElse (-1 ) >= 21 ? NativeImageFlags . COLOR : NativeImageFlags . BUILD_OUTPUT_COLORFUL );
196
196
}
197
- appendBooleanOption (cliArgs , options .getPgoInstrument (), "--pgo-instrument" );
197
+ appendBooleanOption (cliArgs , options .getPgoInstrument (), NativeImageFlags . PGO_INSTRUMENT );
198
198
199
199
String targetOutputPath = getExecutableName ().get ();
200
200
if (layerCreateName != null ) {
@@ -221,7 +221,7 @@ public List<String> asArguments() {
221
221
.map (File ::getAbsolutePath )
222
222
.collect (Collectors .joining ("," ));
223
223
if (!configFiles .isEmpty ()) {
224
- cliArgs .add ("-H:ConfigurationFileDirectories =" + configFiles );
224
+ cliArgs .add (NativeImageFlags . CONFIGURATION_FILE_DIRECTORIES + " =" + configFiles );
225
225
}
226
226
if (Boolean .FALSE .equals (options .getPgoInstrument ().get ()) && options .getPgoProfilesDirectory ().isPresent ()) {
227
227
FileTree files = options .getPgoProfilesDirectory ().get ().getAsFileTree ();
0 commit comments