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

Made paths specifications absolute

This commit is contained in:
Erik C. Thauvin 2024-08-25 18:46:15 -07:00
parent 5821022fee
commit 0b9581cf12
Signed by: erik
GPG key ID: 776702A6A2DA330E
9 changed files with 217 additions and 165 deletions

View file

@ -26,7 +26,6 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
super("jlink"); super("jlink");
} }
/** /**
* Read options and/or mode from file(s). * Read options and/or mode from file(s).
* *
@ -56,7 +55,7 @@ public class JlinkOperation extends AbstractToolProviderOperation<JlinkOperation
* @return this operation instance * @return this operation instance
*/ */
public JlinkOperation cmdFiles(Path... file) { public JlinkOperation cmdFiles(Path... file) {
cmdFiles_.addAll(Arrays.stream(file).map(Path::toString).toList()); cmdFiles_.addAll(Arrays.stream(file).map(Path::toFile).map(File::getAbsolutePath).toList());
return this; return this;
} }

View file

@ -187,7 +187,7 @@ public class JlinkOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JlinkOptions modulePath(Path path) { public JlinkOptions modulePath(Path path) {
put("--module-path", path.toString()); put("--module-path", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -250,7 +250,7 @@ public class JlinkOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JlinkOptions output(Path path) { public JlinkOptions output(Path path) {
put("--output", path.toString()); put("--output", path.toFile().getAbsolutePath());
return this; return this;
} }

View file

@ -65,7 +65,7 @@ public class JmodOperation extends AbstractToolProviderOperation<JmodOperation>
* @return this operation instance * @return this operation instance
*/ */
public JmodOperation cmdFiles(Path... file) { public JmodOperation cmdFiles(Path... file) {
cmdFiles.addAll(Arrays.stream(file).map(Path::toString).toList()); cmdFiles.addAll(Arrays.stream(file).map(Path::toFile).map(File::getAbsolutePath).toList());
return this; return this;
} }
@ -129,7 +129,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) {
jmodFile_ = file.toString(); jmodFile_ = file.toFile().getAbsolutePath();
return this; return this;
} }

View file

@ -60,7 +60,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions cmds(Path path) { public JmodOptions cmds(Path path) {
put("--cmds", path.toString()); put("--cmds", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -112,7 +112,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions config(Path path) { public JmodOptions config(Path path) {
put("--config", path.toString()); put("--config", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -156,7 +156,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions dir(Path path) { public JmodOptions dir(Path path) {
put("--dir", path.toString()); put("--dir", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -252,7 +252,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions headerFiles(Path path) { public JmodOptions headerFiles(Path path) {
put("--header-files", path.toString()); put("--header-files", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -286,7 +286,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions legalNotices(Path path) { public JmodOptions legalNotices(Path path) {
put("--legal-notices", path.toString()); put("--legal-notices", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -320,7 +320,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions libs(Path path) { public JmodOptions libs(Path path) {
put("--libs", path.toString()); put("--libs", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -365,7 +365,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions manPages(Path path) { public JmodOptions manPages(Path path) {
put("--man-pages", path.toString()); put("--man-pages", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -398,7 +398,7 @@ public class JmodOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JmodOptions modulePath(Path path) { public JmodOptions modulePath(Path path) {
put("--module-path", path.toString()); put("--module-path", path.toFile().getAbsolutePath());
return this; return this;
} }

View file

@ -60,7 +60,7 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
* @return this operation instance * @return this operation instance
*/ */
public JpackageOperation cmdFiles(Path... file) { public JpackageOperation cmdFiles(Path... file) {
cmdFiles_.addAll(Arrays.stream(file).map(Path::toString).toList()); cmdFiles_.addAll(Arrays.stream(file).map(Path::toFile).map(File::getAbsolutePath).toList());
return this; return this;
} }
@ -147,7 +147,7 @@ public class JpackageOperation extends AbstractToolProviderOperation<JpackageOpe
} }
public Launcher(String name, Path path) { public Launcher(String name, Path path) {
this(name, path.toString()); this(name, path.toFile().getAbsolutePath());
} }
} }
} }

View file

@ -86,7 +86,7 @@ public class JpackageOptions extends HashMap<String, String> {
*/ */
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public JpackageOptions appImage(Path path) { public JpackageOptions appImage(Path path) {
put("--app-image", path.toString()); put("--app-image", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -170,7 +170,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions dest(Path path) { public JpackageOptions dest(Path path) {
put("--dest", path.toString()); put("--dest", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -213,7 +213,8 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions fileAssociations(Path... path) { public JpackageOptions fileAssociations(Path... path) {
put("--file-associations", String.join(",", Arrays.stream(path).map(Path::toString).toList())); put("--file-associations", String.join(",",
Arrays.stream(path).map(Path::toFile).map(File::getAbsolutePath).toList()));
return this; return this;
} }
@ -247,7 +248,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions icon(Path path) { public JpackageOptions icon(Path path) {
put("--icon", path.toString()); put("--icon", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -286,7 +287,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions input(Path path) { public JpackageOptions input(Path path) {
put("--input", path.toString()); put("--input", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -320,7 +321,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions installDir(Path path) { public JpackageOptions installDir(Path path) {
put("--install-dir", path.toString()); put("--install-dir", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -398,7 +399,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions licenseFile(Path path) { public JpackageOptions licenseFile(Path path) {
put("--license-file", path.toString()); put("--license-file", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -573,7 +574,8 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions macDmgContent(Path... additionalContent) { public JpackageOptions macDmgContent(Path... additionalContent) {
put("--mac-dmg-content", String.join(",", Arrays.stream(additionalContent).map(Path::toString).toList())); put("--mac-dmg-content", String.join(",",
Arrays.stream(additionalContent).map(Path::toFile).map(File::getAbsolutePath).toList()));
return this; return this;
} }
@ -607,7 +609,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions macEntitlements(Path path) { public JpackageOptions macEntitlements(Path path) {
put("--mac-entitlements", path.toString()); put("--mac-entitlements", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -824,7 +826,8 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions modulePath(Path... path) { public JpackageOptions modulePath(Path... path) {
put("--module-path", String.join(":", Arrays.stream(path).map(Path::toString).toList())); put("--module-path", String.join(":",
Arrays.stream(path).map(Path::toFile).map(File::getAbsolutePath).toList()));
return this; return this;
} }
@ -888,7 +891,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions resourceDir(Path path) { public JpackageOptions resourceDir(Path path) {
put("--resource-dir", path.toString()); put("--resource-dir", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -943,7 +946,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions runtimeImage(Path path) { public JpackageOptions runtimeImage(Path path) {
put("--runtime-image", path.toString()); put("--runtime-image", path.toFile().getAbsolutePath());
return this; return this;
} }
@ -1004,7 +1007,7 @@ public class JpackageOptions extends HashMap<String, String> {
* @return this map of options * @return this map of options
*/ */
public JpackageOptions temp(Path path) { public JpackageOptions temp(Path path) {
put("--temp", path.toString()); put("--temp", path.toFile().getAbsolutePath());
return this; return this;
} }

View file

@ -158,15 +158,16 @@ public class TestJlinkOperation {
@Test @Test
void testModulePath() { void testModulePath() {
var options = new JlinkOptions(); var options = new JlinkOptions();
options.modulePath("foo"); options.modulePath("foo");
assertEquals("foo", options.get("--module-path")); assertEquals("foo", options.get("--module-path"));
options.modulePath(Path.of("bar"));
assertEquals("bar", options.get("--module-path"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.modulePath(foo); options.modulePath(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--module-path")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--module-path"));
var fooFile = new File("foo");
options.modulePath(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--module-path"));
} }
@Test @Test
@ -180,15 +181,16 @@ public class TestJlinkOperation {
@Test @Test
void testOutput() { void testOutput() {
var options = new JlinkOptions(); var options = new JlinkOptions();
options.output("foo"); options.output("foo");
assertEquals("foo", options.get("--output")); assertEquals("foo", options.get("--output"));
options.output(Path.of("bar"));
assertEquals("bar", options.get("--output"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.output(foo); options.output(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--output")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--output"));
var fooFile = new File("foo");
options.output(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--output"));
} }
@Test @Test

View file

@ -121,24 +121,28 @@ public class TestJmodOperation {
void testCmds() { void testCmds() {
var options = new JmodOptions().cmds("foo"); var options = new JmodOptions().cmds("foo");
assertEquals("foo", options.get("--cmds")); assertEquals("foo", options.get("--cmds"));
options = options.cmds(Path.of("bar"));
assertEquals("bar", options.get("--cmds"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.cmds(foo); options = options.cmds(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--cmds")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--cmds"));
var fooFile = new File("foo");
options.cmds(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--cmds"));
} }
@Test @Test
void testConfig() { void testConfig() {
var options = new JmodOptions().config("foo"); var options = new JmodOptions().config("foo");
assertEquals("foo", options.get("--config")); assertEquals("foo", options.get("--config"));
options = options.config(Path.of("bar"));
assertEquals("bar", options.get("--config"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.config(foo); options = options.config(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--config")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--config"));
var fooFile = new File("foo");
options.config(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--config"));
} }
@Test @Test
@ -167,12 +171,14 @@ public class TestJmodOperation {
void testDir() { void testDir() {
var options = new JmodOptions().dir("foo"); var options = new JmodOptions().dir("foo");
assertEquals("foo", options.get("--dir")); assertEquals("foo", options.get("--dir"));
options = options.dir(Path.of("bar"));
assertEquals("bar", options.get("--dir"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.dir(foo); options = options.dir(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--dir")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--dir"));
var fooFile = new File("foo");
options.dir(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--dir"));
} }
@Test @Test
@ -215,12 +221,14 @@ public class TestJmodOperation {
void testHeaderFiles() { void testHeaderFiles() {
var options = new JmodOptions().headerFiles("foo"); var options = new JmodOptions().headerFiles("foo");
assertEquals("foo", options.get("--header-files")); assertEquals("foo", options.get("--header-files"));
options = options.headerFiles(Path.of("bar"));
assertEquals("bar", options.get("--header-files"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.headerFiles(foo); options = options.headerFiles(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--header-files")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--header-files"));
var fooFile = new File("foo");
options.headerFiles(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--header-files"));
} }
@Test @Test
@ -234,60 +242,70 @@ public class TestJmodOperation {
void testJmodFile() { void testJmodFile() {
var op = new JmodOperation().jmodFile("foo"); var op = new JmodOperation().jmodFile("foo");
assertEquals("foo", op.jmodFile()); assertEquals("foo", op.jmodFile());
op = op.jmodFile(Path.of("bar"));
assertEquals("bar", op.jmodFile());
var foo = new File("foo"); var barPath = Path.of("bar");
op.jmodFile(foo); op = op.jmodFile(barPath);
assertEquals(foo.getAbsolutePath(), op.jmodFile()); assertEquals(barPath.toFile().getAbsolutePath(), op.jmodFile());
var fooFile = new File("foo");
op.jmodFile(fooFile);
assertEquals(fooFile.getAbsolutePath(), op.jmodFile());
} }
@Test @Test
void testLegalNotices() { void testLegalNotices() {
var options = new JmodOptions().legalNotices("foo"); var options = new JmodOptions().legalNotices("foo");
assertEquals("foo", options.get("--legal-notices")); assertEquals("foo", options.get("--legal-notices"));
options = options.legalNotices(Path.of("bar"));
assertEquals("bar", options.get("--legal-notices"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.legalNotices(foo); options = options.legalNotices(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--legal-notices")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--legal-notices"));
var fooFile = new File("foo");
options.legalNotices(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--legal-notices"));
} }
@Test @Test
void testLibs() { void testLibs() {
var options = new JmodOptions().libs("foo"); var options = new JmodOptions().libs("foo");
assertEquals("foo", options.get("--libs")); assertEquals("foo", options.get("--libs"));
options = options.libs(Path.of("bar"));
assertEquals("bar", options.get("--libs"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.libs(foo); options = options.libs(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--libs")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--libs"));
var fooFile = new File("foo");
options.libs(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--libs"));
} }
@Test @Test
void testManPages() { void testManPages() {
var options = new JmodOptions().manPages("foo"); var options = new JmodOptions().manPages("foo");
assertEquals("foo", options.get("--man-pages")); assertEquals("foo", options.get("--man-pages"));
options = options.manPages(Path.of("bar"));
assertEquals("bar", options.get("--man-pages"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.manPages(foo); options = options.manPages(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--man-pages")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--man-pages"));
var fooFile = new File("foo");
options.manPages(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--man-pages"));
} }
@Test @Test
void testModulePath() { void testModulePath() {
var options = new JmodOptions().modulePath("foo"); var options = new JmodOptions().modulePath("foo");
assertEquals("foo", options.get("--module-path")); assertEquals("foo", options.get("--module-path"));
options = options.modulePath(Path.of("bar"));
assertEquals("bar", options.get("--module-path"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.modulePath(foo); options = options.modulePath(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--module-path")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--module-path"));
var fooFile = new File("foo");
options.modulePath(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--module-path"));
} }
@Test @Test

View file

@ -33,32 +33,35 @@ public class TestJpackageOperation {
void testAddLauncher() { void testAddLauncher() {
var op = new JpackageOperation(); var op = new JpackageOperation();
var foo = new Launcher("foo-name", "foo-path"); var fooLauncher = new Launcher("foo-name", "foo-path");
var bar = new Launcher("bar-name", Path.of("bar-path")); var barPath = Path.of("bar-path");
assertEquals(bar.name(), "bar-name"); var barLauncher = new Launcher("bar-name", barPath);
assertEquals(bar.path(), "bar-path"); assertEquals("bar-name", barLauncher.name());
assertEquals(barPath.toFile().getAbsolutePath(), barLauncher.path());
var f = new File("foo/bar"); var fooFile = new File("foo/bar");
var foobar = new Launcher("foobar", f); var foobarLauncher = new Launcher("foobar", fooFile);
assertEquals(foobar.name(), "foobar"); assertEquals("foobar", foobarLauncher.name());
assertEquals(foobar.path(), f.getAbsolutePath()); assertEquals(fooFile.getAbsolutePath(), foobarLauncher.path());
op = op.addLauncher(foo); op = op.addLauncher(fooLauncher);
assertTrue(op.launchers().contains(foo), "foo not found"); assertTrue(op.launchers().contains(fooLauncher), "foo not found");
op.addLauncher(bar); op.addLauncher(barLauncher);
assertTrue(op.launchers().contains(bar), "bar not found"); assertTrue(op.launchers().contains(barLauncher), "bar not found");
} }
@Test @Test
void testAppImage() { void testAppImage() {
var options = new JpackageOptions().appImage("foo"); var options = new JpackageOptions().appImage("foo");
assertEquals("foo", options.get("--app-image")); assertEquals("foo", options.get("--app-image"));
options.appImage(Path.of("bar"));
assertEquals("bar", options.get("--app-image"));
var foo = new File("foo"); var barPath = Path.of("bar");
options = options.appImage(foo); options.appImage(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--app-image")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--app-image"));
var fooFile = new File("foo");
options = options.appImage(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--app-image"));
} }
@Test @Test
@ -260,12 +263,14 @@ public class TestJpackageOperation {
void testDest() { void testDest() {
var options = new JpackageOptions().dest("foo"); var options = new JpackageOptions().dest("foo");
assertEquals("foo", options.get("--dest")); assertEquals("foo", options.get("--dest"));
options = options.dest(Path.of("bar"));
assertEquals("bar", options.get("--dest"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.dest(foo); options = options.dest(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--dest")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--dest"));
var fooFile = new File("foo");
options.dest(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--dest"));
} }
@Test @Test
@ -273,13 +278,16 @@ public class TestJpackageOperation {
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"));
options = options.fileAssociations(Path.of("bar"), Path.of("foo")); var barPath = Path.of("bar");
assertEquals("bar,foo", options.get("--file-associations")); var fooPath = Path.of("foo");
options = options.fileAssociations(barPath, fooPath);
assertEquals(barPath.toFile().getAbsolutePath() + ',' + fooPath.toFile().getAbsolutePath(),
options.get("--file-associations"));
var foo = new File("foo"); var fooFile = new File("foo");
var bar = new File("bar"); var barFile = new File("bar");
options.fileAssociations(foo, bar); options.fileAssociations(fooFile, barFile);
assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--file-associations")); assertEquals(fooFile.getAbsolutePath() + ',' + barFile.getAbsolutePath(), options.get("--file-associations"));
} }
@Test @Test
@ -293,12 +301,14 @@ public class TestJpackageOperation {
void testIcon() { void testIcon() {
var options = new JpackageOptions().icon("foo"); var options = new JpackageOptions().icon("foo");
assertEquals("foo", options.get("--icon")); assertEquals("foo", options.get("--icon"));
options = options.icon(Path.of("bar"));
assertEquals("bar", options.get("--icon"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.icon(foo); options = options.icon(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--icon")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--icon"));
var fooFile = new File("foo");
options.icon(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--icon"));
} }
@Test @Test
@ -307,36 +317,42 @@ public class TestJpackageOperation {
options.input("foo"); options.input("foo");
assertEquals("foo", options.get("--input")); assertEquals("foo", options.get("--input"));
options.input(Path.of("bar"));
assertEquals("bar", options.get("--input"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.input(foo); options.input(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--input")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--input"));
var fooFile = new File("foo");
options.input(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--input"));
} }
@Test @Test
void testInstallDir() { void testInstallDir() {
var options = new JpackageOptions().installDir("foo"); var options = new JpackageOptions().installDir("foo");
assertEquals("foo", options.get("--install-dir")); assertEquals("foo", options.get("--install-dir"));
options = options.installDir(Path.of("bar"));
assertEquals("bar", options.get("--install-dir"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.installDir(foo); options = options.installDir(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--install-dir")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--install-dir"));
var fooFile = new File("foo");
options.installDir(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--install-dir"));
} }
@Test @Test
void testLicenseFile() { void testLicenseFile() {
var options = new JpackageOptions().licenseFile("foo"); var options = new JpackageOptions().licenseFile("foo");
assertEquals("foo", options.get("--license-file")); assertEquals("foo", options.get("--license-file"));
options = options.licenseFile(Path.of("bar"));
assertEquals("bar", options.get("--license-file"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.licenseFile(foo); options = options.licenseFile(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--license-file")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--license-file"));
var fooFile = new File("foo");
options.licenseFile(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--license-file"));
} }
@Test @Test
@ -344,25 +360,31 @@ public class TestJpackageOperation {
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"));
options = options.macDmgContent(Path.of("bar"), Path.of("foo")); var barPath = Path.of("bar");
assertEquals("bar,foo", options.get("--mac-dmg-content")); var fooPath = Path.of("foo");
var foo = new File("foo"); options = options.macDmgContent(barPath, fooPath);
var bar = new File("bar"); assertEquals(barPath.toFile().getAbsolutePath() + ',' + fooPath.toFile().getAbsolutePath(),
options.macDmgContent(foo, bar); options.get("--mac-dmg-content"));
assertEquals(foo.getAbsolutePath() + ',' + bar.getAbsolutePath(), options.get("--mac-dmg-content"));
var fooFile = new File("foo");
var barFile = new File("bar");
options.macDmgContent(fooFile, barFile);
assertEquals(fooFile.getAbsolutePath() + ',' + barFile.getAbsolutePath(), options.get("--mac-dmg-content"));
} }
@Test @Test
void testMacEntitlements() { void testMacEntitlements() {
var options = new JpackageOptions().macEntitlements("foo"); var options = new JpackageOptions().macEntitlements("foo");
assertEquals("foo", options.get("--mac-entitlements")); assertEquals("foo", options.get("--mac-entitlements"));
options = options.macEntitlements(Path.of("bar"));
assertEquals("bar", options.get("--mac-entitlements"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.macEntitlements(foo); options = options.macEntitlements(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--mac-entitlements")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--mac-entitlements"));
var fooFile = new File("foo");
options.macEntitlements(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--mac-entitlements"));
} }
@Test @Test
@ -378,12 +400,14 @@ public class TestJpackageOperation {
void testModulePath() { void testModulePath() {
var options = new JpackageOptions().modulePath("foo"); var options = new JpackageOptions().modulePath("foo");
assertEquals("foo", options.get("--module-path")); assertEquals("foo", options.get("--module-path"));
options = options.modulePath(Path.of("bar"));
assertEquals("bar", options.get("--module-path"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.modulePath(foo); options = options.modulePath(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--module-path")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--module-path"));
var fooFile = new File("foo");
options.modulePath(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--module-path"));
} }
@Test @Test
@ -398,36 +422,42 @@ public class TestJpackageOperation {
void testResourceDir() { void testResourceDir() {
var options = new JpackageOptions().resourceDir("foo"); var options = new JpackageOptions().resourceDir("foo");
assertEquals("foo", options.get("--resource-dir")); assertEquals("foo", options.get("--resource-dir"));
options = options.resourceDir(Path.of("bar"));
assertEquals("bar", options.get("--resource-dir"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.resourceDir(foo); options = options.resourceDir(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--resource-dir")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--resource-dir"));
var fooFile = new File("foo");
options.resourceDir(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--resource-dir"));
} }
@Test @Test
void testRuntimeImage() { void testRuntimeImage() {
var options = new JpackageOptions().runtimeImage("foo"); var options = new JpackageOptions().runtimeImage("foo");
assertEquals("foo", options.get("--runtime-image")); assertEquals("foo", options.get("--runtime-image"));
options = options.runtimeImage(Path.of("bar"));
assertEquals("bar", options.get("--runtime-image"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.runtimeImage(foo); options = options.runtimeImage(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--runtime-image")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--runtime-image"));
var fooFile = new File("foo");
options.runtimeImage(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--runtime-image"));
} }
@Test @Test
void testTemp() { void testTemp() {
var options = new JpackageOptions().temp("foo"); var options = new JpackageOptions().temp("foo");
assertEquals("foo", options.get("--temp")); assertEquals("foo", options.get("--temp"));
options = options.temp(Path.of("bar"));
assertEquals("bar", options.get("--temp"));
var foo = new File("foo"); var barPath = Path.of("bar");
options.temp(foo); options = options.temp(barPath);
assertEquals(foo.getAbsolutePath(), options.get("--temp")); assertEquals(barPath.toFile().getAbsolutePath(), options.get("--temp"));
var fooFile = new File("foo");
options.temp(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--temp"));
} }
@Test @Test