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:
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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue