mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 00:07:12 -07:00
Cleaned up and improved tests
This commit is contained in:
parent
d69956cf91
commit
0ad964ea4d
10 changed files with 685 additions and 304 deletions
|
@ -9,7 +9,6 @@ import rife.bld.operations.exceptions.ExitStatusException;
|
|||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
@ -22,7 +21,7 @@ import java.util.spi.ToolProvider;
|
|||
*/
|
||||
public abstract class AbstractToolProviderOperation<T extends 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_;
|
||||
|
||||
/**
|
||||
|
@ -34,35 +33,6 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
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.
|
||||
*
|
||||
|
@ -70,8 +40,12 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
* @param value the value
|
||||
* @return this operation
|
||||
*/
|
||||
public T toolArg(String arg, String value) {
|
||||
toolArgs_.put(arg, value);
|
||||
@SuppressWarnings({"unchecked", "UnusedReturnValue"})
|
||||
public T addArg(String arg, String value) {
|
||||
toolArgs_.add(arg);
|
||||
if (value != null && !value.isEmpty()) {
|
||||
toolArgs_.add(value);
|
||||
}
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
@ -81,18 +55,33 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
* @param args the argument-value pairs to add
|
||||
* @return this operation
|
||||
*/
|
||||
protected T toolArgs(Map<String, String> args) {
|
||||
toolArgs_.putAll(args);
|
||||
@SuppressWarnings({"unchecked", "UnusedReturnValue"})
|
||||
protected T addArgs(Map<String, String> args) {
|
||||
args.forEach(this::addArg);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the tool command line arguments.
|
||||
* Adds tool command line arguments.
|
||||
*
|
||||
* @param args the argument to add
|
||||
* @return this operation
|
||||
*/
|
||||
protected T clearToolArguments() {
|
||||
toolArgs_.clear();
|
||||
@SuppressWarnings({"unchecked", "UnusedReturnValue"})
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -105,17 +94,15 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
var tool = ToolProvider.findFirst(toolName_).orElseThrow(() ->
|
||||
new IllegalStateException("No " + toolName_ + " tool found."));
|
||||
|
||||
var argsList = argsToList(toolArgs_);
|
||||
|
||||
var stderr = new StringWriter();
|
||||
var stdout = new StringWriter();
|
||||
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();
|
||||
err.flush();
|
||||
|
||||
if (status != 0) {
|
||||
System.out.println(tool.name() + " " + String.join(" ", argsList));
|
||||
System.out.println(tool.name() + ' ' + String.join(" ", toolArgs_));
|
||||
}
|
||||
|
||||
var output = stdout.toString();
|
||||
|
@ -136,7 +123,7 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
*
|
||||
* @return the arguments
|
||||
*/
|
||||
public Map<String, String> toolArgs() {
|
||||
public List<String> toolArgs() {
|
||||
return toolArgs_;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
package rife.bld.operations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -15,14 +17,26 @@ import java.util.Map;
|
|||
*/
|
||||
public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation> {
|
||||
private final JlinkOptions jlinkOptions_ = new JlinkOptions();
|
||||
private final List<String> disabledPlugins_ = new ArrayList<>();
|
||||
|
||||
public JlinkOperation() {
|
||||
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
|
||||
public void execute() throws Exception {
|
||||
toolArgs(jlinkOptions_);
|
||||
disabledPlugins_.forEach(plugin -> addArg("--disable-plugin", plugin));
|
||||
super.execute();
|
||||
}
|
||||
|
||||
|
@ -31,12 +45,22 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
|
|||
* <p>
|
||||
* 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() {
|
||||
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.
|
||||
* <p>
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
*/
|
||||
package rife.bld.operations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Options for jlink tool.
|
||||
|
@ -39,13 +41,24 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JlinkOptions bindServices(boolean bindServices) {
|
||||
if (bindServices) {
|
||||
put("--bind-services", null);
|
||||
put("--bind-services");
|
||||
} else {
|
||||
remove("--bind-services");
|
||||
}
|
||||
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.
|
||||
* <p>
|
||||
|
@ -61,16 +74,6 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
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.
|
||||
|
@ -85,17 +88,6 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
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.
|
||||
*
|
||||
|
@ -104,7 +96,7 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JlinkOptions ignoreSigningInformation(boolean ignoreSigningInformation) {
|
||||
if (ignoreSigningInformation) {
|
||||
put("--ignore-signing-information", null);
|
||||
put("--ignore-signing-information");
|
||||
} else {
|
||||
remove("--ignore-signing-information");
|
||||
}
|
||||
|
@ -123,6 +115,21 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
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.
|
||||
*
|
||||
|
@ -161,21 +168,6 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
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.
|
||||
*
|
||||
|
@ -184,13 +176,23 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JlinkOptions noManPages(boolean noManPages) {
|
||||
if (noManPages) {
|
||||
put("--no-man-pages", null);
|
||||
put("--no-man-pages");
|
||||
} else {
|
||||
remove("--no-man-pages");
|
||||
}
|
||||
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.
|
||||
*
|
||||
|
@ -221,7 +223,7 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JlinkOptions stripDebug(boolean stripDebug) {
|
||||
if (stripDebug) {
|
||||
put("--strip-debug", null);
|
||||
put("--strip-debug");
|
||||
} else {
|
||||
remove("--strip-debug");
|
||||
}
|
||||
|
@ -236,7 +238,7 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JlinkOptions stripNativeCommands(boolean stripNativeCommands) {
|
||||
if (stripNativeCommands) {
|
||||
put("--strip-native-commands", null);
|
||||
put("--strip-native-commands");
|
||||
} else {
|
||||
remove("--strip-native-commands");
|
||||
}
|
||||
|
@ -254,6 +256,17 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
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
|
||||
*
|
||||
|
@ -262,7 +275,7 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JlinkOptions verbose(boolean verbose) {
|
||||
if (verbose) {
|
||||
put("--verbose", null);
|
||||
put("--verbose");
|
||||
} else {
|
||||
remove("--verbose");
|
||||
}
|
||||
|
@ -281,4 +294,5 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
this.byteOrder = byteOrder;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class JmodOperation extends AbstractToolProviderOperation<JmodOperation> {
|
||||
private final JmodOptions jmodOptions_ = new JmodOptions();
|
||||
private String jmodFile_;
|
||||
private OperationMode operationMode_;
|
||||
|
||||
public JmodOperation() {
|
||||
|
@ -28,18 +29,44 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
|||
if (operationMode_ == null) {
|
||||
System.err.println("Operation mode not set.");
|
||||
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);
|
||||
toolArgs(jmodOptions_);
|
||||
addArgs(operationMode_.mode);
|
||||
addArgs(jmodOptions_);
|
||||
addArgs(jmodFile_);
|
||||
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.
|
||||
* <p>
|
||||
* 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() {
|
||||
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
|
||||
* @return this operation instance
|
||||
|
@ -73,10 +102,25 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
|||
* The operation modes.
|
||||
*/
|
||||
public enum OperationMode {
|
||||
/**
|
||||
* Creates a new JMOD archive file.
|
||||
*/
|
||||
CREATE("create"),
|
||||
/**
|
||||
* Prints the module details.
|
||||
*/
|
||||
DESCRIBE("describe"),
|
||||
/**
|
||||
* Extracts all the files from the JMOD archive file.
|
||||
*/
|
||||
EXTRACT("extract"),
|
||||
/**
|
||||
* Determines leaf modules and records the hashes of the dependencies that directly and indirectly require them.
|
||||
*/
|
||||
HASH("hash"),
|
||||
/**
|
||||
* Prints the names of all the entries.
|
||||
*/
|
||||
LIST("list");
|
||||
|
||||
final String mode;
|
||||
|
|
|
@ -94,7 +94,7 @@ public class JmodOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JmodOptions doNotResolveByDefault(boolean doNotResolveByDefault) {
|
||||
if (doNotResolveByDefault) {
|
||||
put("--do-not-resolve-by-default", null);
|
||||
put("--do-not-resolve-by-default");
|
||||
} else {
|
||||
remove("--do-not-resolve-by-default");
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class JmodOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JmodOptions dryRun(boolean dryRun) {
|
||||
if (dryRun) {
|
||||
put("--dry-run", null);
|
||||
put("--dry-run");
|
||||
} else {
|
||||
remove("--dry-run");
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class JmodOptions extends HashMap<String, String> {
|
|||
* Exclude files matching the supplied pattern list.
|
||||
*
|
||||
* @param pattern one or more pattern
|
||||
* @return the list of options
|
||||
* @return the map of options
|
||||
*/
|
||||
public JmodOptions exclude(FilePattern... pattern) {
|
||||
var args = new ArrayList<String>();
|
||||
|
@ -142,10 +142,20 @@ public class JmodOptions extends HashMap<String, String> {
|
|||
* @return this map of options
|
||||
*/
|
||||
public JmodOptions filename(String filename) {
|
||||
put("@" + filename, null);
|
||||
put("@" + filename);
|
||||
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
|
||||
* depending upon it directly or indirectly. The hashes are recorded in the JMOD file being created, or a JMOD file
|
||||
|
|
|
@ -22,7 +22,7 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
|
|||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
toolArgs(jpackageOptions_);
|
||||
addArgs(jpackageOptions_);
|
||||
super.execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,17 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
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.
|
||||
* <p>
|
||||
|
@ -68,17 +79,6 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
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.
|
||||
*
|
||||
|
@ -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
|
||||
*/
|
||||
public JpackageOptions filename(String filename) {
|
||||
put("@" + filename, null);
|
||||
public JpackageOptions javaOptions(String... options) {
|
||||
put("--java-options", String.join(" ", options));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -205,6 +205,22 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
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.
|
||||
* <p>
|
||||
|
@ -216,22 +232,21 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions jlinkOptions(JlinkOptions options) {
|
||||
put("--jlink-options", String.join(" ", AbstractToolProviderOperation.argsToList(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
|
||||
* application.
|
||||
* Required packages or capabilities for the 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
|
||||
*/
|
||||
public JpackageOptions launcherAsService(boolean launcherAsService) {
|
||||
if (launcherAsService) {
|
||||
put("--launcher-as-service", null);
|
||||
public JpackageOptions linuxPackageDeps(boolean packageDeps) {
|
||||
if (packageDeps) {
|
||||
put("--linux-package-deps");
|
||||
} else {
|
||||
remove("--launcher-as-service");
|
||||
remove("--linux-package-deps");
|
||||
}
|
||||
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
|
||||
* @return this list of operation
|
||||
* @param shortcut {@code true| to create a shortcut, {@code false} otherwise
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions linuxPackageDeps(String packageDeps) {
|
||||
put("--linux-package-deps", packageDeps);
|
||||
public JpackageOptions linuxShortcut(boolean shortcut) {
|
||||
if (shortcut) {
|
||||
put("--linux-shortcut");
|
||||
} else {
|
||||
remove("--linux-shortcut");
|
||||
}
|
||||
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
|
||||
*/
|
||||
public JpackageOptions linuxShortcut(boolean shortcut) {
|
||||
if (shortcut) {
|
||||
put("--linux-shortcut", null);
|
||||
public JpackageOptions macAppCategory(String appCategory) {
|
||||
put("--mac-app-category", appCategory);
|
||||
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 {
|
||||
remove("--linux-shortcut");
|
||||
remove("--mac-app-store");
|
||||
}
|
||||
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.
|
||||
* <p>
|
||||
|
@ -360,6 +535,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param jar the path relative to the input path
|
||||
* @return this map of options
|
||||
*/
|
||||
@SuppressWarnings("JavadocDeclaration")
|
||||
public JpackageOptions mainJar(String jar) {
|
||||
put("--main-jar", jar);
|
||||
return this;
|
||||
|
@ -368,14 +544,14 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
/**
|
||||
* The main module and main class of the application.
|
||||
* <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>
|
||||
* When this option is specified, the main module will be linked in the Java runtime image.
|
||||
* <p>
|
||||
* Either {@link #module(String, String) module} or {@link #mainJar(String) mainJar} option can be specified but not both.
|
||||
*
|
||||
* @param name the module name
|
||||
* @return this list of operation
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions module(String name) {
|
||||
put("--module", name);
|
||||
|
@ -385,7 +561,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
/**
|
||||
* The main module and main class of the application.
|
||||
* <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>
|
||||
* When this option is specified, the main module will be linked in the Java runtime image.
|
||||
* <p>
|
||||
|
@ -395,23 +571,20 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param mainClass the main class
|
||||
* @return this map of options
|
||||
*/
|
||||
@SuppressWarnings("JavadocDeclaration")
|
||||
public JpackageOptions module(String name, String mainClass) {
|
||||
put("--module-name", name + "/" + mainClass);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module path.
|
||||
* <p>
|
||||
* 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.
|
||||
* 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 path the module path
|
||||
* @return this map of options
|
||||
* @param key key with which the specified value is to be associated
|
||||
*/
|
||||
public JpackageOptions modulePath(String path) {
|
||||
put("--module-path", path);
|
||||
return this;
|
||||
public void put(String key) {
|
||||
put(key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -480,7 +653,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JpackageOptions stripDebug(boolean stripDebug) {
|
||||
if (stripDebug) {
|
||||
put("--strip-debug", null);
|
||||
put("--strip-debug");
|
||||
} else {
|
||||
remove("--strip-debug");
|
||||
}
|
||||
|
@ -524,126 +697,6 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
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.
|
||||
*
|
||||
|
@ -652,13 +705,29 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JpackageOptions verbose(boolean verbose) {
|
||||
if (verbose) {
|
||||
put("--verbose", null);
|
||||
put("--verbose");
|
||||
} else {
|
||||
remove("--verbose");
|
||||
}
|
||||
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..
|
||||
*
|
||||
|
@ -667,7 +736,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JpackageOptions winDirChooser(boolean winDirChooser) {
|
||||
if (winDirChooser) {
|
||||
put("--win-dir-chooser", null);
|
||||
put("--win-dir-chooser");
|
||||
} else {
|
||||
remove("--win-dir-chooser");
|
||||
}
|
||||
|
@ -693,7 +762,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JpackageOptions winMenu(boolean winMenu) {
|
||||
if (winMenu) {
|
||||
put("--win-menu", null);
|
||||
put("--win-menu");
|
||||
} else {
|
||||
remove("--win-menu");
|
||||
}
|
||||
|
@ -706,7 +775,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param menuGroup the menu group
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions winMenuGroupM(String menuGroup) {
|
||||
public JpackageOptions winMenuGroup(String menuGroup) {
|
||||
put("--win-menu-group", menuGroup);
|
||||
return this;
|
||||
}
|
||||
|
@ -719,7 +788,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JpackageOptions winPerUserInstall(boolean winPerUserInstall) {
|
||||
if (winPerUserInstall) {
|
||||
put("--win-per-user-install", null);
|
||||
put("--win-per-user-install");
|
||||
} else {
|
||||
remove("--win-per-user-install");
|
||||
}
|
||||
|
@ -734,7 +803,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JpackageOptions winShortcut(boolean winShortcut) {
|
||||
if (winShortcut) {
|
||||
put("--win-shortcut", null);
|
||||
put("--win-shortcut");
|
||||
} else {
|
||||
remove("--win-shortcut");
|
||||
}
|
||||
|
@ -749,7 +818,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
*/
|
||||
public JpackageOptions winShortcutPrompt(boolean shortcutPrompt) {
|
||||
if (shortcutPrompt) {
|
||||
put("--win-shortcut-prompt", null);
|
||||
put("--win-shortcut-prompt");
|
||||
} else {
|
||||
remove("--win-shortcut-prompt");
|
||||
}
|
||||
|
@ -778,33 +847,6 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -8,8 +8,10 @@ package rife.bld.operations;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestJlinkOperation {
|
||||
@Test
|
||||
|
@ -18,9 +20,67 @@ public class TestJlinkOperation {
|
|||
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
|
||||
void testVersion() {
|
||||
var jlink = new JlinkOperation().toolArg("--version");
|
||||
var jlink = new JlinkOperation().addArgs("--version");
|
||||
assertDoesNotThrow(jlink::execute);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,11 @@ package rife.bld.operations;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestJmodOperation {
|
||||
@Test
|
||||
|
@ -18,9 +21,67 @@ public class TestJmodOperation {
|
|||
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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import rife.bld.operations.exceptions.ExitStatusException;
|
|||
import rife.tools.FileUtils;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
@ -18,6 +19,7 @@ public class TestJpackageOperation {
|
|||
void testCreatePackage() throws Exception {
|
||||
var tmpdir = Files.createTempDirectory("bld-jpackage-test").toFile();
|
||||
tmpdir.deleteOnExit();
|
||||
|
||||
var options = new JpackageOptions()
|
||||
.input("lib/bld")
|
||||
.name("bld")
|
||||
|
@ -49,9 +51,146 @@ public class TestJpackageOperation {
|
|||
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
|
||||
void testVersion() {
|
||||
var jpackage = new JpackageOperation().toolArg("--version");
|
||||
var jpackage = new JpackageOperation().addArgs("--version");
|
||||
assertDoesNotThrow(jpackage::execute);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue