2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 16:27:11 -07:00

Cleaned up and improved tests

This commit is contained in:
Erik C. Thauvin 2024-08-02 02:54:46 -07:00
parent d69956cf91
commit 0ad964ea4d
Signed by: erik
GPG key ID: 776702A6A2DA330E
10 changed files with 685 additions and 304 deletions

View file

@ -9,7 +9,6 @@ import rife.bld.operations.exceptions.ExitStatusException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.spi.ToolProvider; import java.util.spi.ToolProvider;
@ -22,7 +21,7 @@ import java.util.spi.ToolProvider;
*/ */
public abstract class AbstractToolProviderOperation<T extends AbstractToolProviderOperation<T>> public abstract class AbstractToolProviderOperation<T extends AbstractToolProviderOperation<T>>
extends AbstractOperation<AbstractToolProviderOperation<T>> { extends AbstractOperation<AbstractToolProviderOperation<T>> {
private final Map<String, String> toolArgs_ = new HashMap<>(); private final List<String> toolArgs_ = new ArrayList<>();
private final String toolName_; private final String toolName_;
/** /**
@ -34,35 +33,6 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
toolName_ = toolName; toolName_ = toolName;
} }
/**
* Converts arguments to a list.
*
* @param args the argument-value pairs
* @return the arguments list
*/
static List<String> argsToList(Map<String, String> args) {
var list = new ArrayList<String>();
for (String arg : args.keySet()) {
var value = args.get(arg);
list.add(arg);
if (value != null && !value.isEmpty()) {
list.add(value);
}
}
return list;
}
/**
* Adds tool command line argument.
*
* @param arg the argument to add
* @return this operation
*/
public T toolArg(String arg) {
toolArgs_.put(arg, null);
return (T) this;
}
/** /**
* Add tool command line argument. * Add tool command line argument.
* *
@ -70,8 +40,12 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
* @param value the value * @param value the value
* @return this operation * @return this operation
*/ */
public T toolArg(String arg, String value) { @SuppressWarnings({"unchecked", "UnusedReturnValue"})
toolArgs_.put(arg, value); public T addArg(String arg, String value) {
toolArgs_.add(arg);
if (value != null && !value.isEmpty()) {
toolArgs_.add(value);
}
return (T) this; return (T) this;
} }
@ -81,18 +55,33 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
* @param args the argument-value pairs to add * @param args the argument-value pairs to add
* @return this operation * @return this operation
*/ */
protected T toolArgs(Map<String, String> args) { @SuppressWarnings({"unchecked", "UnusedReturnValue"})
toolArgs_.putAll(args); protected T addArgs(Map<String, String> args) {
args.forEach(this::addArg);
return (T) this; return (T) this;
} }
/** /**
* Clears the tool command line arguments. * Adds tool command line arguments.
* *
* @param args the argument to add
* @return this operation * @return this operation
*/ */
protected T clearToolArguments() { @SuppressWarnings({"unchecked", "UnusedReturnValue"})
toolArgs_.clear(); public T addArgs(List<String> args) {
toolArgs_.addAll(args);
return (T) this;
}
/**
* Adds tool command line arguments.
*
* @param arg one or more argument
* @return this operation
*/
@SuppressWarnings("unchecked")
public T addArgs(String... arg) {
addArgs(List.of(arg));
return (T) this; return (T) this;
} }
@ -105,17 +94,15 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
var tool = ToolProvider.findFirst(toolName_).orElseThrow(() -> var tool = ToolProvider.findFirst(toolName_).orElseThrow(() ->
new IllegalStateException("No " + toolName_ + " tool found.")); new IllegalStateException("No " + toolName_ + " tool found."));
var argsList = argsToList(toolArgs_);
var stderr = new StringWriter(); var stderr = new StringWriter();
var stdout = new StringWriter(); var stdout = new StringWriter();
try (var err = new PrintWriter(stderr); var out = new PrintWriter(stdout)) { try (var err = new PrintWriter(stderr); var out = new PrintWriter(stdout)) {
var status = tool.run(out, err, argsList.toArray(new String[0])); var status = tool.run(out, err, toolArgs_.toArray(new String[0]));
out.flush(); out.flush();
err.flush(); err.flush();
if (status != 0) { if (status != 0) {
System.out.println(tool.name() + " " + String.join(" ", argsList)); System.out.println(tool.name() + ' ' + String.join(" ", toolArgs_));
} }
var output = stdout.toString(); var output = stdout.toString();
@ -136,7 +123,7 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
* *
* @return the arguments * @return the arguments
*/ */
public Map<String, String> toolArgs() { public List<String> toolArgs() {
return toolArgs_; return toolArgs_;
} }
} }

View file

@ -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,14 +17,26 @@ import java.util.Map;
*/ */
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> { public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
private final JlinkOptions jlinkOptions_ = new JlinkOptions(); private final JlinkOptions jlinkOptions_ = new JlinkOptions();
private final List<String> disabledPlugins_ = new ArrayList<>();
public JlinkOperation() { public JlinkOperation() {
super("jlink"); super("jlink");
} }
/**
* Disable the plugin mentioned.
*
* @param plugin the plugin name
* @return this map of options
*/
public JlinkOperation disablePlugin(String... plugin) {
disabledPlugins_.addAll(List.of(plugin));
return this;
}
@Override @Override
public void execute() throws Exception { public void execute() throws Exception {
toolArgs(jlinkOptions_); disabledPlugins_.forEach(plugin -> addArg("--disable-plugin", plugin));
super.execute(); super.execute();
} }
@ -31,12 +45,22 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
* <p> * <p>
* This is a modifiable list that can be retrieved and changed. * This is a modifiable list that can be retrieved and changed.
* *
* @return the list of jlink options * @return the map of jlink options
*/ */
public JlinkOptions jlinkOptions() { public JlinkOptions jlinkOptions() {
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>

View file

@ -4,7 +4,9 @@
*/ */
package rife.bld.operations; package rife.bld.operations;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
/** /**
* Options for jlink tool. * Options for jlink tool.
@ -39,13 +41,24 @@ public class JlinkOptions extends HashMap<String, String> {
*/ */
public JlinkOptions bindServices(boolean bindServices) { public JlinkOptions bindServices(boolean bindServices) {
if (bindServices) { if (bindServices) {
put("--bind-services", null); put("--bind-services");
} else { } else {
remove("--bind-services"); remove("--bind-services");
} }
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>
@ -61,16 +74,6 @@ public class JlinkOptions extends HashMap<String, String> {
return this; return this;
} }
/**
* Disable the plugin mentioned.
*
* @param plugin the plugin name
* @return this map of options
*/
public JlinkOptions disablePlugin(String plugin) {
put("--disable-plugin", plugin);
return this;
}
/** /**
* Byte order of generated jimage. * Byte order of generated jimage.
@ -85,17 +88,6 @@ 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, null);
return this;
}
/** /**
* Suppress a fatal error when signed modular JARs are linked in the image. * Suppress a fatal error when signed modular JARs are linked in the image.
* *
@ -104,7 +96,7 @@ public class JlinkOptions extends HashMap<String, String> {
*/ */
public JlinkOptions ignoreSigningInformation(boolean ignoreSigningInformation) { public JlinkOptions ignoreSigningInformation(boolean ignoreSigningInformation) {
if (ignoreSigningInformation) { if (ignoreSigningInformation) {
put("--ignore-signing-information", null); put("--ignore-signing-information");
} else { } else {
remove("--ignore-signing-information"); remove("--ignore-signing-information");
} }
@ -123,6 +115,21 @@ public class JlinkOptions extends HashMap<String, String> {
return this; return this;
} }
/**
* Exclude include header files.
*
* @param noHeaderFiles {@code true} to exclude header files, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions noHeaderFiles(boolean noHeaderFiles) {
if (noHeaderFiles) {
put("--no-header-files");
} else {
remove("--no-header-files");
}
return this;
}
/** /**
* Add a launcher command of the given name for the module and the main class. * Add a launcher command of the given name for the module and the main class.
* *
@ -161,21 +168,6 @@ public class JlinkOptions extends HashMap<String, String> {
return this; return this;
} }
/**
* Exclude include header files.
*
* @param noHeaderFiles {@code true} to exclude header files, {@code false} otherwise
* @return this map of options
*/
public JlinkOptions noHeaderFiles(boolean noHeaderFiles) {
if (noHeaderFiles) {
put("--no-header-files", null);
} else {
remove("--no-header-files");
}
return this;
}
/** /**
* Exclude man pages. * Exclude man pages.
* *
@ -184,13 +176,23 @@ public class JlinkOptions extends HashMap<String, String> {
*/ */
public JlinkOptions noManPages(boolean noManPages) { public JlinkOptions noManPages(boolean noManPages) {
if (noManPages) { if (noManPages) {
put("--no-man-pages", null); put("--no-man-pages");
} else { } else {
remove("--no-man-pages"); remove("--no-man-pages");
} }
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);
}
/** /**
* Location of output path. * Location of output path.
* *
@ -221,7 +223,7 @@ public class JlinkOptions extends HashMap<String, String> {
*/ */
public JlinkOptions stripDebug(boolean stripDebug) { public JlinkOptions stripDebug(boolean stripDebug) {
if (stripDebug) { if (stripDebug) {
put("--strip-debug", null); put("--strip-debug");
} else { } else {
remove("--strip-debug"); remove("--strip-debug");
} }
@ -236,7 +238,7 @@ public class JlinkOptions extends HashMap<String, String> {
*/ */
public JlinkOptions stripNativeCommands(boolean stripNativeCommands) { public JlinkOptions stripNativeCommands(boolean stripNativeCommands) {
if (stripNativeCommands) { if (stripNativeCommands) {
put("--strip-native-commands", null); put("--strip-native-commands");
} else { } else {
remove("--strip-native-commands"); remove("--strip-native-commands");
} }
@ -254,6 +256,17 @@ public class JlinkOptions extends HashMap<String, String> {
return this; return this;
} }
public List<String> toList() {
var list = new ArrayList<String>();
forEach((k, v) -> {
list.add(k);
if (v != null && !v.isEmpty()) {
list.add(v);
}
});
return list;
}
/** /**
* Enable verbose tracing * Enable verbose tracing
* *
@ -262,7 +275,7 @@ public class JlinkOptions extends HashMap<String, String> {
*/ */
public JlinkOptions verbose(boolean verbose) { public JlinkOptions verbose(boolean verbose) {
if (verbose) { if (verbose) {
put("--verbose", null); put("--verbose");
} else { } else {
remove("--verbose"); remove("--verbose");
} }
@ -281,4 +294,5 @@ public class JlinkOptions extends HashMap<String, String> {
this.byteOrder = byteOrder; this.byteOrder = byteOrder;
} }
} }
} }

View file

@ -17,6 +17,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 String jmodFile_;
private OperationMode operationMode_; private OperationMode operationMode_;
public JmodOperation() { public JmodOperation() {
@ -28,18 +29,44 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
if (operationMode_ == null) { if (operationMode_ == null) {
System.err.println("Operation mode not set."); System.err.println("Operation mode not set.");
throw new ExitStatusException(ExitStatusException.EXIT_FAILURE); throw new ExitStatusException(ExitStatusException.EXIT_FAILURE);
} else if (jmodFile_ == null) {
System.err.println("Jmod file not set.");
throw new ExitStatusException(ExitStatusException.EXIT_FAILURE);
} }
toolArg(operationMode_.mode); addArgs(operationMode_.mode);
toolArgs(jmodOptions_); addArgs(jmodOptions_);
addArgs(jmodFile_);
super.execute(); super.execute();
} }
/**
* Retrieves the name of the JMOD file to create or from which to retrieve information.
*
* @return the JMOD file
*/
public String jmodFile() {
return jmodFile_;
}
/**
* Specifies name of the JMOD file to create or from which to retrieve information.
* <p>
* The JMOD file is <b>required</b>.
*
* @param file the JMOD file
* @return this operation instance
*/
public JmodOperation jmodFile(String file) {
jmodFile_ = file;
return this;
}
/** /**
* Retrieves the list of options for the jmod tool. * Retrieves the list of options for the jmod tool.
* <p> * <p>
* This is a modifiable list that can be retrieved and changed. * This is a modifiable list that can be retrieved and changed.
* *
* @return the list of jmod options * @return the map of jmod options
*/ */
public JmodOptions jmodOptions() { public JmodOptions jmodOptions() {
return jmodOptions_; return jmodOptions_;
@ -59,7 +86,9 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
} }
/** /**
* Provides the required {@link OperationMode operation mode}. * Provides the {@link OperationMode operation mode}.
* <p>
* The operation mode is <b>required</b>.
* *
* @param mode the mode * @param mode the mode
* @return this operation instance * @return this operation instance
@ -73,10 +102,25 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
* The operation modes. * The operation modes.
*/ */
public enum OperationMode { public enum OperationMode {
/**
* Creates a new JMOD archive file.
*/
CREATE("create"), CREATE("create"),
/**
* Prints the module details.
*/
DESCRIBE("describe"), DESCRIBE("describe"),
/**
* Extracts all the files from the JMOD archive file.
*/
EXTRACT("extract"), EXTRACT("extract"),
/**
* Determines leaf modules and records the hashes of the dependencies that directly and indirectly require them.
*/
HASH("hash"), HASH("hash"),
/**
* Prints the names of all the entries.
*/
LIST("list"); LIST("list");
final String mode; final String mode;

View file

@ -94,7 +94,7 @@ public class JmodOptions extends HashMap<String, String> {
*/ */
public JmodOptions doNotResolveByDefault(boolean doNotResolveByDefault) { public JmodOptions doNotResolveByDefault(boolean doNotResolveByDefault) {
if (doNotResolveByDefault) { if (doNotResolveByDefault) {
put("--do-not-resolve-by-default", null); put("--do-not-resolve-by-default");
} else { } else {
remove("--do-not-resolve-by-default"); remove("--do-not-resolve-by-default");
} }
@ -109,7 +109,7 @@ public class JmodOptions extends HashMap<String, String> {
*/ */
public JmodOptions dryRun(boolean dryRun) { public JmodOptions dryRun(boolean dryRun) {
if (dryRun) { if (dryRun) {
put("--dry-run", null); put("--dry-run");
} else { } else {
remove("--dry-run"); remove("--dry-run");
} }
@ -120,7 +120,7 @@ public class JmodOptions extends HashMap<String, String> {
* Exclude files matching the supplied pattern list. * Exclude files matching the supplied pattern list.
* *
* @param pattern one or more pattern * @param pattern one or more pattern
* @return the list of options * @return the map of options
*/ */
public JmodOptions exclude(FilePattern... pattern) { public JmodOptions exclude(FilePattern... pattern) {
var args = new ArrayList<String>(); var args = new ArrayList<String>();
@ -142,10 +142,20 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions filename(String filename) { public JmodOptions filename(String filename) {
put("@" + filename, null); put("@" + filename);
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);
}
/** /**
* Compute and record hashes to tie a packaged module with modules matching the given regular expression pattern and * Compute and record hashes to tie a packaged module with modules matching the given regular expression pattern and
* depending upon it directly or indirectly. The hashes are recorded in the JMOD file being created, or a JMOD file * depending upon it directly or indirectly. The hashes are recorded in the JMOD file being created, or a JMOD file

View file

@ -22,7 +22,7 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
@Override @Override
public void execute() throws Exception { public void execute() throws Exception {
toolArgs(jpackageOptions_); addArgs(jpackageOptions_);
super.execute(); super.execute();
} }

View file

@ -25,6 +25,17 @@ 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>
@ -68,17 +79,6 @@ 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;
}
/** /**
* Location of the predefined application image that is used to build an installable package. * Location of the predefined application image that is used to build an installable package.
* *
@ -160,13 +160,13 @@ public class JpackageOptions extends HashMap<String, String> {
} }
/** /**
* Read options and/or mode from a file. * Options to pass to the Java runtime.
* *
* @param filename the filename * @param options the options
* @return this map of options * @return this map of options
*/ */
public JpackageOptions filename(String filename) { public JpackageOptions javaOptions(String... options) {
put("@" + filename, null); put("--java-options", String.join(" ", options));
return this; return this;
} }
@ -205,6 +205,22 @@ public class JpackageOptions extends HashMap<String, String> {
return this; return this;
} }
/**
* Request to create an installer that will register the main application launcher as a background service-type
* application.
*
* @param launcherAsService {@code true} to register the launcher as a service; {@code false} otherwise
* @return this map of options
*/
public JpackageOptions launcherAsService(boolean launcherAsService) {
if (launcherAsService) {
put("--launcher-as-service");
} else {
remove("--launcher-as-service");
}
return this;
}
/** /**
* List of options to pass to jlink. * List of options to pass to jlink.
* <p> * <p>
@ -216,22 +232,21 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions jlinkOptions(JlinkOptions options) { public JpackageOptions jlinkOptions(JlinkOptions options) {
put("--jlink-options", String.join(" ", AbstractToolProviderOperation.argsToList(options))); put("--jlink-options", String.join(" ", options.toList()));
return this; return this;
} }
/** /**
* Request to create an installer that will register the main application launcher as a background service-type * Required packages or capabilities for the application.
* application.
* *
* @param launcherAsService {@code true} to register the launcher as a service; {@code false} otherwise * @param packageDeps {@code true} if required, {@code false} otherwise
* @return this map of options * @return this map of options
*/ */
public JpackageOptions launcherAsService(boolean launcherAsService) { public JpackageOptions linuxPackageDeps(boolean packageDeps) {
if (launcherAsService) { if (packageDeps) {
put("--launcher-as-service", null); put("--linux-package-deps");
} else { } else {
remove("--launcher-as-service"); remove("--linux-package-deps");
} }
return this; return this;
} }
@ -292,13 +307,17 @@ public class JpackageOptions extends HashMap<String, String> {
} }
/** /**
* Required packages or capabilities for the application. * Creates a shortcut for the application.
* *
* @param packageDeps the package dependencies * @param shortcut {@code true| to create a shortcut, {@code false} otherwise
* @return this list of operation * @return this map of options
*/ */
public JpackageOptions linuxPackageDeps(String packageDeps) { public JpackageOptions linuxShortcut(boolean shortcut) {
put("--linux-package-deps", packageDeps); if (shortcut) {
put("--linux-shortcut");
} else {
remove("--linux-shortcut");
}
return this; return this;
} }
@ -325,20 +344,176 @@ public class JpackageOptions extends HashMap<String, String> {
} }
/** /**
* Creates a shortcut for the application. * String used to construct {@code LSApplicationCategoryType} in application plist.
* <p>
* The default value is {@code utilities}.
* *
* @param shortcut {@code true| to create a shortcut, {@code false} otherwise * @param appCategory the category
* @return this map of options * @return this map of options
*/ */
public JpackageOptions linuxShortcut(boolean shortcut) { public JpackageOptions macAppCategory(String appCategory) {
if (shortcut) { put("--mac-app-category", appCategory);
put("--linux-shortcut", null); return this;
}
/**
* Identity used to sign application image.
* <p>
* This value will be passed directly to {@code --sign} option of {@code codesign} tool.
* <p>
* This option cannot be combined with {@link #macSigningKeyUserName(String) macSignKeyUserName}.
*
* @param identity the identity
* @return this map of options
*/
public JpackageOptions macAppImageSignIdentity(String identity) {
put("--mac-app-image-sign-identity", identity);
return this;
}
/**
* Indicates that the jpackage output is intended for the Mac App Store.
*
* @param appStore {@code true} if intended for the Mac App Store, {@code false} otherwise
* @return this map of options
*/
public JpackageOptions macAppStore(boolean appStore) {
if (appStore) {
put("--mac-app-store");
} else { } else {
remove("--linux-shortcut"); remove("--mac-app-store");
} }
return this; return this;
} }
/**
* Include all the referenced content in the dmg.
*
* @param additionalContent one or more path
* @return this map of options
*/
public JpackageOptions macDmgContent(String... additionalContent) {
put("--mac-dmg-content", String.join(",", additionalContent));
return this;
}
/**
* Path to file containing entitlements to use when signing executables and libraries in the bundle.
*
* @param path the fie path
* @return this map of options
*/
public JpackageOptions macEntitlements(String path) {
put("--mac-entitlements", path);
return this;
}
/**
* Identity used to sign "pkg" installer.
* <p>
* This value will be passed directly to {@code --sign} option of {@code productbuild} tool.
* <p>
* This option cannot be combined with {@link #macSigningKeyUserName(String) macSignKeyUserName}.
*
* @param identity the identity
* @return this map of options
*/
public JpackageOptions macInstallerSignIdentity(String identity) {
put("--mac-installer-sign-identity", identity);
return this;
}
/**
* An identifier that uniquely identifies the application for macOS.
* <p>
* Defaults to the main class name.
* <p>
* May only use alphanumeric ({@code A-Z,a-z,0-9}), hyphen ({@code -}), and period ({@code .}) characters.
*
* @param packageIdentifier the package identifier
* @return this map of options
*/
public JpackageOptions macPackageIdentifier(String packageIdentifier) {
put("--mac-package-identifier", packageIdentifier);
return this;
}
/**
* Name of the application as it appears in the Menu Bar
* <p>
* This can be different from the application name.
* <p>
* This name must be less than 16 characters long and be suitable for displaying in the menu bar and the application
* Info window.
* <p>
* Defaults to the application name.
*
* @param name the package name
* @return this map of options
*/
public JpackageOptions macPackageName(String name) {
put("--mac-package-name", name);
return this;
}
/**
* When signing the application package, this value is prefixed to all components that need to be signed that don't
* have an existing package identifier.
*
* @param prefix the signing prefix
* @return this map of options
*/
public JpackageOptions macPackageSigningPrefix(String prefix) {
put("--mac-package-signing-prefix", prefix);
return this;
}
/**
* Request that the package or the predefined application image be signed.
*
* @param sign {@code true} to sign, {@code false} otherwise
* @return this map of options
*/
public JpackageOptions macSign(boolean sign) {
if (sign) {
put("--mac-sign");
} else {
remove("--mac-sign");
}
return this;
}
/**
* Team or user name portion in Apple signing identities.
* <p>
* For direct control of the signing identity used to sign application images or installers use
* {@link #macAppImageSignIdentity(String) macAppImageSignIdentity} and/or
* {@link #macInstallerSignIdentity(String) macInstallerSignIdentity}.
* <p>
* This option cannot be combined with {@link #macAppImageSignIdentity(String) macAppImageSignIdentity} or
* {@link #macInstallerSignIdentity(String) macInstallerSignIdentity}.
*
* @param username the username
* @return this map of options
*/
public JpackageOptions macSigningKeyUserName(String username) {
put("--mac-signing-key-user-name", username);
return this;
}
/**
* Name of the keychain to search for the signing identity.
* <p>
* If not specified, the standard keychains are used.
*
* @param keychain the keychain name
* @return this map of options
*/
public JpackageOptions macSigningKeychain(String keychain) {
put("--mac-signing-keychain", keychain);
return this;
}
/** /**
* Qualified name of the application main class to execute. * Qualified name of the application main class to execute.
* <p> * <p>
@ -360,6 +535,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @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
*/ */
@SuppressWarnings("JavadocDeclaration")
public JpackageOptions mainJar(String jar) { public JpackageOptions mainJar(String jar) {
put("--main-jar", jar); put("--main-jar", jar);
return this; return this;
@ -368,14 +544,14 @@ public class JpackageOptions extends HashMap<String, String> {
/** /**
* The main module and main class of the application. * The main module and main class of the application.
* <p> * <p>
* This module must be located on the {@link #modulePath(String) module path}. * This module must be located on the {@link #modulePath(String...) module path}.
* <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 list of operation * @return this map of options
*/ */
public JpackageOptions module(String name) { public JpackageOptions module(String name) {
put("--module", name); put("--module", name);
@ -385,7 +561,7 @@ public class JpackageOptions extends HashMap<String, String> {
/** /**
* The main module and main class of the application. * The main module and main class of the application.
* <p> * <p>
* This module must be located on the {@link #modulePath(String) module path}. * This module must be located on the {@link #modulePath(String...) module path}.
* <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>
@ -395,23 +571,20 @@ public class JpackageOptions extends HashMap<String, String> {
* @param mainClass the main class * @param mainClass the main class
* @return this map of options * @return this map of options
*/ */
@SuppressWarnings("JavadocDeclaration")
public JpackageOptions module(String name, String mainClass) { public JpackageOptions module(String name, String mainClass) {
put("--module-name", name + "/" + mainClass); put("--module-name", name + "/" + mainClass);
return this; return this;
} }
/** /**
* Module path. * Associates {@code null} with the specified key in this map. If the map previously contained a mapping for the
* <p> * key, the old value is replaced.
* If not specified, the JDKs jmods directory will be used, if it exists. If specified, but it does not contain the
* {@code java.base} module, the JDKs jmods directory will be added, if it exists.
* *
* @param path the module path * @param key key with which the specified value is to be associated
* @return this map of options
*/ */
public JpackageOptions modulePath(String path) { public void put(String key) {
put("--module-path", path); put(key, null);
return this;
} }
/** /**
@ -480,7 +653,7 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
public JpackageOptions stripDebug(boolean stripDebug) { public JpackageOptions stripDebug(boolean stripDebug) {
if (stripDebug) { if (stripDebug) {
put("--strip-debug", null); put("--strip-debug");
} else { } else {
remove("--strip-debug"); remove("--strip-debug");
} }
@ -524,126 +697,6 @@ public class JpackageOptions extends HashMap<String, String> {
return this; return this;
} }
/**
* An identifier that uniquely identifies the application for macOS.
* <p>
* Defaults to the main class name.
* <p>
* May only use alphanumeric ({@code A-Z,a-z,0-9}), hyphen ({@code -}), and period ({@code .}) characters.
*
* @param packageIdentifier the package identifier
* @return this map of options
*/
public JpackageOptions macPackageIdentifier(String packageIdentifier) {
put("--mac-package-identifier", packageIdentifier);
return this;
}
/**
* When signing the application package, this value is prefixed to all components that need to be signed that don't
* have an existing package identifier.
*
* @param packageSigningPrefix the signing prefix
* @return this map of options
*/
public JpackageOptions macPackageSigningPrefix(String packageSigningPrefix) {
put("--mac-package-signing-prefix", packageSigningPrefix);
return this;
}
/**
* When signing the application package, this value is prefixed to all components that need to be signed that don't
* have an existing package identifier.
*
* @param prefix the prefix
* @return this map of options
*/
public JpackageOptions macSign(String prefix) {
put("--mac-sign", prefix);
return this;
}
/**
* Name of the keychain to search for the signing identity.
* <p>
* If not specified, the standard keychains are used.
*
* @param keychain the keychain name
* @return this map of options
*/
public JpackageOptions macSigningKeychain(String keychain) {
put("--mac-signing-keychain", keychain);
return this;
}
/**
* Team or user name portion in Apple signing identities.
*
* @param username the username
* @return this map of options
*/
public JpackageOptions macSigningKeyUserName(String username) {
put("--mac-signing-key-user-name", username);
return this;
}
/**
* String used to construct {@code LSApplicationCategoryType} in application plist.
* <p>
* The default value is {@code utilities}.
*
* @param appCategory the category
* @return this map of options
*/
public JpackageOptions macAppCategory(String appCategory) {
put("--mac-app-category", appCategory);
return this;
}
/**
* Path to file containing entitlements to use when signing executables and libraries in the bundle.
*
* @param path the fie path
* @return this map of options
*/
public JpackageOptions macEntitlements(String path) {
put("--mac-entitlements", path);
return this;
}
/**
* Indicates that the jpackage output is intended for the Mac App Store.
*
* @param appStore {@code true} if intended for the Mac App Store, {@code false} otherwise
* @return this map of options
*/
public JpackageOptions macAppStore(boolean appStore) {
if (appStore) {
put("--mac-app-store", null);
} else {
remove("--mac-app-store");
}
return this;
}
/**
* Name of the application as it appears in the Menu Bar
* <p>
* This can be different from the application name.
* <p>
* This name must be less than 16 characters long and be suitable for displaying in the menu bar and the application
* Info window.
* <p>
* Defaults to the application name.
*
* @param name the package name
* @return this map of options
*/
public JpackageOptions macPackageName(String name) {
put("--mac-package-name", name);
return this;
}
/** /**
* Enables verbose output. * Enables verbose output.
* *
@ -652,13 +705,29 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
public JpackageOptions verbose(boolean verbose) { public JpackageOptions verbose(boolean verbose) {
if (verbose) { if (verbose) {
put("--verbose", null); put("--verbose");
} else { } else {
remove("--verbose"); remove("--verbose");
} }
return this; return this;
} }
/**
* Creates a console launcher for the application, should be specified for application which requires console
* interactions.
*
* @param winConsole {@code true} to create a console launcher, {@code false} otherwise
* @return this map of options
*/
public JpackageOptions winConsole(boolean winConsole) {
if (winConsole) {
put("--win-console");
} else {
remove("--win-console");
}
return this;
}
/** /**
* 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..
* *
@ -667,7 +736,7 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
public JpackageOptions winDirChooser(boolean winDirChooser) { public JpackageOptions winDirChooser(boolean winDirChooser) {
if (winDirChooser) { if (winDirChooser) {
put("--win-dir-chooser", null); put("--win-dir-chooser");
} else { } else {
remove("--win-dir-chooser"); remove("--win-dir-chooser");
} }
@ -693,7 +762,7 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
public JpackageOptions winMenu(boolean winMenu) { public JpackageOptions winMenu(boolean winMenu) {
if (winMenu) { if (winMenu) {
put("--win-menu", null); put("--win-menu");
} else { } else {
remove("--win-menu"); remove("--win-menu");
} }
@ -706,7 +775,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @param menuGroup the menu group * @param menuGroup the menu group
* @return this map of options * @return this map of options
*/ */
public JpackageOptions winMenuGroupM(String menuGroup) { public JpackageOptions winMenuGroup(String menuGroup) {
put("--win-menu-group", menuGroup); put("--win-menu-group", menuGroup);
return this; return this;
} }
@ -719,7 +788,7 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
public JpackageOptions winPerUserInstall(boolean winPerUserInstall) { public JpackageOptions winPerUserInstall(boolean winPerUserInstall) {
if (winPerUserInstall) { if (winPerUserInstall) {
put("--win-per-user-install", null); put("--win-per-user-install");
} else { } else {
remove("--win-per-user-install"); remove("--win-per-user-install");
} }
@ -734,7 +803,7 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
public JpackageOptions winShortcut(boolean winShortcut) { public JpackageOptions winShortcut(boolean winShortcut) {
if (winShortcut) { if (winShortcut) {
put("--win-shortcut", null); put("--win-shortcut");
} else { } else {
remove("--win-shortcut"); remove("--win-shortcut");
} }
@ -749,7 +818,7 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
public JpackageOptions winShortcutPrompt(boolean shortcutPrompt) { public JpackageOptions winShortcutPrompt(boolean shortcutPrompt) {
if (shortcutPrompt) { if (shortcutPrompt) {
put("--win-shortcut-prompt", null); put("--win-shortcut-prompt");
} else { } else {
remove("--win-shortcut-prompt"); remove("--win-shortcut-prompt");
} }
@ -778,33 +847,6 @@ public class JpackageOptions extends HashMap<String, String> {
return this; return this;
} }
/**
* Creates a console launcher for the application, should be specified for application which requires console
* interactions.
*
* @param winConsole {@code true} to create a console launcher, {@code false} otherwise
* @return this map of options
*/
public JpackageOptions winConsole(boolean winConsole) {
if (winConsole) {
put("--win-console", null);
} else {
remove("--win-console");
}
return this;
}
/**
* Include all the referenced content in the dmg.
*
* @param additionalContent one or more path
* @return this map of options
*/
public JpackageOptions macDmgContent(String... additionalContent) {
put("--mac-dmg-content", String.join(",", additionalContent));
return this;
}
/** /**
* The package types. * The package types.
*/ */

View file

@ -8,8 +8,10 @@ package rife.bld.operations;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import rife.bld.operations.exceptions.ExitStatusException; import rife.bld.operations.exceptions.ExitStatusException;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.util.HashMap;
import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
public class TestJlinkOperation { public class TestJlinkOperation {
@Test @Test
@ -18,9 +20,67 @@ public class TestJlinkOperation {
assertThrows(ExitStatusException.class, jlink::execute); 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>();
args.put("--add-modules", "module-1,module-2");
args.put("--bind-services", null);
args.put("--compress", "zip-6");
args.put("--endian", "big");
args.put("--ignore-signing-information", null);
args.put("--launcher", "name=module/mainclass");
args.put("--limit-modules", "module-1,module-2");
args.put("--module-path", "module-path");
args.put("--no-header-files", null);
args.put("--no-man-pages", null);
args.put("--output", "output");
args.put("--save-opts", "save-opts");
args.put("--strip-debug", null);
args.put("--suggest-providers", "provider-1,provider-2");
args.put("--verbose", null);
var options = new JlinkOptions()
.addModules(args.get("--add-modules").split(","))
.bindServices(true)
.compress(ZipCompression.ZIP_6)
.endian(JlinkOptions.Endian.BIG)
.ignoreSigningInformation(true)
.launcher("name", "module", "mainclass")
.limitModule(args.get("--limit-modules").split(","))
.modulePath(args.get("--module-path"))
.noHeaderFiles(true)
.noManPages(true)
.output(args.get("--output"))
.saveOpts(args.get("--save-opts"))
.stripDebug(true)
.suggestProviders(args.get("--suggest-providers").split(","))
.verbose(true);
assertEquals(options.size(), args.size(), "Wrong number of arguments");
for (var arg : args.entrySet()) {
assertTrue(options.containsKey(arg.getKey()), arg.getValue() + " not found");
assertEquals(arg.getValue(), options.get(arg.getKey()), arg.getKey());
}
options.launcher("name-2", "module-2");
assertEquals("name-2=module-2", options.get("--launcher"), "incorrect launcher");
}
@Test @Test
void testVersion() { void testVersion() {
var jlink = new JlinkOperation().toolArg("--version"); var jlink = new JlinkOperation().addArgs("--version");
assertDoesNotThrow(jlink::execute); assertDoesNotThrow(jlink::execute);
} }
} }

View file

@ -8,8 +8,11 @@ package rife.bld.operations;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import rife.bld.operations.exceptions.ExitStatusException; import rife.bld.operations.exceptions.ExitStatusException;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.time.ZoneId;
import static org.junit.jupiter.api.Assertions.assertThrows; import java.time.ZonedDateTime;
import java.util.HashMap;
import static org.junit.jupiter.api.Assertions.*;
public class TestJmodOperation { public class TestJmodOperation {
@Test @Test
@ -18,9 +21,67 @@ public class TestJmodOperation {
assertThrows(ExitStatusException.class, jmod::execute); assertThrows(ExitStatusException.class, jmod::execute);
} }
@Test
void testOptions() {
var args = new HashMap<String, String>();
args.put("--class-path", "classpath");
args.put("--cmds", "cmds");
args.put("--compress", "zip-5");
args.put("--config", "config");
args.put("--date", "1997-08-29T09:14:00Z");
args.put("--dir", "dir");
args.put("--do-not-resolve-by-default", null);
args.put("--dry-run", null);
args.put("--exclude", "glob:glob,regex:regex");
args.put("--hash-modules", "regex");
args.put("--header-files", "header-files");
args.put("--legal-notices", "legal-notices");
args.put("--libs", "libs");
args.put("--main-class", "main-class");
args.put("--man-pages", "man-pages");
args.put("--module-path", "module-path");
args.put("--module-version", "module-version");
args.put("--target-platform", "target-platform");
args.put("--warn-if-resolved", "deprecated");
args.put("@filename", null);
var options = new JmodOptions()
.classpath(args.get("--class-path"))
.cmds(args.get("--cmds"))
.compress(ZipCompression.ZIP_5)
.config(args.get("--config"))
.date(ZonedDateTime.of(1997, 8, 29, 2, 14, 0, 0, ZoneId.of("America/Los_Angeles")))
.dir(args.get("--dir"))
.doNotResolveByDefault(true)
.dryRun(true)
.exclude(new JmodOptions.FilePattern(JmodOptions.FilePatternType.GLOB, "glob"),
new JmodOptions.FilePattern(JmodOptions.FilePatternType.REGEX, "regex"))
.filename("filename")
.hashModules(args.get("--hash-modules"))
.headerFiles(args.get("--header-files"))
.legalNotices(args.get("--legal-notices"))
.libs(args.get("--libs"))
.mainClass(args.get("--main-class"))
.manPages(args.get("--man-pages"))
.modulePath(args.get("--module-path"))
.moduleVersion(args.get("--module-version"))
.targetPlatform(args.get("--target-platform"))
.warnIfResolved(JmodOptions.ResolvedReason.DEPRECATED);
assertEquals(options.size(), args.size(), "Wrong number of arguments");
for (var arg : args.entrySet()) {
assertTrue(options.containsKey(arg.getKey()), arg.getValue() + " not found");
assertEquals(arg.getValue(), options.get(arg.getKey()), arg.getKey());
}
}
@Test @Test
void testVersion() { void testVersion() {
var jmod = new JmodOperation().operationMode(JmodOperation.OperationMode.DESCRIBE).toolArg("--version"); var jmod = new JmodOperation()
.operationMode(JmodOperation.OperationMode.DESCRIBE)
.jmodFile("foo")
.addArgs("--version");
assertDoesNotThrow(jmod::execute); assertDoesNotThrow(jmod::execute);
} }
} }

View file

@ -10,6 +10,7 @@ import rife.bld.operations.exceptions.ExitStatusException;
import rife.tools.FileUtils; import rife.tools.FileUtils;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.HashMap;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@ -18,6 +19,7 @@ public class TestJpackageOperation {
void testCreatePackage() throws Exception { void testCreatePackage() throws Exception {
var tmpdir = Files.createTempDirectory("bld-jpackage-test").toFile(); var tmpdir = Files.createTempDirectory("bld-jpackage-test").toFile();
tmpdir.deleteOnExit(); tmpdir.deleteOnExit();
var options = new JpackageOptions() var options = new JpackageOptions()
.input("lib/bld") .input("lib/bld")
.name("bld") .name("bld")
@ -49,9 +51,146 @@ public class TestJpackageOperation {
assertThrows(ExitStatusException.class, jpackage::execute); assertThrows(ExitStatusException.class, jpackage::execute);
} }
@Test
void testOptions() {
var args = new HashMap<String, String>();
args.put("--about-url", "about-url");
args.put("--add-launcher", "name=path");
args.put("--add-modules", "modules-1,modules-2");
args.put("--app-content", "content-1,content-2");
args.put("--app-image", "app-image");
args.put("--app-version", "app-version");
args.put("--arguments", "argument1 argument2");
args.put("--copyright", "copyright");
args.put("--description", "description");
args.put("--dest", "dest");
args.put("--file-associations", "file-associations");
args.put("--icon", "icon");
args.put("--input", "input");
args.put("--install-dir", "install-dir");
args.put("--java-options", "java-options");
args.put("--jlink-options", "--strip-debug --add-modules module-1,module-2");
args.put("--launcher-as-service", null);
args.put("--license-file", "license-file");
args.put("--linux-app-category", "linux-app-category");
args.put("--linux-app-release", "linux-app-release");
args.put("--linux-deb-maintainer", "linux-deb-maintainer");
args.put("--linux-menu-group", "linux-menu-group");
args.put("--linux-package-deps", null);
args.put("--linux-package-name", "linux-package-name");
args.put("--linux-rpm-license-type", "linux-rpm-license-type");
args.put("--linux-shortcut", null);
args.put("--mac-app-category", "mac-app-category");
args.put("--mac-app-image-sign-identity", "mac-app-image-sign-identity");
args.put("--mac-app-store", null);
args.put("--mac-dmg-content", "mac-dmg-content");
args.put("--mac-entitlements", "mac-entitlements");
args.put("--mac-installer-sign-identity", "mac-installer-sign-identity");
args.put("--mac-package-identifier", "mac-package-identifier");
args.put("--mac-package-name", "mac-package-name");
args.put("--mac-package-signing-prefix", "mac-package-signing-prefix");
args.put("--mac-sign", null);
args.put("--mac-signing-key-user-name", "mac-signing-key-user-name");
args.put("--mac-signing-keychain", "mac-signing-keychain");
args.put("--main-class", "main-class");
args.put("--main-jar", "main-jar");
args.put("--module", "module");
args.put("--module-path", "module-path-1,module-path-2");
args.put("--name", "name");
args.put("--resource-dir", "resource-dir");
args.put("--runtime-image", "runtime-image");
args.put("--strip-debug", null);
args.put("--temp", "temp");
args.put("--type", "exe");
args.put("--vendor", "vendor");
args.put("--verbose", null);
args.put("--win-console", null);
args.put("--win-dir-chooser", null);
args.put("--win-help-url", "win-help-url");
args.put("--win-menu", null);
args.put("--win-menu-group", "win-menu-group");
args.put("--win-per-user-install", null);
args.put("--win-shortcut", null);
args.put("--win-shortcut-prompt", null);
args.put("--win-update-url", "win-update-url");
args.put("--win-upgrade-uuid", "win-upgrade-uuid");
args.put("@filename", null);
var options = new JpackageOptions()
.aboutUrl(args.get("--about-url"))
.addLauncher(new JpackageOptions.Launcher("name", "path"))
.addModules(args.get("--add-modules").split(","))
.appContent(args.get("--app-content").split(","))
.appImage(args.get("--app-image"))
.appVersion(args.get("--app-version"))
.arguments(args.get("--arguments").split(" "))
.copyright(args.get("--copyright"))
.description(args.get("--description"))
.dest(args.get("--dest"))
.fileAssociations(args.get("--file-associations").split(","))
.icon(args.get("--icon"))
.input(args.get("--input"))
.installDir(args.get("--install-dir"))
.javaOptions(args.get("--java-options").split(","))
.jlinkOptions(new JlinkOptions().stripDebug(true).addModules("module-1", "module-2"))
.launcherAsService(true)
.licenseFile(args.get("--license-file"))
.linuxAppCategory(args.get("--linux-app-category"))
.linuxAppRelease(args.get("--linux-app-release"))
.linuxDebMaintainer(args.get("--linux-deb-maintainer"))
.linuxMenuGroup(args.get("--linux-menu-group"))
.linuxPackageDeps(true)
.linuxPackageName(args.get("--linux-package-name"))
.linuxRpmLicenseType(args.get("--linux-rpm-license-type"))
.linuxShortcut(true)
.macAppCategory(args.get("--mac-app-category"))
.macAppImageSignIdentity(args.get("--mac-app-image-sign-identity"))
.macAppStore(true)
.macDmgContent(args.get("--mac-dmg-content"))
.macEntitlements(args.get("--mac-entitlements"))
.macInstallerSignIdentity(args.get("--mac-installer-sign-identity"))
.macPackageIdentifier(args.get("--mac-package-identifier"))
.macPackageName(args.get("--mac-package-name"))
.macPackageSigningPrefix(args.get("--mac-package-signing-prefix"))
.macSign(true)
.macSigningKeyUserName(args.get("--mac-signing-key-user-name"))
.macSigningKeychain(args.get("--mac-signing-keychain"))
.mainClass(args.get("--main-class"))
.mainJar(args.get("--main-jar"))
.module(args.get("--module"))
.modulePath(args.get("--module-path").split(","))
.name(args.get("--name"))
.resourceDir(args.get("--resource-dir"))
.runtimeImage(args.get("--runtime-image"))
.stripDebug(true)
.temp(args.get("--temp"))
.type(JpackageOptions.PackageType.EXE)
.vendor(args.get("--vendor"))
.verbose(true)
.winConsole(true)
.winDirChooser(true)
.winHelpUrl(args.get("--win-help-url"))
.winMenu(true)
.winMenuGroup(args.get("--win-menu-group"))
.winPerUserInstall(true)
.winShortcut(true)
.winShortcutPrompt(true)
.winUpdateUrl(args.get("--win-update-url"))
.winUpgradeUuid(args.get("--win-upgrade-uuid"))
.filename("filename");
assertEquals(options.size(), args.size(), "Wrong number of arguments");
for (var arg : args.entrySet()) {
assertTrue(options.containsKey(arg.getKey()), arg.getValue() + " not found");
assertEquals(arg.getValue(), options.get(arg.getKey()), arg.getKey());
}
}
@Test @Test
void testVersion() { void testVersion() {
var jpackage = new JpackageOperation().toolArg("--version"); var jpackage = new JpackageOperation().addArgs("--version");
assertDoesNotThrow(jpackage::execute); assertDoesNotThrow(jpackage::execute);
} }
} }