Skip to content

Commit

Permalink
More cleanups to jlink, jmod & jpackage operations, options and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Aug 29, 2024
1 parent c7ca0e2 commit 5da9e4b
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ public List<String> cmdFiles() {
* @param files one or more files
* @return this operation instance
*/
@SuppressWarnings({"unchecked"})
public T cmdFilesPaths(List<Path> files) {
cmdFiles_.addAll(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
return (T) this;
return cmdFilesStrings(files.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rife/bld/operations/JlinkOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public JlinkOptions modulePath(File path) {
* @return this map of options
*/
public JlinkOptions modulePath(Path path) {
return modulePath(path.toFile());
return modulePath(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -268,7 +268,7 @@ public JlinkOptions output(File path) {
* @return this map of options
*/
public JlinkOptions output(Path path) {
return output(path.toFile());
return output(path.toFile().getAbsolutePath());
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/rife/bld/operations/JmodOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ public JmodOperation jmodFile(String file) {
* @return this operation instance
*/
public JmodOperation jmodFile(File file) {
jmodFile_ = file.getAbsolutePath();
return this;
return jmodFile(file.getAbsolutePath());
}

/**
Expand All @@ -83,7 +82,7 @@ public JmodOperation jmodFile(File file) {
* @return this operation instance
*/
public JmodOperation jmodFile(Path file) {
return jmodFile(file.toFile());
return jmodFile(file.toFile().getAbsolutePath());
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/rife/bld/operations/JmodOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public JmodOptions cmds(File path) {
* @return this map of options
*/
public JmodOptions cmds(Path path) {
return cmds(path.toFile());
return cmds(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ public JmodOptions config(File path) {
* @return this map of options
*/
public JmodOptions config(Path path) {
return config(path.toFile());
return config(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ public JmodOptions dir(File path) {
* @return this map of options
*/
public JmodOptions dir(Path path) {
return dir(path.toFile());
return dir(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -256,7 +256,7 @@ public JmodOptions headerFiles(File path) {
* @return this map of options
*/
public JmodOptions headerFiles(Path path) {
return headerFiles(path.toFile());
return headerFiles(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -288,7 +288,7 @@ public JmodOptions legalNotices(File path) {
* @return this map of options
*/
public JmodOptions legalNotices(Path path) {
return legalNotices(path.toFile());
return legalNotices(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -320,7 +320,7 @@ public JmodOptions libs(File path) {
* @return this map of options
*/
public JmodOptions libs(Path path) {
return libs(path.toFile());
return libs(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -363,7 +363,7 @@ public JmodOptions manPages(File path) {
* @return this map of options
*/
public JmodOptions manPages(Path path) {
return manPages(path.toFile());
return manPages(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -394,7 +394,7 @@ public JmodOptions modulePath(File path) {
* @return this map of options
*/
public JmodOptions modulePath(Path path) {
return modulePath(path.toFile());
return modulePath(path.toFile().getAbsolutePath());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rife/bld/operations/JpackageOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public Launcher(String name, File path) {
}

public Launcher(String name, Path path) {
this(name, path.toFile());
this(name, path.toFile().getAbsolutePath());
}
}
}
31 changes: 14 additions & 17 deletions src/main/java/rife/bld/operations/JpackageOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public JpackageOptions appImage(File path) {
*/
@SuppressWarnings("UnusedReturnValue")
public JpackageOptions appImage(Path path) {
return appImage(path.toFile());
return appImage(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -204,7 +204,7 @@ public JpackageOptions dest(File path) {
* @return this map of options
*/
public JpackageOptions dest(Path path) {
return dest(path.toFile());
return dest(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -271,7 +271,7 @@ public JpackageOptions fileAssociations(List<File> paths) {
* @return this map of options
*/
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());
}

/**
Expand Down Expand Up @@ -316,7 +316,7 @@ public JpackageOptions icon(File path) {
* @return this map of options
*/
public JpackageOptions icon(Path path) {
return icon(path.toFile());
return icon(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -354,7 +354,7 @@ public JpackageOptions input(File path) {
*/
@SuppressWarnings("UnusedReturnValue")
public JpackageOptions input(Path path) {
return input(path.toFile());
return input(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -386,7 +386,7 @@ public JpackageOptions installDir(File path) {
* @return this map of options
*/
public JpackageOptions installDir(Path path) {
return installDir(path.toFile());
return installDir(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -472,7 +472,7 @@ public JpackageOptions licenseFile(File path) {
* @return this map of options
*/
public JpackageOptions licenseFile(Path path) {
return licenseFile(path.toFile());
return licenseFile(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -634,8 +634,7 @@ public JpackageOptions macDmgContent(String... additionalContents) {
*/
@SuppressWarnings("UnusedReturnValue")
public JpackageOptions macDmgContent(List<File> additionalContents) {
put("--mac-dmg-content", String.join(",", additionalContents.stream().map(File::getAbsolutePath).toList()));
return this;
return macDmgContentStrings(additionalContents.stream().map(File::getAbsolutePath).toList());
}

/**
Expand All @@ -656,9 +655,7 @@ public JpackageOptions macDmgContent(File... additionalContents) {
* @return this map of options
*/
public JpackageOptions macDmgContentPaths(List<Path> additionalContents) {
put("--mac-dmg-content", String.join(",",
additionalContents.stream().map(Path::toFile).map(File::getAbsolutePath).toList()));
return this;
return macDmgContentStrings(additionalContents.stream().map(Path::toFile).map(File::getAbsolutePath).toList());
}

/**
Expand Down Expand Up @@ -711,7 +708,7 @@ public JpackageOptions macEntitlements(File path) {
* @return this map of options
*/
public JpackageOptions macEntitlements(Path path) {
return macEntitlements(path.toFile());
return macEntitlements(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -969,7 +966,7 @@ public JpackageOptions modulePath(Path... paths) {
* @return this map of options
*/
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());
}

/**
Expand Down Expand Up @@ -1031,7 +1028,7 @@ public JpackageOptions resourceDir(File path) {
* @return this map of options
*/
public JpackageOptions resourceDir(Path path) {
return resourceDir(path.toFile());
return resourceDir(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -1084,7 +1081,7 @@ public JpackageOptions runtimeImage(File path) {
* @return this map of options
*/
public JpackageOptions runtimeImage(Path path) {
return runtimeImage(path.toFile());
return runtimeImage(path.toFile().getAbsolutePath());
}

/**
Expand Down Expand Up @@ -1143,7 +1140,7 @@ public JpackageOptions temp(File path) {
* @return this map of options
*/
public JpackageOptions temp(Path path) {
return temp(path.toFile());
return temp(path.toFile().getAbsolutePath());
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/rife/bld/operations/TestJlinkOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ void testModulePath() {
options.modulePath("foo");
assertEquals("foo", options.get("--module-path"));

var barPath = Path.of("bar");
options.modulePath(barPath);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--module-path"));
var bar = Path.of("bar");
options = options.modulePath(bar);
assertEquals(bar.toFile().getAbsolutePath(), options.get("--module-path"));

var fooFile = new File("foo");
options.modulePath(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--module-path"));
var foo = new File("foo");
options = options.modulePath(foo);
assertEquals(foo.getAbsolutePath(), options.get("--module-path"));
}

@Test
Expand All @@ -184,13 +184,13 @@ void testOutput() {
options.output("foo");
assertEquals("foo", options.get("--output"));

var barPath = Path.of("bar");
options.output(barPath);
assertEquals(barPath.toFile().getAbsolutePath(), options.get("--output"));
var bar = Path.of("bar");
options = options.output(bar);
assertEquals(bar.toFile().getAbsolutePath(), options.get("--output"));

var fooFile = new File("foo");
options.output(fooFile);
assertEquals(fooFile.getAbsolutePath(), options.get("--output"));
var foo = new File("foo");
options = options.output(foo);
assertEquals(foo.getAbsolutePath(), options.get("--output"));
}

@Test
Expand Down
Loading

0 comments on commit 5da9e4b

Please sign in to comment.