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

Merge pull request #50 from ethauvin/main

More cleanups to jlink, jmod & jpackage operations, options and tests
This commit is contained in:
Geert Bevin 2024-08-29 07:33:28 -04:00 committed by GitHub
commit a07db3f94e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 216 additions and 195 deletions

View file

@ -97,10 +97,8 @@ public abstract class AbstractToolProviderOperation<T extends AbstractToolProvid
* @param files one or more files * @param files one or more files
* @return this operation instance * @return this operation instance
*/ */
@SuppressWarnings({"unchecked"})
public T cmdFilesPaths(List<Path> files) { public T cmdFilesPaths(List<Path> files) {
cmdFiles_.addAll(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList()); return cmdFilesStrings(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
return (T) this;
} }
/** /**

View file

@ -207,7 +207,7 @@ public class JlinkOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JlinkOptions modulePath(Path path) { public JlinkOptions modulePath(Path path) {
return modulePath(path.toFile()); return modulePath(path.toFile().getAbsolutePath());
} }
/** /**
@ -268,7 +268,7 @@ public class JlinkOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JlinkOptions output(Path path) { public JlinkOptions output(Path path) {
return output(path.toFile()); return output(path.toFile().getAbsolutePath());
} }
/** /**

View file

@ -70,8 +70,7 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
* @return this operation instance * @return this operation instance
*/ */
public JmodOperation jmodFile(File file) { public JmodOperation jmodFile(File file) {
jmodFile_ = file.getAbsolutePath(); return jmodFile(file.getAbsolutePath());
return this;
} }
/** /**
@ -83,7 +82,7 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
* @return this operation instance * @return this operation instance
*/ */
public JmodOperation jmodFile(Path file) { public JmodOperation jmodFile(Path file) {
return jmodFile(file.toFile()); return jmodFile(file.toFile().getAbsolutePath());
} }
/** /**

View file

@ -60,7 +60,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions cmds(Path path) { public JmodOptions cmds(Path path) {
return cmds(path.toFile()); return cmds(path.toFile().getAbsolutePath());
} }
/** /**
@ -110,7 +110,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions config(Path path) { public JmodOptions config(Path path) {
return config(path.toFile()); return config(path.toFile().getAbsolutePath());
} }
/** /**
@ -152,7 +152,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions dir(Path path) { public JmodOptions dir(Path path) {
return dir(path.toFile()); return dir(path.toFile().getAbsolutePath());
} }
/** /**
@ -256,7 +256,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions headerFiles(Path path) { public JmodOptions headerFiles(Path path) {
return headerFiles(path.toFile()); return headerFiles(path.toFile().getAbsolutePath());
} }
/** /**
@ -288,7 +288,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions legalNotices(Path path) { public JmodOptions legalNotices(Path path) {
return legalNotices(path.toFile()); return legalNotices(path.toFile().getAbsolutePath());
} }
/** /**
@ -320,7 +320,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions libs(Path path) { public JmodOptions libs(Path path) {
return libs(path.toFile()); return libs(path.toFile().getAbsolutePath());
} }
/** /**
@ -363,7 +363,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions manPages(Path path) { public JmodOptions manPages(Path path) {
return manPages(path.toFile()); return manPages(path.toFile().getAbsolutePath());
} }
/** /**
@ -394,7 +394,7 @@ public class JmodOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions modulePath(Path path) { public JmodOptions modulePath(Path path) {
return modulePath(path.toFile()); return modulePath(path.toFile().getAbsolutePath());
} }
/** /**

View file

@ -118,7 +118,7 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
} }
public Launcher(String name, Path path) { public Launcher(String name, Path path) {
this(name, path.toFile()); this(name, path.toFile().getAbsolutePath());
} }
} }
} }

View file

@ -112,7 +112,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
*/ */
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public JpackageOptions appImage(Path path) { public JpackageOptions appImage(Path path) {
return appImage(path.toFile()); return appImage(path.toFile().getAbsolutePath());
} }
/** /**
@ -204,7 +204,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions dest(Path path) { public JpackageOptions dest(Path path) {
return dest(path.toFile()); return dest(path.toFile().getAbsolutePath());
} }
/** /**
@ -271,7 +271,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions fileAssociationsPaths(List<Path> paths) { public JpackageOptions fileAssociationsPaths(List<Path> paths) {
return fileAssociations(paths.stream().map(Path::toFile).toList()); return fileAssociationsStrings(paths.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
} }
/** /**
@ -316,7 +316,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions icon(Path path) { public JpackageOptions icon(Path path) {
return icon(path.toFile()); return icon(path.toFile().getAbsolutePath());
} }
/** /**
@ -354,7 +354,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
*/ */
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public JpackageOptions input(Path path) { public JpackageOptions input(Path path) {
return input(path.toFile()); return input(path.toFile().getAbsolutePath());
} }
/** /**
@ -386,7 +386,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions installDir(Path path) { public JpackageOptions installDir(Path path) {
return installDir(path.toFile()); return installDir(path.toFile().getAbsolutePath());
} }
/** /**
@ -472,7 +472,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions licenseFile(Path path) { public JpackageOptions licenseFile(Path path) {
return licenseFile(path.toFile()); return licenseFile(path.toFile().getAbsolutePath());
} }
/** /**
@ -634,8 +634,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
*/ */
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public JpackageOptions macDmgContent(List<File> additionalContents) { public JpackageOptions macDmgContent(List<File> additionalContents) {
put("--mac-dmg-content", String.join(",", additionalContents.stream().map(File::getAbsolutePath).toList())); return macDmgContentStrings(additionalContents.stream().map(File::getAbsolutePath).toList());
return this;
} }
/** /**
@ -656,9 +655,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions macDmgContentPaths(List<Path> additionalContents) { public JpackageOptions macDmgContentPaths(List<Path> additionalContents) {
put("--mac-dmg-content", String.join(",", return macDmgContentStrings(additionalContents.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
additionalContents.stream().map(Path::toFile).map(File::getAbsolutePath).toList()));
return this;
} }
/** /**
@ -711,7 +708,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions macEntitlements(Path path) { public JpackageOptions macEntitlements(Path path) {
return macEntitlements(path.toFile()); return macEntitlements(path.toFile().getAbsolutePath());
} }
/** /**
@ -969,7 +966,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions modulePathPaths(List<Path> paths) { public JpackageOptions modulePathPaths(List<Path> paths) {
return modulePath(paths.stream().map(Path::toFile).toList()); return modulePathStrings(paths.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
} }
/** /**
@ -1031,7 +1028,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions resourceDir(Path path) { public JpackageOptions resourceDir(Path path) {
return resourceDir(path.toFile()); return resourceDir(path.toFile().getAbsolutePath());
} }
/** /**
@ -1084,7 +1081,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions runtimeImage(Path path) { public JpackageOptions runtimeImage(Path path) {
return runtimeImage(path.toFile()); return runtimeImage(path.toFile().getAbsolutePath());
} }
/** /**
@ -1143,7 +1140,7 @@ public class JpackageOptions extends LinkedHashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions temp(Path path) { public JpackageOptions temp(Path path) {
return temp(path.toFile()); return temp(path.toFile().getAbsolutePath());
} }
/** /**

View file

@ -161,13 +161,13 @@ public class TestJlinkOperation {
options.modulePath("foo"); options.modulePath("foo");
assertEquals("foo", options.get("--module-path")); assertEquals("foo", options.get("--module-path"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options.modulePath(barPath); options = options.modulePath(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--module-path")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--module-path"));
var fooFile = new File("foo"); var foo = new File("foo");
options.modulePath(fooFile); options = options.modulePath(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--module-path")); assertEquals(foo.getAbsolutePath(), options.get("--module-path"));
} }
@Test @Test
@ -184,13 +184,13 @@ public class TestJlinkOperation {
options.output("foo"); options.output("foo");
assertEquals("foo", options.get("--output")); assertEquals("foo", options.get("--output"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options.output(barPath); options = options.output(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--output")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--output"));
var fooFile = new File("foo"); var foo = new File("foo");
options.output(fooFile); options = options.output(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--output")); assertEquals(foo.getAbsolutePath(), options.get("--output"));
} }
@Test @Test

View file

@ -122,13 +122,13 @@ public class TestJmodOperation {
var options = new JmodOptions().cmds("foo"); var options = new JmodOptions().cmds("foo");
assertEquals("foo", options.get("--cmds")); assertEquals("foo", options.get("--cmds"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.cmds(barPath); options = options.cmds(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--cmds")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--cmds"));
var fooFile = new File("foo"); var foo = new File("foo");
options.cmds(fooFile); options.cmds(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--cmds")); assertEquals(foo.getAbsolutePath(), options.get("--cmds"));
} }
@Test @Test
@ -136,13 +136,13 @@ public class TestJmodOperation {
var options = new JmodOptions().config("foo"); var options = new JmodOptions().config("foo");
assertEquals("foo", options.get("--config")); assertEquals("foo", options.get("--config"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.config(barPath); options = options.config(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--config")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--config"));
var fooFile = new File("foo"); var foo = new File("foo");
options.config(fooFile); options = options.config(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--config")); assertEquals(foo.getAbsolutePath(), options.get("--config"));
} }
@Test @Test
@ -172,13 +172,13 @@ public class TestJmodOperation {
var options = new JmodOptions().dir("foo"); var options = new JmodOptions().dir("foo");
assertEquals("foo", options.get("--dir")); assertEquals("foo", options.get("--dir"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.dir(barPath); options = options.dir(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--dir")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--dir"));
var fooFile = new File("foo"); var foo = new File("foo");
options.dir(fooFile); options = options.dir(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--dir")); assertEquals(foo.getAbsolutePath(), options.get("--dir"));
} }
@Test @Test
@ -222,13 +222,13 @@ public class TestJmodOperation {
var options = new JmodOptions().headerFiles("foo"); var options = new JmodOptions().headerFiles("foo");
assertEquals("foo", options.get("--header-files")); assertEquals("foo", options.get("--header-files"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.headerFiles(barPath); options = options.headerFiles(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--header-files")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--header-files"));
var fooFile = new File("foo"); var foo = new File("foo");
options.headerFiles(fooFile); options.headerFiles(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--header-files")); assertEquals(foo.getAbsolutePath(), options.get("--header-files"));
} }
@Test @Test
@ -243,13 +243,13 @@ public class TestJmodOperation {
var op = new JmodOperation().jmodFile("foo"); var op = new JmodOperation().jmodFile("foo");
assertEquals("foo", op.jmodFile()); assertEquals("foo", op.jmodFile());
var barPath = Path.of("bar"); var bar = Path.of("bar");
op = op.jmodFile(barPath); op = op.jmodFile(bar);
assertEquals(barPath.toFile().getAbsolutePath(), op.jmodFile()); assertEquals(bar.toFile().getAbsolutePath(), op.jmodFile());
var fooFile = new File("foo"); var foo = new File("foo");
op.jmodFile(fooFile); op.jmodFile(foo);
assertEquals(fooFile.getAbsolutePath(), op.jmodFile()); assertEquals(foo.getAbsolutePath(), op.jmodFile());
} }
@Test @Test
@ -257,13 +257,13 @@ public class TestJmodOperation {
var options = new JmodOptions().legalNotices("foo"); var options = new JmodOptions().legalNotices("foo");
assertEquals("foo", options.get("--legal-notices")); assertEquals("foo", options.get("--legal-notices"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.legalNotices(barPath); options = options.legalNotices(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--legal-notices")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--legal-notices"));
var fooFile = new File("foo"); var foo = new File("foo");
options.legalNotices(fooFile); options.legalNotices(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--legal-notices")); assertEquals(foo.getAbsolutePath(), options.get("--legal-notices"));
} }
@Test @Test
@ -271,13 +271,13 @@ public class TestJmodOperation {
var options = new JmodOptions().libs("foo"); var options = new JmodOptions().libs("foo");
assertEquals("foo", options.get("--libs")); assertEquals("foo", options.get("--libs"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.libs(barPath); options = options.libs(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--libs")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--libs"));
var fooFile = new File("foo"); var foo = new File("foo");
options.libs(fooFile); options.libs(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--libs")); assertEquals(foo.getAbsolutePath(), options.get("--libs"));
} }
@Test @Test
@ -285,13 +285,13 @@ public class TestJmodOperation {
var options = new JmodOptions().manPages("foo"); var options = new JmodOptions().manPages("foo");
assertEquals("foo", options.get("--man-pages")); assertEquals("foo", options.get("--man-pages"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.manPages(barPath); options = options.manPages(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--man-pages")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--man-pages"));
var fooFile = new File("foo"); var foo = new File("foo");
options.manPages(fooFile); options.manPages(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--man-pages")); assertEquals(foo.getAbsolutePath(), options.get("--man-pages"));
} }
@Test @Test
@ -299,13 +299,13 @@ public class TestJmodOperation {
var options = new JmodOptions().modulePath("foo"); var options = new JmodOptions().modulePath("foo");
assertEquals("foo", options.get("--module-path")); assertEquals("foo", options.get("--module-path"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.modulePath(barPath); options = options.modulePath(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--module-path")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--module-path"));
var fooFile = new File("foo"); var foo = new File("foo");
options.modulePath(fooFile); options = options.modulePath(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--module-path")); assertEquals(foo.getAbsolutePath(), options.get("--module-path"));
} }
@Test @Test

View file

@ -15,6 +15,7 @@ import java.io.PrintStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static rife.bld.operations.JpackageOperation.Launcher; import static rife.bld.operations.JpackageOperation.Launcher;
@ -32,22 +33,29 @@ public class TestJpackageOperation {
@Test @Test
void testAddLauncher() { void testAddLauncher() {
var op = new JpackageOperation(); var op = new JpackageOperation();
var bar = Path.of("bar-path");
var foo = new File("foo/bar");
var fooLauncher = new Launcher("foo-name", "foo-path"); var fooLauncher = new Launcher("foo-name", "foo-path");
var barPath = Path.of("bar-path"); assertEquals("foo-name", fooLauncher.name());
var barLauncher = new Launcher("bar-name", barPath); assertEquals("foo-path", fooLauncher.path());
assertEquals("bar-name", barLauncher.name());
assertEquals(barPath.toFile().getAbsolutePath(), barLauncher.path());
var fooFile = new File("foo/bar"); var barLauncher = new Launcher("bar-name", bar);
var foobarLauncher = new Launcher("foobar", fooFile); assertEquals("bar-name", barLauncher.name());
assertEquals(bar.toFile().getAbsolutePath(), barLauncher.path());
var foobarLauncher = new Launcher("foobar", foo);
assertEquals("foobar", foobarLauncher.name()); assertEquals("foobar", foobarLauncher.name());
assertEquals(fooFile.getAbsolutePath(), foobarLauncher.path()); assertEquals(foo.getAbsolutePath(), foobarLauncher.path());
op = op.addLauncher(fooLauncher); op = op.addLauncher(fooLauncher);
assertTrue(op.launchers().contains(fooLauncher), "foo not found"); assertTrue(op.launchers().contains(fooLauncher), "foo launcher not found");
op.addLauncher(barLauncher); op.addLauncher(barLauncher);
assertTrue(op.launchers().contains(barLauncher), "bar not found"); assertTrue(op.launchers().contains(barLauncher), "bar launcher not found");
op.addLauncher(foobarLauncher);
assertTrue(op.launchers().contains(fooLauncher), "foobar launcher not found");
} }
@Test @Test
@ -55,13 +63,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().appImage("foo"); var options = new JpackageOptions().appImage("foo");
assertEquals("foo", options.get("--app-image")); assertEquals("foo", options.get("--app-image"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options.appImage(barPath); options.appImage(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--app-image")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--app-image"));
var fooFile = new File("foo"); var foo = new File("foo");
options = options.appImage(fooFile); options = options.appImage(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--app-image")); assertEquals(foo.getAbsolutePath(), options.get("--app-image"));
} }
@Test @Test
@ -264,30 +272,40 @@ public class TestJpackageOperation {
var options = new JpackageOptions().dest("foo"); var options = new JpackageOptions().dest("foo");
assertEquals("foo", options.get("--dest")); assertEquals("foo", options.get("--dest"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.dest(barPath); options = options.dest(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--dest")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--dest"));
var fooFile = new File("foo"); var foo = new File("foo");
options.dest(fooFile); options.dest(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--dest")); assertEquals(foo.getAbsolutePath(), options.get("--dest"));
} }
@Test @Test
void testFileAssociations() { void testFileAssociations() {
var options = new JpackageOptions().fileAssociations("foo", "bar"); var options = new JpackageOptions().fileAssociations("foo", "bar");
assertEquals("foo,bar", options.get("--file-associations")); assertEquals("foo,bar", options.get("--file-associations"), "String...");
var barPath = Path.of("bar"); var foo = new File("foo");
var fooPath = Path.of("foo"); var bar = new File("bar");
options = options.fileAssociations(barPath, fooPath); options = options.fileAssociations(foo.toPath(), bar.toPath());
assertEquals(barPath.toFile().getAbsolutePath() + ',' + fooPath.toFile().getAbsolutePath(), assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--file-associations"),
options.get("--file-associations")); "Path...");
var fooFile = new File("foo"); options.fileAssociations(foo, bar);
var barFile = new File("bar"); assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--file-associations"),
options.fileAssociations(fooFile, barFile); "File...");
assertEquals(fooFile.getAbsolutePath() + ',' + barFile.getAbsolutePath(), options.get("--file-associations"));
options.fileAssociations(List.of(foo, bar));
assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--file-associations"),
"List(File...)");
options.fileAssociationsPaths(List.of(foo.toPath(), bar.toPath()));
assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--file-associations"),
"List(Path...)");
options.fileAssociationsStrings(List.of("foo", "bar"));
assertEquals("foo,bar", options.get("--file-associations"), "List(String...)");
} }
@Test @Test
@ -302,13 +320,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().icon("foo"); var options = new JpackageOptions().icon("foo");
assertEquals("foo", options.get("--icon")); assertEquals("foo", options.get("--icon"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.icon(barPath); options = options.icon(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--icon")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--icon"));
var fooFile = new File("foo"); var foo = new File("foo");
options.icon(fooFile); options.icon(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--icon")); assertEquals(foo.getAbsolutePath(), options.get("--icon"));
} }
@Test @Test
@ -318,13 +336,13 @@ public class TestJpackageOperation {
options.input("foo"); options.input("foo");
assertEquals("foo", options.get("--input")); assertEquals("foo", options.get("--input"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options.input(barPath); options.input(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--input")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--input"));
var fooFile = new File("foo"); var foo = new File("foo");
options.input(fooFile); options = options.input(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--input")); assertEquals(foo.getAbsolutePath(), options.get("--input"));
} }
@Test @Test
@ -332,13 +350,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().installDir("foo"); var options = new JpackageOptions().installDir("foo");
assertEquals("foo", options.get("--install-dir")); assertEquals("foo", options.get("--install-dir"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.installDir(barPath); options = options.installDir(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--install-dir")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--install-dir"));
var fooFile = new File("foo"); var foo = new File("foo");
options.installDir(fooFile); options.installDir(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--install-dir")); assertEquals(foo.getAbsolutePath(), options.get("--install-dir"));
} }
@Test @Test
@ -346,31 +364,40 @@ public class TestJpackageOperation {
var options = new JpackageOptions().licenseFile("foo"); var options = new JpackageOptions().licenseFile("foo");
assertEquals("foo", options.get("--license-file")); assertEquals("foo", options.get("--license-file"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.licenseFile(barPath); options = options.licenseFile(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--license-file")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--license-file"));
var fooFile = new File("foo"); var foo = new File("foo");
options.licenseFile(fooFile); options.licenseFile(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--license-file")); assertEquals(foo.getAbsolutePath(), options.get("--license-file"));
} }
@Test @Test
void testMacDmgContent() { void testMacDmgContent() {
var options = new JpackageOptions().macDmgContent("foo", "bar"); var options = new JpackageOptions().macDmgContent("foo", "bar");
assertEquals("foo,bar", options.get("--mac-dmg-content")); assertEquals("foo,bar", options.get("--mac-dmg-content"), "String...");
var barPath = Path.of("bar"); var foo = new File("foo");
var fooPath = Path.of("foo"); var bar = new File("bar");
options.macDmgContent(foo, bar);
assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--mac-dmg-content"),
"File...");
options = options.macDmgContent(barPath, fooPath); options = options.macDmgContent(foo.toPath(), bar.toPath());
assertEquals(barPath.toFile().getAbsolutePath() + ',' + fooPath.toFile().getAbsolutePath(), assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--mac-dmg-content"),
options.get("--mac-dmg-content")); "Path...");
var fooFile = new File("foo"); options.macDmgContent(List.of(foo, bar));
var barFile = new File("bar"); assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--mac-dmg-content"),
options.macDmgContent(fooFile, barFile); "List(File...)");
assertEquals(fooFile.getAbsolutePath() + ',' + barFile.getAbsolutePath(), options.get("--mac-dmg-content"));
options.macDmgContentPaths(List.of(foo.toPath(), bar.toPath()));
assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--mac-dmg-content"),
"List(Path...)");
options.macDmgContentStrings(List.of("foo", "bar"));
assertEquals("foo,bar", options.get("--mac-dmg-content"), "List(String...)");
} }
@Test @Test
@ -378,13 +405,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().macEntitlements("foo"); var options = new JpackageOptions().macEntitlements("foo");
assertEquals("foo", options.get("--mac-entitlements")); assertEquals("foo", options.get("--mac-entitlements"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.macEntitlements(barPath); options = options.macEntitlements(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--mac-entitlements")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--mac-entitlements"));
var fooFile = new File("foo"); var foo = new File("foo");
options.macEntitlements(fooFile); options.macEntitlements(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--mac-entitlements")); assertEquals(foo.getAbsolutePath(), options.get("--mac-entitlements"));
} }
@Test @Test
@ -401,13 +428,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().modulePath("foo"); var options = new JpackageOptions().modulePath("foo");
assertEquals("foo", options.get("--module-path")); assertEquals("foo", options.get("--module-path"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.modulePath(barPath); options = options.modulePath(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--module-path")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--module-path"));
var fooFile = new File("foo"); var foo = new File("foo");
options.modulePath(fooFile); options.modulePath(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--module-path")); assertEquals(foo.getAbsolutePath(), options.get("--module-path"));
} }
@Test @Test
@ -423,13 +450,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().resourceDir("foo"); var options = new JpackageOptions().resourceDir("foo");
assertEquals("foo", options.get("--resource-dir")); assertEquals("foo", options.get("--resource-dir"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.resourceDir(barPath); options = options.resourceDir(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--resource-dir")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--resource-dir"));
var fooFile = new File("foo"); var foo = new File("foo");
options.resourceDir(fooFile); options.resourceDir(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--resource-dir")); assertEquals(foo.getAbsolutePath(), options.get("--resource-dir"));
} }
@Test @Test
@ -437,13 +464,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().runtimeImage("foo"); var options = new JpackageOptions().runtimeImage("foo");
assertEquals("foo", options.get("--runtime-image")); assertEquals("foo", options.get("--runtime-image"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.runtimeImage(barPath); options = options.runtimeImage(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--runtime-image")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--runtime-image"));
var fooFile = new File("foo"); var foo = new File("foo");
options.runtimeImage(fooFile); options.runtimeImage(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--runtime-image")); assertEquals(foo.getAbsolutePath(), options.get("--runtime-image"));
} }
@Test @Test
@ -451,13 +478,13 @@ public class TestJpackageOperation {
var options = new JpackageOptions().temp("foo"); var options = new JpackageOptions().temp("foo");
assertEquals("foo", options.get("--temp")); assertEquals("foo", options.get("--temp"));
var barPath = Path.of("bar"); var bar = Path.of("bar");
options = options.temp(barPath); options = options.temp(bar);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--temp")); assertEquals(bar.toFile().getAbsolutePath(), options.get("--temp"));
var fooFile = new File("foo"); var foo = new File("foo");
options.temp(fooFile); options.temp(foo);
assertEquals(fooFile.getAbsolutePath(), options.get("--temp")); assertEquals(foo.getAbsolutePath(), options.get("--temp"));
} }
@Test @Test