mirror of
https://github.com/rife2/bld
synced 2026-05-02 03:54:10 +02:00
Compare commits
1 commit
626ec1d17b
...
70a53417b9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70a53417b9 |
|
|
@ -11,7 +11,6 @@ import java.nio.file.Path;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
|
||||
|
|
@ -89,34 +88,26 @@ public class JavacOptions extends ArrayList<String> {
|
|||
return collection != null && !collection.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add delimited options
|
||||
*/
|
||||
private JavacOptions addDelimitedOption(String option, Collection<String> values, String separator) {
|
||||
if (isNotEmpty(values)) {
|
||||
var joined = values.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.joining(separator));
|
||||
if (!joined.isEmpty()) {
|
||||
add(option);
|
||||
add(joined);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add path-based options
|
||||
*/
|
||||
private JavacOptions addPathOption(String option, Collection<String> paths) {
|
||||
return addDelimitedOption(option, paths, File.pathSeparator);
|
||||
if (isNotEmpty(paths)) {
|
||||
add(option);
|
||||
add(String.join(File.pathSeparator, paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add comma-separated options
|
||||
*/
|
||||
private JavacOptions addCommaSeparatedOption(String option, Collection<String> values) {
|
||||
return addDelimitedOption(option, values, ",");
|
||||
if (isNotEmpty(values)) {
|
||||
add(option);
|
||||
add(String.join(",", values));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -154,10 +145,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addExports(Collection<String> modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
return addCommaSeparatedOption("--add-exports", modules);
|
||||
}
|
||||
return this;
|
||||
return addCommaSeparatedOption("--add-exports", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -180,10 +168,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addReads(Collection<String> modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
return addCommaSeparatedOption("--add-reads", modules);
|
||||
}
|
||||
return this;
|
||||
return addCommaSeparatedOption("--add-reads", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -208,10 +193,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions addModules(Collection<String> modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
return addCommaSeparatedOption("--add-modules", modules);
|
||||
}
|
||||
return this;
|
||||
return addCommaSeparatedOption("--add-modules", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -281,10 +263,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions endorsedDirs(Collection<File> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -307,10 +286,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsPaths(Collection<Path> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
return this;
|
||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -333,7 +309,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsStrings(Collection<String> dirs) {
|
||||
return addCommaSeparatedOption("-endorseddirs", dirs);
|
||||
if (isNotEmpty(dirs)) {
|
||||
add("-endorseddirs");
|
||||
add(String.join(",", dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -356,10 +336,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions extDirs(Collection<File> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -382,10 +359,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsPaths(Collection<Path> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
return this;
|
||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -408,7 +382,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsStrings(Collection<String> dirs) {
|
||||
return addCommaSeparatedOption("-extdirs", dirs);
|
||||
if (isNotEmpty(dirs)) {
|
||||
add("-extdirs");
|
||||
add(String.join(",", dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -548,10 +526,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions limitModules(Collection<String> modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
return addCommaSeparatedOption("--limit-modules", modules);
|
||||
}
|
||||
return this;
|
||||
return addCommaSeparatedOption("--limit-modules", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -574,10 +549,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions module(Collection<String> modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
return addCommaSeparatedOption("--module", modules);
|
||||
}
|
||||
return this;
|
||||
return addCommaSeparatedOption("--module", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -601,10 +573,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.6.2
|
||||
*/
|
||||
public JavacOptions modulePath(Collection<File> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -627,10 +596,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePathPaths(Collection<Path> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return modulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
return this;
|
||||
return modulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -653,10 +619,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePathStrings(Collection<String> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return addPathOption(COMPILE_OPTION_MODULE_PATH, paths);
|
||||
}
|
||||
return this;
|
||||
return addPathOption(COMPILE_OPTION_MODULE_PATH, paths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -666,10 +629,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePathStrings(Collection<String> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return addPathOption("--module-source-path", paths);
|
||||
}
|
||||
return this;
|
||||
return addPathOption("--module-source-path", paths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -679,10 +639,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePathPaths(Collection<Path> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return moduleSourcePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
return this;
|
||||
return moduleSourcePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -692,10 +649,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(Collection<File> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return moduleSourcePathStrings(paths.stream().map(File::getPath).toList());
|
||||
}
|
||||
return this;
|
||||
return moduleSourcePathStrings(paths.stream().map(File::getPath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -802,10 +756,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processors(Collection<String> classnames) {
|
||||
if (isNotEmpty(classnames)) {
|
||||
return addCommaSeparatedOption("-processor", classnames);
|
||||
}
|
||||
return this;
|
||||
return addCommaSeparatedOption("-processor", classnames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -854,10 +805,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorModulePathPaths(Collection<Path> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return processorModulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
return this;
|
||||
return processorModulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -867,10 +815,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorModulePathStrings(Collection<String> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return addPathOption("--processor-module-path", paths);
|
||||
}
|
||||
return this;
|
||||
return addPathOption("--processor-module-path", paths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -880,10 +825,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorModulePath(Collection<File> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return processorModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
return processorModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -932,10 +874,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorPathStrings(Collection<String> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return addPathOption("--processor-path", paths);
|
||||
}
|
||||
return this;
|
||||
return addPathOption("--processor-path", paths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -945,10 +884,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorPath(Collection<File> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return processorPathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
return processorPathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -958,10 +894,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorPathPaths(Collection<Path> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return processorPathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
return this;
|
||||
return processorPathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1069,10 +1002,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePathStrings(Collection<String> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return addPathOption("--upgrade-module-path", paths);
|
||||
}
|
||||
return this;
|
||||
return addPathOption("--upgrade-module-path", paths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1082,10 +1012,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(Collection<File> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return upgradeModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
return upgradeModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1095,10 +1022,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePathPaths(Collection<Path> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return upgradeModulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
return this;
|
||||
return upgradeModulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1143,10 +1067,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLint(Collection<XLintKey> keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
return addXLintOption(keys, "");
|
||||
}
|
||||
return this;
|
||||
return addXLintOption(keys, "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue