mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 08:17:11 -07:00
Fixed handling of @filename in all tools
This commit is contained in:
parent
0ad964ea4d
commit
002844861b
11 changed files with 297 additions and 188 deletions
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
package rife.bld.operations;
|
package rife.bld.operations;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create run-time images using the jlink tool.
|
* Create run-time images using the jlink tool.
|
||||||
|
@ -16,8 +19,9 @@ import java.util.Map;
|
||||||
* @since 2.0.2
|
* @since 2.0.2
|
||||||
*/
|
*/
|
||||||
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
|
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
|
||||||
private final JlinkOptions jlinkOptions_ = new JlinkOptions();
|
|
||||||
private final List<String> disabledPlugins_ = new ArrayList<>();
|
private final List<String> disabledPlugins_ = new ArrayList<>();
|
||||||
|
private final JlinkOptions jlinkOptions_ = new JlinkOptions();
|
||||||
|
private final List<String> options_ = new ArrayList<>();
|
||||||
|
|
||||||
public JlinkOperation() {
|
public JlinkOperation() {
|
||||||
super("jlink");
|
super("jlink");
|
||||||
|
@ -37,6 +41,8 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
disabledPlugins_.forEach(plugin -> addArg("--disable-plugin", plugin));
|
disabledPlugins_.forEach(plugin -> addArg("--disable-plugin", plugin));
|
||||||
|
addArgs(jlinkOptions_);
|
||||||
|
addArgs(parseOptions());
|
||||||
super.execute();
|
super.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,16 +57,6 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
|
||||||
return jlinkOptions_;
|
return jlinkOptions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* List available plugins.
|
|
||||||
*
|
|
||||||
* @return this operation instance
|
|
||||||
*/
|
|
||||||
public JlinkOperation listPlugins() {
|
|
||||||
addArgs("--list-plugins");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a list of options to provide to the jlink tool.
|
* Provides a list of options to provide to the jlink tool.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -73,4 +69,49 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
|
||||||
jlinkOptions_.putAll(options);
|
jlinkOptions_.putAll(options);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List available plugins.
|
||||||
|
*
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public JlinkOperation listPlugins() {
|
||||||
|
addArgs("--list-plugins");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read options and/or mode from a file.
|
||||||
|
*
|
||||||
|
* @param filename one or more file
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public JlinkOperation options(String... filename) {
|
||||||
|
options_.addAll(List.of(filename));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of files containing options or mode.
|
||||||
|
*
|
||||||
|
* @return the list of files
|
||||||
|
*/
|
||||||
|
public List<String> options() {
|
||||||
|
return options_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shouldn't be needed, but for some reason jlink doesn't like @filename when called via ToolProvider
|
||||||
|
private List<String> parseOptions() throws FileNotFoundException {
|
||||||
|
var list = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (var option : options_) {
|
||||||
|
try (var scanner = new Scanner(new File(option))) {
|
||||||
|
while (scanner.hasNext()) {
|
||||||
|
list.addAll(List.of(scanner.next().split(" ")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,10 @@ import java.util.List;
|
||||||
* @since 2.0.2
|
* @since 2.0.2
|
||||||
*/
|
*/
|
||||||
public class JlinkOptions extends HashMap<String, String> {
|
public class JlinkOptions extends HashMap<String, String> {
|
||||||
/**
|
/**ranran
|
||||||
* All Modules Path.
|
* All Modules Path.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public final static String ALL_MODULE_PATH = "ALL-MODULE-PATH";
|
public final static String ALL_MODULE_PATH = "ALL-MODULE-PATH";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,22 +49,11 @@ public class JlinkOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read options from file.
|
|
||||||
*
|
|
||||||
* @param filename the filename
|
|
||||||
* @return this map of options
|
|
||||||
*/
|
|
||||||
public JlinkOptions filename(String filename) {
|
|
||||||
put("@" + filename);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compression to use in compressing resources.
|
* Compression to use in compressing resources.
|
||||||
* <p>
|
* <p>
|
||||||
* Where {@link ZipCompression#ZIP_0 ZIP_0} provides no compression and {@link ZipCompression#ZIP_9 ZIP_9} provides the
|
* Where {@link ZipCompression#ZIP_0 ZIP_0} provides no compression and {@link ZipCompression#ZIP_9 ZIP_9} provides
|
||||||
* best compression.
|
* the best compression.
|
||||||
* <p>Default is {@link ZipCompression#ZIP_6 ZIP_6}
|
* <p>Default is {@link ZipCompression#ZIP_6 ZIP_6}
|
||||||
*
|
*
|
||||||
* @param compression the {@link ZipCompression compression} level
|
* @param compression the {@link ZipCompression compression} level
|
||||||
|
@ -110,6 +100,7 @@ public class JlinkOptions extends HashMap<String, String> {
|
||||||
* @param module the module
|
* @param module the module
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public JlinkOptions launcher(String name, String module) {
|
public JlinkOptions launcher(String name, String module) {
|
||||||
put("--launcher", name + "=" + module);
|
put("--launcher", name + "=" + module);
|
||||||
return this;
|
return this;
|
||||||
|
@ -268,7 +259,7 @@ public class JlinkOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable verbose tracing
|
* Enable verbose tracing.
|
||||||
*
|
*
|
||||||
* @param verbose {@code true} to enable verbose tracing, {@code false} otherwise.
|
* @param verbose {@code true} to enable verbose tracing, {@code false} otherwise.
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
|
|
@ -7,6 +7,8 @@ package rife.bld.operations;
|
||||||
|
|
||||||
import rife.bld.operations.exceptions.ExitStatusException;
|
import rife.bld.operations.exceptions.ExitStatusException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +19,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class JmodOperation extends AbstractToolProviderOperation<JmodOperation> {
|
public class JmodOperation extends AbstractToolProviderOperation<JmodOperation> {
|
||||||
private final JmodOptions jmodOptions_ = new JmodOptions();
|
private final JmodOptions jmodOptions_ = new JmodOptions();
|
||||||
|
private final List<String> options_ = new ArrayList<>();
|
||||||
private String jmodFile_;
|
private String jmodFile_;
|
||||||
private OperationMode operationMode_;
|
private OperationMode operationMode_;
|
||||||
|
|
||||||
|
@ -98,6 +101,26 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of files containing options or mode.
|
||||||
|
*
|
||||||
|
* @return the list of files
|
||||||
|
*/
|
||||||
|
public List<String> options() {
|
||||||
|
return options_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read options and/or mode from a file.
|
||||||
|
*
|
||||||
|
* @param filename one or more file
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public JmodOperation options(String... filename) {
|
||||||
|
options_.addAll(List.of(filename));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The operation modes.
|
* The operation modes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -135,17 +135,6 @@ public class JmodOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read options from the specified file.
|
|
||||||
*
|
|
||||||
* @param filename the filename
|
|
||||||
* @return this map of options
|
|
||||||
*/
|
|
||||||
public JmodOptions filename(String filename) {
|
|
||||||
put("@" + filename);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates {@code null} with the specified key in this map. If the map previously contained a mapping for the
|
* Associates {@code null} with the specified key in this map. If the map previously contained a mapping for the
|
||||||
* key, the old value is replaced.
|
* key, the old value is replaced.
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
package rife.bld.operations;
|
package rife.bld.operations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +17,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class JpackageOperation extends AbstractToolProviderOperation<JpackageOperation> {
|
public class JpackageOperation extends AbstractToolProviderOperation<JpackageOperation> {
|
||||||
private final JpackageOptions jpackageOptions_ = new JpackageOptions();
|
private final JpackageOptions jpackageOptions_ = new JpackageOptions();
|
||||||
|
private final List<String> options_ = new ArrayList<>();
|
||||||
|
|
||||||
public JpackageOperation() {
|
public JpackageOperation() {
|
||||||
super("jpackage");
|
super("jpackage");
|
||||||
|
@ -23,9 +26,29 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
addArgs(jpackageOptions_);
|
addArgs(jpackageOptions_);
|
||||||
|
addArgs(options_.stream().map(opt -> '@' + opt).toList());
|
||||||
super.execute();
|
super.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the list of files containing options or mode.
|
||||||
|
*
|
||||||
|
* @return the list of files
|
||||||
|
*/
|
||||||
|
public List<String> options(){
|
||||||
|
return options_;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Read options and/or mode from a file.
|
||||||
|
*
|
||||||
|
* @param filename one or more file
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public JpackageOperation options(String... filename) {
|
||||||
|
options_.addAll(List.of(filename));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of options for the jpackage tool.
|
* Retrieves the list of options for the jpackage tool.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -25,17 +25,6 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read options and/or mode from a file.
|
|
||||||
*
|
|
||||||
* @param filename the filename
|
|
||||||
* @return this map of options
|
|
||||||
*/
|
|
||||||
public JpackageOptions filename(String filename) {
|
|
||||||
put("@" + filename);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of application launchers.
|
* List of application launchers.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -135,7 +124,9 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path where generated output file is placed
|
* Path where generated output file is placed.
|
||||||
|
* <p>
|
||||||
|
* Defaults to the current working directory.
|
||||||
*
|
*
|
||||||
* @param path absolute path or relative to the current directory
|
* @param path absolute path or relative to the current directory
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -160,18 +151,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options to pass to the Java runtime.
|
* Path of the icon of the application package.
|
||||||
*
|
|
||||||
* @param options the options
|
|
||||||
* @return this map of options
|
|
||||||
*/
|
|
||||||
public JpackageOptions javaOptions(String... options) {
|
|
||||||
put("--java-options", String.join(" ", options));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path of the icon of the application package/
|
|
||||||
*
|
*
|
||||||
* @param path absolute path or relative to the current directory
|
* @param path absolute path or relative to the current directory
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -195,7 +175,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Absolute path of the installation directory of the application
|
* Absolute path of the installation directory of the application.
|
||||||
*
|
*
|
||||||
* @param path the absolute directory path
|
* @param path the absolute directory path
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -205,6 +185,32 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options to pass to the Java runtime.
|
||||||
|
*
|
||||||
|
* @param options the options
|
||||||
|
* @return this map of options
|
||||||
|
*/
|
||||||
|
public JpackageOptions javaOptions(String... options) {
|
||||||
|
put("--java-options", String.join(" ", options));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of options to pass to jlink.
|
||||||
|
* <p>
|
||||||
|
* If not specified, defaults to {@link JlinkOptions#stripNativeCommands(boolean) stripNativeCommands}
|
||||||
|
* {@link JlinkOptions#stripDebug(boolean) stripDebug} {@link JlinkOptions#noManPages(boolean) noManPages}
|
||||||
|
* {@link JlinkOptions#noHeaderFiles(boolean) noHeaderFiles}.
|
||||||
|
*
|
||||||
|
* @param options the {@link JlinkOptions}
|
||||||
|
* @return this map of options
|
||||||
|
*/
|
||||||
|
public JpackageOptions jlinkOptions(JlinkOptions options) {
|
||||||
|
put("--jlink-options", String.join(" ", options.toList()));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -222,37 +228,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of options to pass to jlink.
|
* Path to the license file.
|
||||||
* <p>
|
|
||||||
* If not specified, defaults to {@link JlinkOptions#stripNativeCommands(boolean) stripNativeCommands}
|
|
||||||
* {@link JlinkOptions#stripDebug(boolean) stripDebug} {@link JlinkOptions#noManPages(boolean) noManPages}
|
|
||||||
* {@link JlinkOptions#noHeaderFiles(boolean) noHeaderFiles}.
|
|
||||||
*
|
|
||||||
* @param options the {@link JlinkOptions}
|
|
||||||
* @return this map of options
|
|
||||||
*/
|
|
||||||
public JpackageOptions jlinkOptions(JlinkOptions options) {
|
|
||||||
put("--jlink-options", String.join(" ", options.toList()));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required packages or capabilities for the application.
|
|
||||||
*
|
|
||||||
* @param packageDeps {@code true} if required, {@code false} otherwise
|
|
||||||
* @return this map of options
|
|
||||||
*/
|
|
||||||
public JpackageOptions linuxPackageDeps(boolean packageDeps) {
|
|
||||||
if (packageDeps) {
|
|
||||||
put("--linux-package-deps");
|
|
||||||
} else {
|
|
||||||
remove("--linux-package-deps");
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path to the license file
|
|
||||||
*
|
*
|
||||||
* @param path absolute path or relative to the current directory
|
* @param path absolute path or relative to the current directory
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -263,7 +239,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group value of the RPM {@code <name>.spec} file or Section value of DEB control file
|
* Group value of the RPM {@code <name>.spec} file or Section value of DEB control file.
|
||||||
*
|
*
|
||||||
* @param appCategory the application category
|
* @param appCategory the application category
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -285,7 +261,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maintainer for .deb package.
|
* Maintainer for {@code .deb} package.
|
||||||
*
|
*
|
||||||
* @param maintainer the maintainer
|
* @param maintainer the maintainer
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -307,16 +283,16 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a shortcut for the application.
|
* Required packages or capabilities for the application.
|
||||||
*
|
*
|
||||||
* @param shortcut {@code true| to create a shortcut, {@code false} otherwise
|
* @param packageDeps {@code true} if required, {@code false} otherwise
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
*/
|
*/
|
||||||
public JpackageOptions linuxShortcut(boolean shortcut) {
|
public JpackageOptions linuxPackageDeps(boolean packageDeps) {
|
||||||
if (shortcut) {
|
if (packageDeps) {
|
||||||
put("--linux-shortcut");
|
put("--linux-package-deps");
|
||||||
} else {
|
} else {
|
||||||
remove("--linux-shortcut");
|
remove("--linux-package-deps");
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +309,9 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of the license ({@code License: <value>} of the RPM .spec)
|
* Type of the license.
|
||||||
|
* <p>
|
||||||
|
* {@code License: <value>} of the RPM {@code .spec}
|
||||||
*
|
*
|
||||||
* @param licenseType the license type
|
* @param licenseType the license type
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -343,6 +321,21 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a shortcut for the application.
|
||||||
|
*
|
||||||
|
* @param shortcut {@code true| to create a shortcut, {@code false} otherwise
|
||||||
|
* @return this map of options
|
||||||
|
*/
|
||||||
|
public JpackageOptions linuxShortcut(boolean shortcut) {
|
||||||
|
if (shortcut) {
|
||||||
|
put("--linux-shortcut");
|
||||||
|
} else {
|
||||||
|
remove("--linux-shortcut");
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String used to construct {@code LSApplicationCategoryType} in application plist.
|
* String used to construct {@code LSApplicationCategoryType} in application plist.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -439,7 +432,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the application as it appears in the Menu Bar
|
* Name of the application as it appears in the Menu Bar.
|
||||||
* <p>
|
* <p>
|
||||||
* This can be different from the application name.
|
* This can be different from the application name.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -530,7 +523,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
/**
|
/**
|
||||||
* The main JAR of the application; containing the main class.
|
* The main JAR of the application; containing the main class.
|
||||||
* <p>
|
* <p>
|
||||||
* Either {@link #module(String, String) module} or {@link #mainJar(String) mainJar} option can be specified but not both.
|
* Either {@link #module(String, String) module} or {@link #mainJar(String) mainJar} option can be specified but
|
||||||
|
* not both.
|
||||||
*
|
*
|
||||||
* @param jar the path relative to the input path
|
* @param jar the path relative to the input path
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -548,7 +542,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
* <p>
|
* <p>
|
||||||
* When this option is specified, the main module will be linked in the Java runtime image.
|
* When this option is specified, the main module will be linked in the Java runtime image.
|
||||||
* <p>
|
* <p>
|
||||||
* Either {@link #module(String, String) module} or {@link #mainJar(String) mainJar} option can be specified but not both.
|
* Either {@link #module(String, String) module} or {@link #mainJar(String) mainJar} option can be specified but
|
||||||
|
* not both.
|
||||||
*
|
*
|
||||||
* @param name the module name
|
* @param name the module name
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -565,7 +560,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
* <p>
|
* <p>
|
||||||
* When this option is specified, the main module will be linked in the Java runtime image.
|
* When this option is specified, the main module will be linked in the Java runtime image.
|
||||||
* <p>
|
* <p>
|
||||||
* Either {@link #module(String, String) module} or {@link #mainJar(String) mainJar} option can be specified but not both.
|
* Either {@link #module(String, String) module} or {@link #mainJar(String) mainJar} option can be specified but
|
||||||
|
* not both.
|
||||||
*
|
*
|
||||||
* @param name the module name
|
* @param name the module name
|
||||||
* @param mainClass the main class
|
* @param mainClass the main class
|
||||||
|
@ -577,16 +573,6 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Associates {@code null} with the specified key in this map. If the map previously contained a mapping for the
|
|
||||||
* key, the old value is replaced.
|
|
||||||
*
|
|
||||||
* @param key key with which the specified value is to be associated
|
|
||||||
*/
|
|
||||||
public void put(String key) {
|
|
||||||
put(key, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of module paths.
|
* List of module paths.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -598,7 +584,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
*/
|
*/
|
||||||
public JpackageOptions modulePath(String... path) {
|
public JpackageOptions modulePath(String... path) {
|
||||||
put("--module-path", String.join(",", path));
|
put("--module-path", String.join(":", path));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,6 +599,16 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associates {@code null} with the specified key in this map. If the map previously contained a mapping for the
|
||||||
|
* key, the old value is replaced.
|
||||||
|
*
|
||||||
|
* @param key key with which the specified value is to be associated
|
||||||
|
*/
|
||||||
|
public void put(String key) {
|
||||||
|
put(key, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to override jpackage resources.
|
* Path to override jpackage resources.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -677,6 +673,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of package to create.
|
* The type of package to create.
|
||||||
|
* <p>
|
||||||
|
* If this option is not specified a platform dependent default type will be created.
|
||||||
*
|
*
|
||||||
* @param type the package type
|
* @param type the package type
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -729,7 +727,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a dialog to enable the user to choose a directory in which the product is installed..
|
* Adds a dialog to enable the user to choose a directory in which the product is installed.
|
||||||
*
|
*
|
||||||
* @param winDirChooser {@code true} to let the user choose a directory, {@code false} otherwise
|
* @param winDirChooser {@code true} to let the user choose a directory, {@code false} otherwise
|
||||||
* @return this map of options
|
* @return this map of options
|
||||||
|
@ -867,7 +865,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of launcher, and a path to a Properties file that contains a list of key, value pairs/
|
* Name of launcher, and a path to a Properties file that contains a list of key, value pairs.
|
||||||
* <p>
|
* <p>
|
||||||
* The keys {@code module}, {@code main-jar}, {@code main-class}, {@code description},
|
* The keys {@code module}, {@code main-jar}, {@code main-class}, {@code description},
|
||||||
* {@code arguments}, {@code java-options}, {@code app-version}, {@code icon},
|
* {@code arguments}, {@code java-options}, {@code app-version}, {@code icon},
|
||||||
|
|
|
@ -15,24 +15,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestJlinkOperation {
|
public class TestJlinkOperation {
|
||||||
@Test
|
@Test
|
||||||
void testNoArguments() {
|
void testArguments() {
|
||||||
var jlink = new JlinkOperation();
|
|
||||||
assertThrows(ExitStatusException.class, jlink::execute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testDisablePlugin() {
|
|
||||||
var jlink = new JlinkOperation()
|
|
||||||
.disablePlugin("vm")
|
|
||||||
.disablePlugin("system-modules")
|
|
||||||
.listPlugins();
|
|
||||||
assertDoesNotThrow(jlink::execute);
|
|
||||||
|
|
||||||
assertTrue(jlink.toolArgs().containsAll(List.of("vm", "system-modules")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testOptions() {
|
|
||||||
var args = new HashMap<String, String>();
|
var args = new HashMap<String, String>();
|
||||||
args.put("--add-modules", "module-1,module-2");
|
args.put("--add-modules", "module-1,module-2");
|
||||||
args.put("--bind-services", null);
|
args.put("--bind-services", null);
|
||||||
|
@ -78,9 +61,40 @@ public class TestJlinkOperation {
|
||||||
assertEquals("name-2=module-2", options.get("--launcher"), "incorrect launcher");
|
assertEquals("name-2=module-2", options.get("--launcher"), "incorrect launcher");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDisablePlugin() {
|
||||||
|
var jlink = new JlinkOperation()
|
||||||
|
.disablePlugin("vm")
|
||||||
|
.disablePlugin("system-modules")
|
||||||
|
.listPlugins();
|
||||||
|
assertDoesNotThrow(jlink::execute);
|
||||||
|
|
||||||
|
assertTrue(jlink.toolArgs().containsAll(List.of("vm", "system-modules")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testHelp() {
|
||||||
|
var jlink = new JlinkOperation().addArgs("--help");
|
||||||
|
assertDoesNotThrow(jlink::execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testNoArguments() {
|
||||||
|
var jlink = new JlinkOperation();
|
||||||
|
assertTrue(jlink.jlinkOptions().isEmpty(), "jlink options not empty");
|
||||||
|
assertTrue(jlink.options().isEmpty(), "options not empty");
|
||||||
|
assertThrows(ExitStatusException.class, jlink::execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testOptions() {
|
||||||
|
var jlink = new JlinkOperation().options("src/test/resources/options_verbose.txt");
|
||||||
|
assertDoesNotThrow(jlink::execute);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testVersion() {
|
void testVersion() {
|
||||||
var jlink = new JlinkOperation().addArgs("--version");
|
var jlink = new JlinkOperation().addArgs("--verbose", "--version");
|
||||||
assertDoesNotThrow(jlink::execute);
|
assertDoesNotThrow(jlink::execute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestJmodOperation {
|
public class TestJmodOperation {
|
||||||
@Test
|
@Test
|
||||||
void testNoArguments() {
|
void testArguments() {
|
||||||
var jmod = new JmodOperation();
|
|
||||||
assertThrows(ExitStatusException.class, jmod::execute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testOptions() {
|
|
||||||
var args = new HashMap<String, String>();
|
var args = new HashMap<String, String>();
|
||||||
args.put("--class-path", "classpath");
|
args.put("--class-path", "classpath");
|
||||||
args.put("--cmds", "cmds");
|
args.put("--cmds", "cmds");
|
||||||
|
@ -43,7 +37,6 @@ public class TestJmodOperation {
|
||||||
args.put("--module-version", "module-version");
|
args.put("--module-version", "module-version");
|
||||||
args.put("--target-platform", "target-platform");
|
args.put("--target-platform", "target-platform");
|
||||||
args.put("--warn-if-resolved", "deprecated");
|
args.put("--warn-if-resolved", "deprecated");
|
||||||
args.put("@filename", null);
|
|
||||||
|
|
||||||
var options = new JmodOptions()
|
var options = new JmodOptions()
|
||||||
.classpath(args.get("--class-path"))
|
.classpath(args.get("--class-path"))
|
||||||
|
@ -56,7 +49,6 @@ public class TestJmodOperation {
|
||||||
.dryRun(true)
|
.dryRun(true)
|
||||||
.exclude(new JmodOptions.FilePattern(JmodOptions.FilePatternType.GLOB, "glob"),
|
.exclude(new JmodOptions.FilePattern(JmodOptions.FilePatternType.GLOB, "glob"),
|
||||||
new JmodOptions.FilePattern(JmodOptions.FilePatternType.REGEX, "regex"))
|
new JmodOptions.FilePattern(JmodOptions.FilePatternType.REGEX, "regex"))
|
||||||
.filename("filename")
|
|
||||||
.hashModules(args.get("--hash-modules"))
|
.hashModules(args.get("--hash-modules"))
|
||||||
.headerFiles(args.get("--header-files"))
|
.headerFiles(args.get("--header-files"))
|
||||||
.legalNotices(args.get("--legal-notices"))
|
.legalNotices(args.get("--legal-notices"))
|
||||||
|
@ -76,6 +68,29 @@ public class TestJmodOperation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testHelp() {
|
||||||
|
var jmod = new JmodOperation()
|
||||||
|
.operationMode(JmodOperation.OperationMode.HASH)
|
||||||
|
.jmodFile("foo")
|
||||||
|
.addArgs("--help-extra");
|
||||||
|
assertDoesNotThrow(jmod::execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testNoArguments() {
|
||||||
|
var jmod = new JmodOperation();
|
||||||
|
assertTrue(jmod.options().isEmpty(), "options not empty");
|
||||||
|
assertTrue(jmod.jmodOptions().isEmpty(), "jmod options not empty");
|
||||||
|
assertThrows(ExitStatusException.class, jmod::execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testOptions() {
|
||||||
|
var jpackage = new JpackageOperation().options("src/test/resources/options_version.txt");
|
||||||
|
assertDoesNotThrow(jpackage::execute);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testVersion() {
|
void testVersion() {
|
||||||
var jmod = new JmodOperation()
|
var jmod = new JmodOperation()
|
||||||
|
|
|
@ -15,44 +15,9 @@ import java.util.HashMap;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestJpackageOperation {
|
public class TestJpackageOperation {
|
||||||
@Test
|
|
||||||
void testCreatePackage() throws Exception {
|
|
||||||
var tmpdir = Files.createTempDirectory("bld-jpackage-test").toFile();
|
|
||||||
tmpdir.deleteOnExit();
|
|
||||||
|
|
||||||
var options = new JpackageOptions()
|
|
||||||
.input("lib/bld")
|
|
||||||
.name("bld")
|
|
||||||
.mainJar("bld-wrapper.jar")
|
|
||||||
.javaOptions("--enable-preview")
|
|
||||||
.dest(tmpdir.getAbsolutePath())
|
|
||||||
.verbose(true);
|
|
||||||
|
|
||||||
var os = System.getProperty("os.version");
|
|
||||||
if (os.endsWith("MANJARO")) {
|
|
||||||
options.type(JpackageOptions.PackageType.DEB);
|
|
||||||
}
|
|
||||||
|
|
||||||
var jpackage = new JpackageOperation().jpackageOptions(options);
|
|
||||||
jpackage.execute();
|
|
||||||
|
|
||||||
var files = tmpdir.listFiles();
|
|
||||||
assertNotNull(files, "files should not be null");
|
|
||||||
assertTrue(files.length > 0, "No files found");
|
|
||||||
|
|
||||||
assertTrue(files[0].getName().matches("bld.*\\.[A-Za-z]{3}"), "Package not found");
|
|
||||||
|
|
||||||
FileUtils.deleteDirectory(tmpdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testNoArguments() {
|
void testArguments() {
|
||||||
var jpackage = new JpackageOperation();
|
|
||||||
assertThrows(ExitStatusException.class, jpackage::execute);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testOptions() {
|
|
||||||
var args = new HashMap<String, String>();
|
var args = new HashMap<String, String>();
|
||||||
args.put("--about-url", "about-url");
|
args.put("--about-url", "about-url");
|
||||||
args.put("--add-launcher", "name=path");
|
args.put("--add-launcher", "name=path");
|
||||||
|
@ -95,7 +60,7 @@ public class TestJpackageOperation {
|
||||||
args.put("--main-class", "main-class");
|
args.put("--main-class", "main-class");
|
||||||
args.put("--main-jar", "main-jar");
|
args.put("--main-jar", "main-jar");
|
||||||
args.put("--module", "module");
|
args.put("--module", "module");
|
||||||
args.put("--module-path", "module-path-1,module-path-2");
|
args.put("--module-path", "module-path-1:module-path-2");
|
||||||
args.put("--name", "name");
|
args.put("--name", "name");
|
||||||
args.put("--resource-dir", "resource-dir");
|
args.put("--resource-dir", "resource-dir");
|
||||||
args.put("--runtime-image", "runtime-image");
|
args.put("--runtime-image", "runtime-image");
|
||||||
|
@ -114,7 +79,6 @@ public class TestJpackageOperation {
|
||||||
args.put("--win-shortcut-prompt", null);
|
args.put("--win-shortcut-prompt", null);
|
||||||
args.put("--win-update-url", "win-update-url");
|
args.put("--win-update-url", "win-update-url");
|
||||||
args.put("--win-upgrade-uuid", "win-upgrade-uuid");
|
args.put("--win-upgrade-uuid", "win-upgrade-uuid");
|
||||||
args.put("@filename", null);
|
|
||||||
|
|
||||||
var options = new JpackageOptions()
|
var options = new JpackageOptions()
|
||||||
.aboutUrl(args.get("--about-url"))
|
.aboutUrl(args.get("--about-url"))
|
||||||
|
@ -176,8 +140,7 @@ public class TestJpackageOperation {
|
||||||
.winShortcut(true)
|
.winShortcut(true)
|
||||||
.winShortcutPrompt(true)
|
.winShortcutPrompt(true)
|
||||||
.winUpdateUrl(args.get("--win-update-url"))
|
.winUpdateUrl(args.get("--win-update-url"))
|
||||||
.winUpgradeUuid(args.get("--win-upgrade-uuid"))
|
.winUpgradeUuid(args.get("--win-upgrade-uuid"));
|
||||||
.filename("filename");
|
|
||||||
|
|
||||||
assertEquals(options.size(), args.size(), "Wrong number of arguments");
|
assertEquals(options.size(), args.size(), "Wrong number of arguments");
|
||||||
|
|
||||||
|
@ -188,9 +151,59 @@ public class TestJpackageOperation {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testCreatePackage() throws Exception {
|
||||||
|
var tmpdir = Files.createTempDirectory("bld-jpackage-test").toFile();
|
||||||
|
tmpdir.deleteOnExit();
|
||||||
|
|
||||||
|
var options = new JpackageOptions()
|
||||||
|
.input("lib/bld")
|
||||||
|
.name("bld")
|
||||||
|
.mainJar("bld-wrapper.jar")
|
||||||
|
.javaOptions("--enable-preview")
|
||||||
|
.dest(tmpdir.getAbsolutePath())
|
||||||
|
.verbose(true);
|
||||||
|
|
||||||
|
var os = System.getProperty("os.version");
|
||||||
|
if (os.endsWith("MANJARO")) {
|
||||||
|
options.type(JpackageOptions.PackageType.DEB);
|
||||||
|
}
|
||||||
|
|
||||||
|
var jpackage = new JpackageOperation().jpackageOptions(options);
|
||||||
|
jpackage.execute();
|
||||||
|
|
||||||
|
var files = tmpdir.listFiles();
|
||||||
|
assertNotNull(files, "files should not be null");
|
||||||
|
assertTrue(files.length > 0, "No files found");
|
||||||
|
|
||||||
|
assertTrue(files[0].getName().matches("bld.*\\.[A-Za-z]{3}"), "Package not found");
|
||||||
|
|
||||||
|
FileUtils.deleteDirectory(tmpdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testHelp() {
|
||||||
|
var jpackage = new JpackageOperation().addArgs("--help");
|
||||||
|
assertDoesNotThrow(jpackage::execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testNoArguments() {
|
||||||
|
var jpackage = new JpackageOperation();
|
||||||
|
assertTrue(jpackage.options().isEmpty(), "options not empty");
|
||||||
|
assertTrue(jpackage.jpackageOptions().isEmpty(), "jpackage options not empty");
|
||||||
|
assertThrows(ExitStatusException.class, jpackage::execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testOptions() {
|
||||||
|
var jpackage = new JpackageOperation().options("src/test/resources/options_verbose.txt");
|
||||||
|
assertDoesNotThrow(jpackage::execute);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testVersion() {
|
void testVersion() {
|
||||||
var jpackage = new JpackageOperation().addArgs("--version");
|
var jpackage = new JpackageOperation().addArgs("--verbose", "--version");
|
||||||
assertDoesNotThrow(jpackage::execute);
|
assertDoesNotThrow(jpackage::execute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
src/test/resources/options_verbose.txt
Normal file
1
src/test/resources/options_verbose.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
--verbose --version
|
1
src/test/resources/options_version.txt
Normal file
1
src/test/resources/options_version.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
--version
|
Loading…
Add table
Add a link
Reference in a new issue