-
Notifications
You must be signed in to change notification settings - Fork 13
JDK Tools
bld provide direct access to various tools provided with the JDK, including:
The jlink tool can be used to assemble and optimize a set of modules and their dependencies into a custom runtime image.
For example, assembling a module with a launcher in bld might look something like:
var options = new JlinkOptions()
.modulePath(new File(buildDirectory(), "jmod"))
.addModules("com.example.mylib")
.launcher("foo", "com.example.mylib", "com.example.mylib.Foo")
.output(new File(buildDirectory(), "jlink")
.compress(ZipCompression.ZIP_9);
new JlinkOperation().jlinkOptions(options).execute();
Please check the JlinkOperation documentation for all available configuration options.
The jmod tool can be used to create JMOD files and list the content of existing JMOD files.
For example, creating a JMOD file in bld might look something like:
var options = new JmodOptions()
.classpath(new File(buildDistDirectory(), "mylib-0.1.jar")
.compress(ZipCompression.ZIP_9);
new JmodOperation()
.operationMode(OperationMode.CREATE)
.jmodFile(new File(buildDirectory(), "jmod/com.example.mylib.jmod"))
.jmodOptions(options)
.execute();
Please check the JmodOperation documentation for all available configuration options.
The jpackage tool can be used to package self-contained Java applications.
For example, packaging an application in bld, might look something like:
var jlinkOptions = new JlinkOptions()
.compress(JlinkOptions.CompressionLevel.ZIP)
.stripNativeCommands(true);
var options = new JpackageOptions()
.input(buildDistDirectory())
.name("MyApp")
.mainJar("myapp-0.1.jar")
.javaOptions("--enable-preview")
.dest(new File(buildDirectory(), "packages")
.verbose(true)
.jlinkOptions(jlinkOptions);
new JpackageOperation().jpackageOptions(options).execute();
Please check the JpackageOperation documentation for all available configuration options.