mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 16:27:11 -07:00
Added support for Java 20-21 specific options
This commit is contained in:
parent
750758993d
commit
e32e17403f
6 changed files with 83 additions and 3 deletions
|
@ -49,6 +49,23 @@ public class JlinkOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compression to use in compressing resources.
|
||||||
|
* <p>
|
||||||
|
* <b>Requires Java 21 or higher</b>.
|
||||||
|
* <p>
|
||||||
|
* Where {@link ZipCompression#ZIP_0 ZIP_0} provides no compression and {@link ZipCompression#ZIP_9 ZIP_9} provides
|
||||||
|
* the best compression.
|
||||||
|
* <p>Default is {@link ZipCompression#ZIP_6 ZIP_6}
|
||||||
|
*
|
||||||
|
* @param compression the {@link ZipCompression compression} level
|
||||||
|
* @return this map of options
|
||||||
|
*/
|
||||||
|
public JlinkOptions compress(ZipCompression compression) {
|
||||||
|
put("--compress", compression.level);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable compression of resources.
|
* Enable compression of resources.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,6 +38,24 @@ public class JmodOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compression to use when creating the JMOD archive.
|
||||||
|
* <p>
|
||||||
|
* <b>Requires Java 20 or higher</b>.
|
||||||
|
* <p>
|
||||||
|
* Where {@link ZipCompression#ZIP_0 ZIP_0} provides no compression and {@link ZipCompression#ZIP_9 ZIP_9} provides the
|
||||||
|
* best compression.
|
||||||
|
* <p>
|
||||||
|
* Default is {@link ZipCompression#ZIP_6 ZIP_6}
|
||||||
|
*
|
||||||
|
* @param compression the {@link ZipCompression compression} level
|
||||||
|
* @return this map of options
|
||||||
|
*/
|
||||||
|
public JmodOptions compress(ZipCompression compression) {
|
||||||
|
put("--compress", compression.level);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location of user-editable config files
|
* Location of user-editable config files
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,8 +27,10 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
/**
|
/**
|
||||||
* List of application launchers.
|
* List of application launchers.
|
||||||
* <p>
|
* <p>
|
||||||
* The main application launcher will be built from the command line options. Additional alternative launchers
|
* The main application launcher will be built from the command line options.
|
||||||
* can be built using this option, and this option can be used to build multiple additional launchers.
|
* <p>
|
||||||
|
* Additional alternative launchers can be built using this option, and this option can be used to build multiple
|
||||||
|
* additional launchers.
|
||||||
*
|
*
|
||||||
* @param launcher one or more {@link Launcher}
|
* @param launcher one or more {@link Launcher}
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -58,6 +60,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of paths to files and/or directories to add to the application payload.
|
* List of paths to files and/or directories to add to the application payload.
|
||||||
|
* <p>
|
||||||
|
* <b>Requires Java 20 or higher</b>.
|
||||||
*
|
*
|
||||||
* @param additionalContent one or more path
|
* @param additionalContent one or more path
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -213,6 +217,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
/**
|
/**
|
||||||
* Request to create an installer that will register the main application launcher as a background service-type
|
* Request to create an installer that will register the main application launcher as a background service-type
|
||||||
* application.
|
* application.
|
||||||
|
* <p>
|
||||||
|
* <b>Requires Java 20 or higher</b>.
|
||||||
*
|
*
|
||||||
* @param launcherAsService {@code true} to register the launcher as a service; {@code false} otherwise
|
* @param launcherAsService {@code true} to register the launcher as a service; {@code false} otherwise
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
|
30
src/main/java/rife/bld/operations/ZipCompression.java
Normal file
30
src/main/java/rife/bld/operations/ZipCompression.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||||
|
*/
|
||||||
|
package rife.bld.operations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The zip compression levels for jlink and jmod.
|
||||||
|
*
|
||||||
|
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||||
|
* @since 2.0.2
|
||||||
|
*/
|
||||||
|
public enum ZipCompression {
|
||||||
|
ZIP_0("zip-0"),
|
||||||
|
ZIP_1("zip-1"),
|
||||||
|
ZIP_2("zip-2"),
|
||||||
|
ZIP_3("zip-3"),
|
||||||
|
ZIP_4("zip-4"),
|
||||||
|
ZIP_5("zip-5"),
|
||||||
|
ZIP_6("zip-6"),
|
||||||
|
ZIP_7("zip-7"),
|
||||||
|
ZIP_8("zip-8"),
|
||||||
|
ZIP_9("zip-9");
|
||||||
|
|
||||||
|
public final String level;
|
||||||
|
|
||||||
|
ZipCompression(String level) {
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
}
|
|
@ -97,8 +97,13 @@ public class TestJlinkOperation {
|
||||||
.modulePath("src/test/resources/jlink/build/jmod")
|
.modulePath("src/test/resources/jlink/build/jmod")
|
||||||
.addModules("dev.mccue.tree")
|
.addModules("dev.mccue.tree")
|
||||||
.launcher("tree", "dev.mccue.tree", "dev.mccue.tree.Tree")
|
.launcher("tree", "dev.mccue.tree", "dev.mccue.tree.Tree")
|
||||||
.compress(CompressionLevel.NO_COMPRESSION)
|
|
||||||
.output(output.getAbsolutePath());
|
.output(output.getAbsolutePath());
|
||||||
|
if (Runtime.version().version().get(0) >= 21) {
|
||||||
|
options.compress(ZipCompression.ZIP_6);
|
||||||
|
} else {
|
||||||
|
options.compress(CompressionLevel.ZIP);
|
||||||
|
}
|
||||||
|
|
||||||
var jlink = new JlinkOperation().jlinkOptions(options);
|
var jlink = new JlinkOperation().jlinkOptions(options);
|
||||||
|
|
||||||
assertDoesNotThrow(jlink::execute);
|
assertDoesNotThrow(jlink::execute);
|
||||||
|
|
|
@ -109,6 +109,10 @@ public class TestJmodOperation {
|
||||||
var mod = new File(tmpdir, "dev.mccue.tree.jmod");
|
var mod = new File(tmpdir, "dev.mccue.tree.jmod");
|
||||||
|
|
||||||
var options = new JmodOptions().classpath("src/test/resources/jlink/build/jar/dev.mccue.tree.jar");
|
var options = new JmodOptions().classpath("src/test/resources/jlink/build/jar/dev.mccue.tree.jar");
|
||||||
|
if (Runtime.version().version().get(0) >= 20) {
|
||||||
|
options.compress(ZipCompression.ZIP_9);
|
||||||
|
}
|
||||||
|
|
||||||
var jmod = new JmodOperation()
|
var jmod = new JmodOperation()
|
||||||
.operationMode(OperationMode.CREATE)
|
.operationMode(OperationMode.CREATE)
|
||||||
.jmodFile(mod.getAbsolutePath())
|
.jmodFile(mod.getAbsolutePath())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue