Class ResourceConfigGenerator
ResourceConfigGenerator
generates a JSON String with the resource bundles and other classpath resources
that should be included in the Substrate VM native image.
The GraalVM native-image builder by default will not integrate any of the classpath resources into the image it creates.
The output of ResourceConfigGenerator
is intended to be passed to the -H:ResourceConfigurationFiles=/path/to/resource-config.json
option of the native-image
GraalVM utility.
This allows picocli-based native image applications to access these resources.
Alternatively, the generated configuration
files can be supplied to the native-image
tool by placing them in a
META-INF/native-image/
directory on the class path, for example, in a JAR file used in the image build.
This directory (or any of its subdirectories) is searched for files with the names jni-config.json
,
reflect-config.json
, proxy-config.json
and resource-config.json
, which are then automatically
included in the build. Not all of those files must be present.
When multiple files with the same name are found, all of them are included.
- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
generateResourceConfig
(CommandLine.Model.CommandSpec[] specs, String[] bundles, String[] resourceRegex) Returns a JSON String with the resources and resource bundles to include for the specifiedCommandSpec
objects.static void
Runs this class as a standalone application, printing the resulting JSON String to a file or toSystem.out
.
-
Constructor Details
-
ResourceConfigGenerator
public ResourceConfigGenerator()
-
-
Method Details
-
main
Runs this class as a standalone application, printing the resulting JSON String to a file or toSystem.out
.- Parameters:
args
- one or more fully qualified class names of@Command
-annotated classes.
-
generateResourceConfig
public static String generateResourceConfig(CommandLine.Model.CommandSpec[] specs, String[] bundles, String[] resourceRegex) Returns a JSON String with the resources and resource bundles to include for the specifiedCommandSpec
objects.- Parameters:
specs
- one or moreCommandSpec
objects to inspect for resource bundlesbundles
- base names of additional resource bundles to be included in the imageresourceRegex
- one or more Java regular expressions that match resource(s) to be included in the image- Returns:
- a JSON String in the format
required by the
-H:ResourceConfigurationFiles=/path/to/resource-config.json
option of the GraalVMnative-image
utility.
-