mirror of
https://github.com/rife2/bld
synced 2026-05-02 12:04:13 +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,11 +145,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies additional modules to be considered as required by a given module
|
||||
|
|
@ -180,11 +168,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Root modules to resolve in addition to the initial modules,
|
||||
|
|
@ -208,11 +193,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify character encoding used by source files
|
||||
|
|
@ -281,11 +263,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override location of endorsed standards path
|
||||
|
|
@ -307,11 +286,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override location of endorsed standards path
|
||||
|
|
@ -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,11 +336,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override location of installed extensions
|
||||
|
|
@ -382,11 +359,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override location of installed extensions
|
||||
|
|
@ -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,11 +526,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile only the specified module(s), check timestamps
|
||||
|
|
@ -574,11 +549,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* /**
|
||||
|
|
@ -601,11 +573,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find application modules
|
||||
|
|
@ -627,11 +596,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find application modules
|
||||
|
|
@ -653,11 +619,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find input source files for multiple modules
|
||||
|
|
@ -666,11 +629,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find input source files for multiple modules
|
||||
|
|
@ -679,11 +639,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find input source files for multiple modules
|
||||
|
|
@ -692,11 +649,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find input source files for multiple modules
|
||||
|
|
@ -802,11 +756,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a module path where to find annotation processors
|
||||
|
|
@ -854,11 +805,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a module path where to find annotation processors
|
||||
|
|
@ -867,11 +815,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a module path where to find annotation processors
|
||||
|
|
@ -880,11 +825,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
|
|
@ -932,11 +874,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
|
|
@ -945,11 +884,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
|
|
@ -958,11 +894,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the API used is available in the specified profile
|
||||
|
|
@ -1069,11 +1002,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override location of upgradeable modules
|
||||
|
|
@ -1082,11 +1012,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override location of upgradeable modules
|
||||
|
|
@ -1095,11 +1022,8 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminate compilation if warnings occur
|
||||
|
|
@ -1143,11 +1067,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLint(Collection<XLintKey> keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
return addXLintOption(keys, "");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning categories to disable
|
||||
|
|
|
|||
Loading…
Reference in a new issue