mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 00:07:12 -07:00
Merge pull request #48 from ethauvin/main
More cleanups to jlink, jmod & jpackage operations and options
This commit is contained in:
commit
d68905b944
8 changed files with 394 additions and 115 deletions
|
@ -6,11 +6,13 @@ package rife.bld.operations;
|
|||
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -67,25 +69,23 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
/**
|
||||
* Adds arguments to pass to the tool.
|
||||
*
|
||||
* @param arg one or more argument
|
||||
* @param args tbe list of arguments
|
||||
* @return this operation
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T toolArgs(String... arg) {
|
||||
toolArgs(List.of(arg));
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public T toolArgs(List<String> args) {
|
||||
toolArgs_.addAll(args);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds arguments to pass to the tool.
|
||||
*
|
||||
* @param args the argument to add
|
||||
* @param args one or more arguments
|
||||
* @return this operation
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "UnusedReturnValue"})
|
||||
public T toolArgs(List<String> args) {
|
||||
toolArgs_.addAll(args);
|
||||
return (T) this;
|
||||
public T toolArgs(String... args) {
|
||||
return toolArgs(List.of(args));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,6 +97,28 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
return toolArgs_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses arguments to pass to the tool from the given files.
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
* @throws FileNotFoundException if a file cannot be found
|
||||
*/
|
||||
public T toolArgsFromFile(String... files) throws IOException {
|
||||
return toolArgsFromFileStrings(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses arguments to pass to the tool from the given files.
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
* @throws FileNotFoundException if a file cannot be found
|
||||
*/
|
||||
public T toolArgsFromFile(Path... files) throws IOException {
|
||||
return toolArgsFromFilePaths(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses arguments to pass to the tool from the given files.
|
||||
*
|
||||
|
@ -104,8 +126,41 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
|
|||
* @return this operation instance
|
||||
* @throws FileNotFoundException if a file cannot be found
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "UnusedReturnValue"})
|
||||
public T toolArgsFromFile(List<String> files) throws IOException {
|
||||
public T toolArgsFromFile(List<File> files) throws IOException {
|
||||
return toolArgsFromFileStrings(files.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses arguments to pass to the tool from the given files.
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
* @throws FileNotFoundException if a file cannot be found
|
||||
*/
|
||||
public T toolArgsFromFile(File... files) throws IOException {
|
||||
return toolArgsFromFile(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses arguments to pass to the tool from the given files.
|
||||
*
|
||||
* @param files the list of files
|
||||
* @return this operation instance
|
||||
* @throws FileNotFoundException if a file cannot be found
|
||||
*/
|
||||
public T toolArgsFromFilePaths(List<Path> files) throws IOException {
|
||||
return toolArgsFromFileStrings(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses arguments to pass to the tool from the given files.
|
||||
*
|
||||
* @param files the list of files
|
||||
* @return this operation instance
|
||||
* @throws FileNotFoundException if a file cannot be found
|
||||
*/
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public T toolArgsFromFileStrings(List<String> files) throws IOException {
|
||||
var args = new ArrayList<String>();
|
||||
|
||||
for (var file : files) {
|
||||
|
|
|
@ -7,7 +7,6 @@ package rife.bld.operations;
|
|||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -29,33 +28,63 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
|
|||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JlinkOperation cmdFiles(String... file) {
|
||||
cmdFiles_.addAll(List.of(file));
|
||||
public JlinkOperation cmdFiles(String... files) {
|
||||
return cmdFilesStrings(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JlinkOperation cmdFiles(List<File> files) {
|
||||
cmdFiles_.addAll(files.stream().map(File::getAbsolutePath).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JlinkOperation cmdFiles(File... file) {
|
||||
cmdFiles_.addAll(Arrays.stream(file).map(File::getAbsolutePath).toList());
|
||||
public JlinkOperation cmdFiles(File... files) {
|
||||
return cmdFiles(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JlinkOperation cmdFiles(Path... files) {
|
||||
return cmdFilesPaths(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JlinkOperation cmdFilesPaths(List<Path> files) {
|
||||
cmdFiles_.addAll(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JlinkOperation cmdFiles(Path... file) {
|
||||
cmdFiles_.addAll(Arrays.stream(file).map(Path::toFile).map(File::getAbsolutePath).toList());
|
||||
public JlinkOperation cmdFilesStrings(List<String> files) {
|
||||
cmdFiles_.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -69,19 +98,29 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
|
|||
}
|
||||
|
||||
/**
|
||||
* Disable the plugin mentioned.
|
||||
* Disable the plugin(s) mentioned.
|
||||
*
|
||||
* @param plugin the plugin name
|
||||
* @param plugins the plugin name(s)
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOperation disablePlugin(String... plugin) {
|
||||
disabledPlugins_.addAll(List.of(plugin));
|
||||
public JlinkOperation disablePlugin(List<String> plugins) {
|
||||
disabledPlugins_.addAll(plugins);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the plugin(s) mentioned.
|
||||
*
|
||||
* @param plugins the plugin name(s)
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOperation disablePlugin(String... plugins) {
|
||||
return disablePlugin(List.of(plugins));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
toolArgsFromFile(cmdFiles_);
|
||||
toolArgsFromFileStrings(cmdFiles_);
|
||||
disabledPlugins_.forEach(plugin -> toolArgs("--disable-plugin", plugin));
|
||||
toolArgs(jlinkOptions_);
|
||||
super.execute();
|
||||
|
|
|
@ -7,7 +7,7 @@ package rife.bld.operations;
|
|||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public class JlinkOptions extends HashMap<String, String> {
|
||||
public class JlinkOptions extends LinkedHashMap<String, String> {
|
||||
/**
|
||||
* All Modules Path.
|
||||
*/
|
||||
|
@ -28,12 +28,24 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* Module can also be {@link #ALL_MODULE_PATH}
|
||||
*
|
||||
* @param modules one or more module
|
||||
* @param modules one or more modules
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOptions addModules(List<String> modules) {
|
||||
put("--add-modules", String.join(",", modules));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Root modules to resolve in addition to the initial modules.
|
||||
* <p>
|
||||
* Module can also be {@link #ALL_MODULE_PATH}
|
||||
*
|
||||
* @param modules one or more modules
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOptions addModules(String... modules) {
|
||||
put("--add-modules", String.join(",", modules));
|
||||
return this;
|
||||
return addModules(List.of(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,13 +153,22 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
/**
|
||||
* Limit the universe of observable modules.
|
||||
*
|
||||
* @param module one or more module
|
||||
* @param modules one or more modules
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOptions limitModule(String... module) {
|
||||
put("--limit-modules", String.join(",", module));
|
||||
public JlinkOptions limitModule(List<String> modules) {
|
||||
put("--limit-modules", String.join(",", modules));
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Limit the universe of observable modules.
|
||||
*
|
||||
* @param modules one or more modules
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOptions limitModule(String... modules) {
|
||||
return limitModule(List.of(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
* Module path.
|
||||
|
@ -304,14 +325,24 @@ public class JlinkOptions extends HashMap<String, String> {
|
|||
/**
|
||||
* Suggest providers that implement the given service types from the module path.
|
||||
*
|
||||
* @param name one or more provider name
|
||||
* @param names one or more provider names
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOptions suggestProviders(String... name) {
|
||||
put("--suggest-providers", String.join(",", name));
|
||||
public JlinkOptions suggestProviders(List<String> names) {
|
||||
put("--suggest-providers", String.join(",", names));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggest providers that implement the given service types from the module path.
|
||||
*
|
||||
* @param names one or more provider names
|
||||
* @return this map of options
|
||||
*/
|
||||
public JlinkOptions suggestProviders(String... names) {
|
||||
return suggestProviders(List.of(names));
|
||||
}
|
||||
|
||||
public List<String> toList() {
|
||||
var list = new ArrayList<String>();
|
||||
forEach((k, v) -> {
|
||||
|
|
|
@ -36,36 +36,57 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
|||
return cmdFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JmodOperation cmdFiles(String... file) {
|
||||
cmdFiles.addAll(List.of(file));
|
||||
public JmodOperation cmdFiles(String... files) {
|
||||
return cmdFilesStrings(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JmodOperation cmdFiles(File... files) {
|
||||
cmdFiles.addAll(Arrays.stream(files).map(File::getAbsolutePath).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JmodOperation cmdFiles(File... file) {
|
||||
cmdFiles.addAll(Arrays.stream(file).map(File::getAbsolutePath).toList());
|
||||
public JmodOperation cmdFiles(Path... files) {
|
||||
return cmdFilesPaths(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JmodOperation cmdFilesPaths(List<Path> files) {
|
||||
cmdFiles.addAll(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JmodOperation cmdFiles(Path... file) {
|
||||
cmdFiles.addAll(Arrays.stream(file).map(Path::toFile).map(File::getAbsolutePath).toList());
|
||||
public JmodOperation cmdFilesStrings(List<String> files) {
|
||||
cmdFiles.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -75,7 +96,7 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
|||
toolArgs(operationMode_.mode);
|
||||
}
|
||||
|
||||
toolArgsFromFile(cmdFiles);
|
||||
toolArgsFromFileStrings(cmdFiles);
|
||||
toolArgs(jmodOptions_);
|
||||
|
||||
if (jmodFile_ != null) {
|
||||
|
@ -129,8 +150,7 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
|
|||
* @return this operation instance
|
||||
*/
|
||||
public JmodOperation jmodFile(Path file) {
|
||||
jmodFile_ = file.toFile().getAbsolutePath();
|
||||
return this;
|
||||
return jmodFile(file.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,8 @@ import java.time.ZonedDateTime;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Options for jmod tool.
|
||||
|
@ -18,7 +19,7 @@ import java.util.HashMap;
|
|||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public class JmodOptions extends HashMap<String, String> {
|
||||
public class JmodOptions extends LinkedHashMap<String, String> {
|
||||
/**
|
||||
* Application jar files|dir containing classes.
|
||||
*
|
||||
|
@ -187,12 +188,12 @@ public class JmodOptions extends HashMap<String, String> {
|
|||
/**
|
||||
* Exclude files matching the supplied pattern list.
|
||||
*
|
||||
* @param pattern one or more pattern
|
||||
* @param patterns one or more patterns
|
||||
* @return the map of options
|
||||
*/
|
||||
public JmodOptions exclude(FilePattern... pattern) {
|
||||
public JmodOptions exclude(List<FilePattern> patterns) {
|
||||
var args = new ArrayList<String>();
|
||||
for (var p : pattern) {
|
||||
for (var p : patterns) {
|
||||
if (p.type == FilePatternType.GLOB) {
|
||||
args.add("glob:" + p.pattern);
|
||||
} else if (p.type == FilePatternType.REGEX) {
|
||||
|
@ -203,6 +204,16 @@ public class JmodOptions extends HashMap<String, String> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude files matching the supplied pattern list.
|
||||
*
|
||||
* @param patterns one or more patterns
|
||||
* @return the map of options
|
||||
*/
|
||||
public JmodOptions exclude(FilePattern... patterns) {
|
||||
return exclude(List.of(patterns));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -7,7 +7,6 @@ package rife.bld.operations;
|
|||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -34,44 +33,89 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
|
|||
* Additional alternative launchers can be built using this option, and this option can be used to build multiple
|
||||
* additional launchers.
|
||||
*
|
||||
* @param launcher one or more {@link JpackageOperation.Launcher}
|
||||
* @param launchers one or more {@link Launcher launchers}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation addLauncher(Launcher... launcher) {
|
||||
launchers_.addAll(Arrays.asList(launcher));
|
||||
public JpackageOperation addLauncher(List<Launcher> launchers) {
|
||||
launchers_.addAll(launchers);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of application launchers.
|
||||
* <p>
|
||||
* The main application launcher will be built from the command line options.
|
||||
* <p>
|
||||
* Additional alternative launchers can be built using this option, and this option can be used to build multiple
|
||||
* additional launchers.
|
||||
*
|
||||
* @param launchers one or more {@link Launcher launchers}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation addLauncher(Launcher... launchers) {
|
||||
return addLauncher(List.of(launchers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation cmdFiles(List<File> files) {
|
||||
cmdFiles_.addAll(files.stream().map(File::getAbsolutePath).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation cmdFiles(File... file) {
|
||||
cmdFiles_.addAll(Arrays.stream(file).map(File::getAbsolutePath).toList());
|
||||
public JpackageOperation cmdFiles(File... files) {
|
||||
return cmdFiles(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation cmdFiles(Path... files) {
|
||||
return cmdFilesPaths(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation cmdFiles(String... files) {
|
||||
return cmdFilesStrings(List.of(files));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation cmdFilesPaths(List<Path> files) {
|
||||
cmdFiles_.addAll(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation cmdFiles(Path... file) {
|
||||
cmdFiles_.addAll(Arrays.stream(file).map(Path::toFile).map(File::getAbsolutePath).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read options and/or mode from file(s).
|
||||
*
|
||||
* @param file one or more file
|
||||
* @return this operation instance
|
||||
*/
|
||||
public JpackageOperation cmdFiles(String... file) {
|
||||
cmdFiles_.addAll(List.of(file));
|
||||
public JpackageOperation cmdFilesStrings(List<String> files) {
|
||||
cmdFiles_.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -147,7 +191,7 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
|
|||
}
|
||||
|
||||
public Launcher(String name, Path path) {
|
||||
this(name, path.toFile().getAbsolutePath());
|
||||
this(name, path.toFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ package rife.bld.operations;
|
|||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -16,7 +15,7 @@ import java.util.List;
|
|||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public class JpackageOptions extends HashMap<String, String> {
|
||||
public class JpackageOptions extends LinkedHashMap<String, String> {
|
||||
/**
|
||||
* URL of the application's home page.
|
||||
*
|
||||
|
@ -36,11 +35,39 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* (if {@link #module(String, String) module} is specified), or the default set of modules (if
|
||||
* {@link #mainJar(String) mainJar} is specified) are used.
|
||||
*
|
||||
* @param modules one or more module
|
||||
* @param modules one or more modules
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions addModules(List<String> modules) {
|
||||
put("--add-modules", String.join(",", modules));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of modules to add.
|
||||
* <p>
|
||||
* This module list, along with the main module (if specified) will be passed to jlink as the
|
||||
* {@link JlinkOptions#addModules(String...) addModules} argument. If not specified, either just the main module
|
||||
* (if {@link #module(String, String) module} is specified), or the default set of modules (if
|
||||
* {@link #mainJar(String) mainJar} is specified) are used.
|
||||
*
|
||||
* @param modules one or more modules
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions addModules(String... modules) {
|
||||
put("--add-modules", String.join(",", modules));
|
||||
return addModules(List.of(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
* List of paths to files and/or directories to add to the application payload.
|
||||
* <p>
|
||||
* <b>Requires Java 20 or higher</b>.
|
||||
*
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions appContent(List<String> additionalContents) {
|
||||
put("--app-content", String.join(",", additionalContents));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -49,12 +76,11 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* <b>Requires Java 20 or higher</b>.
|
||||
*
|
||||
* @param additionalContent one or more path
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions appContent(String... additionalContent) {
|
||||
put("--app-content", String.join(",", additionalContent));
|
||||
return this;
|
||||
public JpackageOptions appContent(String... additionalContents) {
|
||||
return appContent(List.of(additionalContents));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,14 +129,24 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
/**
|
||||
* Command line arguments to pass to main class if no command line arguments are given to the launcher.
|
||||
*
|
||||
* @param argument one or more argument
|
||||
* @param arguments one or more arguments
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions arguments(String... argument) {
|
||||
put("--arguments", String.join(" ", argument));
|
||||
public JpackageOptions arguments(List<String> arguments) {
|
||||
put("--arguments", String.join(" ", arguments));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Command line arguments to pass to main class if no command line arguments are given to the launcher.
|
||||
*
|
||||
* @param arguments one or more arguments
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions arguments(String... arguments) {
|
||||
return arguments(List.of(arguments));
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright of the application.
|
||||
*
|
||||
|
@ -180,8 +216,9 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param paths absolute paths or relative to the current directory
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions fileAssociations(String... paths) {
|
||||
return fileAssociationsStrings(List.of(paths));
|
||||
public JpackageOptions fileAssociationsStrings(List<String> paths) {
|
||||
put("--file-associations", String.join(",", paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,9 +230,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param paths absolute paths or relative to the current directory
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions fileAssociationsStrings(List<String> paths) {
|
||||
put("--file-associations", String.join(",", paths));
|
||||
return this;
|
||||
public JpackageOptions fileAssociations(String... paths) {
|
||||
return fileAssociationsStrings(List.of(paths));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -234,8 +270,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param paths absolute paths or relative to the current directory
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions fileAssociations(Path... paths) {
|
||||
return fileAssociationsPaths(List.of(paths));
|
||||
public JpackageOptions fileAssociationsPaths(List<Path> paths) {
|
||||
return fileAssociations(paths.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,8 +283,8 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param paths absolute paths or relative to the current directory
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions fileAssociationsPaths(List<Path> paths) {
|
||||
return fileAssociations(paths.stream().map(Path::toFile).toList());
|
||||
public JpackageOptions fileAssociations(Path... paths) {
|
||||
return fileAssociationsPaths(List.of(paths));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,6 +352,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param path absolute path or relative to the current directory
|
||||
* @return this map of options
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public JpackageOptions input(Path path) {
|
||||
return input(path.toFile());
|
||||
}
|
||||
|
@ -358,11 +395,21 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* @param options the options
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions javaOptions(String... options) {
|
||||
public JpackageOptions javaOptions(List<String> options) {
|
||||
put("--java-options", String.join(" ", options));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to pass to the Java runtime.
|
||||
*
|
||||
* @param options the options
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions javaOptions(String... options) {
|
||||
return javaOptions(List.of(options));
|
||||
}
|
||||
|
||||
/**
|
||||
* List of options to pass to jlink.
|
||||
* <p>
|
||||
|
@ -572,35 +619,66 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
/**
|
||||
* Include all the referenced content in the dmg.
|
||||
*
|
||||
* @param additionalContent one or more path
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions macDmgContent(String... additionalContent) {
|
||||
put("--mac-dmg-content", String.join(",", additionalContent));
|
||||
return this;
|
||||
public JpackageOptions macDmgContent(String... additionalContents) {
|
||||
return macDmgContentStrings(List.of(additionalContents));
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all the referenced content in the dmg.
|
||||
*
|
||||
* @param additionalContent one or more path
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public JpackageOptions macDmgContent(File... additionalContent) {
|
||||
put("--mac-dmg-content", String.join(",", Arrays.stream(additionalContent).map(File::getAbsolutePath).toList()));
|
||||
public JpackageOptions macDmgContent(List<File> additionalContents) {
|
||||
put("--mac-dmg-content", String.join(",", additionalContents.stream().map(File::getAbsolutePath).toList()));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all the referenced content in the dmg.
|
||||
*
|
||||
* @param additionalContent one or more path
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions macDmgContent(Path... additionalContent) {
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public JpackageOptions macDmgContent(File... additionalContents) {
|
||||
return macDmgContent(List.of(additionalContents));
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all the referenced content in the dmg.
|
||||
*
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions macDmgContentPaths(List<Path> additionalContents) {
|
||||
put("--mac-dmg-content", String.join(",",
|
||||
Arrays.stream(additionalContent).map(Path::toFile).map(File::getAbsolutePath).toList()));
|
||||
additionalContents.stream().map(Path::toFile).map(File::getAbsolutePath).toList()));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all the referenced content in the dmg.
|
||||
*
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions macDmgContentPaths(Path... additionalContents) {
|
||||
return macDmgContentPaths(List.of(additionalContents));
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all the referenced content in the dmg.
|
||||
*
|
||||
* @param additionalContents one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions macDmgContentStrings(List<String> additionalContents) {
|
||||
put("--mac-dmg-content", String.join(",", additionalContents));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -815,7 +893,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* Each path is absolute or relative to the current directory.
|
||||
*
|
||||
* @param paths one or more path
|
||||
* @param paths one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions modulePath(String... paths) {
|
||||
|
@ -829,7 +907,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* Each path is absolute or relative to the current directory.
|
||||
*
|
||||
* @param paths one or more path
|
||||
* @param paths one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions modulePathStrings(List<String> paths) {
|
||||
|
@ -844,9 +922,10 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* Each path is absolute or relative to the current directory.
|
||||
*
|
||||
* @param paths one or more path
|
||||
* @param paths one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public JpackageOptions modulePath(File... paths) {
|
||||
return modulePath(List.of(paths));
|
||||
}
|
||||
|
@ -858,7 +937,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* Each path is absolute or relative to the current directory.
|
||||
*
|
||||
* @param paths one or more path
|
||||
* @param paths one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions modulePath(List<File> paths) {
|
||||
|
@ -872,7 +951,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* Each path is absolute or relative to the current directory.
|
||||
*
|
||||
* @param paths one or more path
|
||||
* @param paths one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions modulePath(Path... paths) {
|
||||
|
@ -886,7 +965,7 @@ public class JpackageOptions extends HashMap<String, String> {
|
|||
* <p>
|
||||
* Each path is absolute or relative to the current directory.
|
||||
*
|
||||
* @param paths one or more path
|
||||
* @param paths one or more paths
|
||||
* @return this map of options
|
||||
*/
|
||||
public JpackageOptions modulePathPaths(List<Path> paths) {
|
||||
|
|
|
@ -363,7 +363,7 @@ public class TestJpackageOperation {
|
|||
var barPath = Path.of("bar");
|
||||
var fooPath = Path.of("foo");
|
||||
|
||||
options = options.macDmgContent(barPath, fooPath);
|
||||
options = options.macDmgContentPaths(barPath, fooPath);
|
||||
assertEquals(barPath.toFile().getAbsolutePath() + ',' + fooPath.toFile().getAbsolutePath(),
|
||||
options.get("--mac-dmg-content"));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue