Compare commits

..

No commits in common. "7b542ac5d015b89d94a8408a2d228ec8186e974e" and "737927da26f21baf2af59e69945479de873371b7" have entirely different histories.

2 changed files with 135 additions and 2237 deletions

View file

@ -1,17 +1,18 @@
/* /*
* Copyright 2001-2026 Geert Bevin (gbevin[remove] at uwyn dot com) * Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
* Licensed under the Apache License, Version 2.0 (the "License") * Licensed under the Apache License, Version 2.0 (the "License")
*/ */
package rife.bld.operations; package rife.bld.operations;
import rife.tools.Convert; import rife.tools.Convert;
import rife.tools.FileUtils;
import rife.tools.StringUtils;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH; import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
@ -22,7 +23,6 @@ import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
* @author Geert Bevin (gbevin[remove] at uwyn dot com) * @author Geert Bevin (gbevin[remove] at uwyn dot com)
* @since 1.5.18 * @since 1.5.18
*/ */
@SuppressWarnings("UnusedReturnValue")
public class JavacOptions extends ArrayList<String> { public class JavacOptions extends ArrayList<String> {
public enum DebuggingInfo { public enum DebuggingInfo {
ALL, NONE, LINES, VAR, SOURCE ALL, NONE, LINES, VAR, SOURCE
@ -79,46 +79,6 @@ public class JavacOptions extends ArrayList<String> {
VARARGS VARARGS
} }
// Helper method to check if an array is not empty
private static <T> boolean isNotEmpty(T[] array) {
return array != null && array.length > 0;
}
// Helper method to check if a collection is not empty
private static boolean isNotEmpty(Collection<?> collection) {
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);
}
/**
* Helper method to add comma-separated options
*/
private JavacOptions addCommaSeparatedOption(String option, Collection<String> values) {
return addDelimitedOption(option, values, ",");
}
/** /**
* Option to pass to annotation processors * Option to pass to annotation processors
* *
@ -139,10 +99,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.3.1 * @since 2.3.1
*/ */
public JavacOptions addExports(String... modules) { public JavacOptions addExports(String... modules) {
if (isNotEmpty(modules)) { return addExports(Arrays.asList(modules));
addExports(Arrays.asList(modules));
}
return this;
} }
/** /**
@ -153,20 +110,9 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.3.1 * @since 2.3.1
*/ */
public JavacOptions addExports(Collection<String> modules) { public JavacOptions addExports(List<String> modules) {
return addCommaSeparatedOption("--add-exports", modules); add("--add-exports");
} add(StringUtils.join(modules, ","));
/**
* Specifies additional modules to be considered as required by a given module
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addReads(String... modules) {
if (isNotEmpty(modules)) {
addReads(Arrays.asList(modules));
}
return this; return this;
} }
@ -176,8 +122,20 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.3.1 * @since 2.3.1
*/ */
public JavacOptions addReads(Collection<String> modules) { public JavacOptions addReads(String... modules) {
return addCommaSeparatedOption("--add-reads", modules); return addReads(Arrays.asList(modules));
}
/**
* Specifies additional modules to be considered as required by a given module
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions addReads(List<String> modules) {
add("--add-reads");
add(StringUtils.join(modules, ","));
return this;
} }
/** /**
@ -188,10 +146,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions addModules(String... modules) { public JavacOptions addModules(String... modules) {
if (isNotEmpty(modules)) { return addModules(Arrays.asList(modules));
addModules(Arrays.asList(modules));
}
return this;
} }
/** /**
@ -201,8 +156,10 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions addModules(Collection<String> modules) { public JavacOptions addModules(List<String> modules) {
return addCommaSeparatedOption("--add-modules", modules); add("--add-modules");
add(StringUtils.join(modules, ","));
return this;
} }
/** /**
@ -259,10 +216,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions endorsedDirs(File... dirs) { public JavacOptions endorsedDirs(File... dirs) {
if (isNotEmpty(dirs)) { return endorsedDirs(Arrays.asList(dirs));
endorsedDirs(Arrays.asList(dirs));
}
return this;
} }
/** /**
@ -271,11 +225,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions endorsedDirs(Collection<File> dirs) { public JavacOptions endorsedDirs(List<File> dirs) {
if (isNotEmpty(dirs)) { return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
}
return this;
} }
/** /**
@ -285,10 +236,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions endorsedDirs(Path... dirs) { public JavacOptions endorsedDirs(Path... dirs) {
if (isNotEmpty(dirs)) { return endorsedDirsPaths(Arrays.asList(dirs));
endorsedDirsPaths(Arrays.asList(dirs));
}
return this;
} }
/** /**
@ -297,11 +245,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions endorsedDirsPaths(Collection<Path> dirs) { public JavacOptions endorsedDirsPaths(List<Path> dirs) {
if (isNotEmpty(dirs)) { return endorsedDirs(dirs.stream().map(Path::toFile).toList());
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
}
return this;
} }
/** /**
@ -311,10 +256,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions endorsedDirs(String... dirs) { public JavacOptions endorsedDirs(String... dirs) {
if (isNotEmpty(dirs)) { return endorsedDirsStrings(Arrays.asList(dirs));
endorsedDirsStrings(Arrays.asList(dirs));
}
return this;
} }
/** /**
@ -323,8 +265,10 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions endorsedDirsStrings(Collection<String> dirs) { public JavacOptions endorsedDirsStrings(List<String> dirs) {
return addCommaSeparatedOption("-endorseddirs", dirs); add("-endorseddirs");
add(String.join(",", dirs));
return this;
} }
/** /**
@ -334,10 +278,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions extDirs(File... dirs) { public JavacOptions extDirs(File... dirs) {
if (isNotEmpty(dirs)) { return extDirs(Arrays.asList(dirs));
extDirs(Arrays.asList(dirs));
}
return this;
} }
/** /**
@ -346,11 +287,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions extDirs(Collection<File> dirs) { public JavacOptions extDirs(List<File> dirs) {
if (isNotEmpty(dirs)) { return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
}
return this;
} }
/** /**
@ -360,10 +298,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions extDirs(Path... dirs) { public JavacOptions extDirs(Path... dirs) {
if (isNotEmpty(dirs)) { return extDirsPaths(Arrays.asList(dirs));
extDirsPaths(Arrays.asList(dirs));
}
return this;
} }
/** /**
@ -372,11 +307,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions extDirsPaths(Collection<Path> dirs) { public JavacOptions extDirsPaths(List<Path> dirs) {
if (isNotEmpty(dirs)) { return extDirs(dirs.stream().map(Path::toFile).toList());
return extDirs(dirs.stream().map(Path::toFile).toList());
}
return this;
} }
/** /**
@ -386,10 +318,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions extDirs(String... dirs) { public JavacOptions extDirs(String... dirs) {
if (isNotEmpty(dirs)) { return extDirsStrings(Arrays.asList(dirs));
extDirsStrings(Arrays.asList(dirs));
}
return this;
} }
/** /**
@ -398,8 +327,10 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions extDirsStrings(Collection<String> dirs) { public JavacOptions extDirsStrings(List<String> dirs) {
return addCommaSeparatedOption("-extdirs", dirs); add("-extdirs");
add(String.join(",", dirs));
return this;
} }
/** /**
@ -526,10 +457,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions limitModules(String... modules) { public JavacOptions limitModules(String... modules) {
if (isNotEmpty(modules)) { return limitModules(Arrays.asList(modules));
limitModules(Arrays.asList(modules));
}
return this;
} }
/** /**
@ -538,8 +466,10 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions limitModules(Collection<String> modules) { public JavacOptions limitModules(List<String> modules) {
return addCommaSeparatedOption("--limit-modules", modules); add("--limit-modules");
add(StringUtils.join(modules, ","));
return this;
} }
/** /**
@ -549,10 +479,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions module(String... modules) { public JavacOptions module(String... modules) {
if (isNotEmpty(modules)) { return module(Arrays.asList(modules));
module(Arrays.asList(modules));
}
return this;
} }
/** /**
@ -561,22 +488,20 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions module(Collection<String> modules) { public JavacOptions module(List<String> modules) {
return addCommaSeparatedOption("--module", modules); add("--module");
add(StringUtils.join(modules, ","));
return this;
} }
/** /**
* /**
* Specify where to find application modules * Specify where to find application modules
* *
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions modulePath(File... paths) { public JavacOptions modulePath(File... paths) {
if (isNotEmpty(paths)) { return modulePath(Arrays.asList(paths));
modulePath(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -585,11 +510,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.6.2 * @since 1.6.2
*/ */
public JavacOptions modulePath(Collection<File> paths) { public JavacOptions modulePath(List<File> paths) {
if (isNotEmpty(paths)) { return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
}
return this;
} }
/** /**
@ -599,10 +521,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions modulePath(Path... paths) { public JavacOptions modulePath(Path... paths) {
if (isNotEmpty(paths)) { return modulePathPaths(Arrays.asList(paths));
modulePathPaths(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -611,11 +530,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions modulePathPaths(Collection<Path> paths) { public JavacOptions modulePathPaths(List<Path> paths) {
if (isNotEmpty(paths)) { return modulePath(paths.stream().map(Path::toFile).toList());
return modulePathStrings(paths.stream().map(Path::toString).toList());
}
return this;
} }
/** /**
@ -625,10 +541,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions modulePath(String... paths) { public JavacOptions modulePath(String... paths) {
if (isNotEmpty(paths)) { return modulePathStrings(Arrays.asList(paths));
modulePathStrings(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -637,43 +550,9 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions modulePathStrings(Collection<String> paths) { public JavacOptions modulePathStrings(List<String> paths) {
return addPathOption(COMPILE_OPTION_MODULE_PATH, paths); add(COMPILE_OPTION_MODULE_PATH);
} add(FileUtils.joinPaths(paths));
/**
* Specify where to find input source files for multiple modules
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions moduleSourcePathStrings(Collection<String> paths) {
return addPathOption("--module-source-path", paths);
}
/**
* Specify where to find input source files for multiple modules
*
* @return this list of options
* @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
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions moduleSourcePath(Collection<File> paths) {
if (isNotEmpty(paths)) {
return moduleSourcePathStrings(paths.stream().map(File::getPath).toList());
}
return this; return this;
} }
@ -683,11 +562,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions moduleSourcePath(File... paths) { public JavacOptions moduleSourcePath(File path) {
if (isNotEmpty(paths)) { return moduleSourcePath(path.getAbsolutePath());
moduleSourcePath(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -696,11 +572,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions moduleSourcePath(String... paths) { public JavacOptions moduleSourcePath(Path path) {
if (isNotEmpty(paths)) { return moduleSourcePath(path.toFile());
moduleSourcePathStrings(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -709,10 +582,9 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions moduleSourcePath(Path... paths) { public JavacOptions moduleSourcePath(String path) {
if (isNotEmpty(paths)) { add("--module-source-path");
moduleSourcePathPaths(Arrays.asList(paths)); add(path);
}
return this; return this;
} }
@ -768,10 +640,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions processors(String... classnames) { public JavacOptions processors(String... classnames) {
if (isNotEmpty(classnames)) { return processors(Arrays.asList(classnames));
processors(Arrays.asList(classnames));
}
return this;
} }
/** /**
@ -780,8 +649,10 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions processors(Collection<String> classnames) { public JavacOptions processors(List<String> classnames) {
return addCommaSeparatedOption("-processor", classnames); add("-processor");
add(StringUtils.join(classnames, ","));
return this;
} }
/** /**
@ -790,11 +661,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions processorModulePath(File... paths) { public JavacOptions processorModulePath(File path) {
if (isNotEmpty(paths)) { return processorModulePath(path.getAbsolutePath());
processorModulePath(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -803,11 +671,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorModulePath(Path... paths) { public JavacOptions processorModulePath(Path path) {
if (isNotEmpty(paths)) { return processorModulePath(path.toFile());
processorModulePathPaths(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -816,46 +681,9 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorModulePath(String... paths) { public JavacOptions processorModulePath(String path) {
if (isNotEmpty(paths)) { add("--processor-module-path");
processorModulePathStrings(Arrays.asList(paths)); add(path);
}
return this;
}
/**
* Specify a module path where to find annotation processors
*
* @return this list of options
* @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
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions processorModulePathStrings(Collection<String> paths) {
return addPathOption("--processor-module-path", paths);
}
/**
* Specify a module path where to find annotation processors
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions processorModulePath(Collection<File> paths) {
if (isNotEmpty(paths)) {
return processorModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
}
return this; return this;
} }
@ -865,11 +693,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions processorPath(String... paths) { public JavacOptions processorPath(File path) {
if (isNotEmpty(paths)) { return processorPath(path.getAbsolutePath());
processorPathStrings(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -878,11 +703,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorPath(File... paths) { public JavacOptions processorPath(Path path) {
if (isNotEmpty(paths)) { return processorPath(path.toFile());
processorPath(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -891,51 +713,14 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorPath(Path... paths) { public JavacOptions processorPath(String path) {
if (isNotEmpty(paths)) { add("--processor-path");
processorPathPaths(Arrays.asList(paths)); add(path);
}
return this; return this;
} }
/** /**
* Specify where to find annotation processors * Check that API used is available in the specified profile
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions processorPathStrings(Collection<String> paths) {
return addPathOption("--processor-path", paths);
}
/**
* Specify where to find annotation processors
*
* @return this list of options
* @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
*
* @return this list of options
* @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
* *
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
@ -999,11 +784,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions upgradeModulePath(File... paths) { public JavacOptions upgradeModulePath(File path) {
if (isNotEmpty(paths)) { return upgradeModulePath(path.getAbsolutePath());
upgradeModulePath(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -1012,11 +794,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions upgradeModulePath(Path... paths) { public JavacOptions upgradeModulePath(Path path) {
if (isNotEmpty(paths)) { return upgradeModulePath(path.toFile());
upgradeModulePathPaths(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -1025,46 +804,9 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.1 * @since 2.1
*/ */
public JavacOptions upgradeModulePath(String... paths) { public JavacOptions upgradeModulePath(String path) {
if (isNotEmpty(paths)) { add("--upgrade-module-path");
upgradeModulePathStrings(Arrays.asList(paths)); add(path);
}
return this;
}
/**
* Override location of upgradeable modules
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions upgradeModulePathStrings(Collection<String> paths) {
return addPathOption("--upgrade-module-path", paths);
}
/**
* Override location of upgradeable modules
*
* @return this list of options
* @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
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions upgradeModulePathPaths(Collection<Path> paths) {
if (isNotEmpty(paths)) {
return upgradeModulePathStrings(paths.stream().map(Path::toString).toList());
}
return this; return this;
} }
@ -1097,10 +839,7 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.3.1 * @since 2.3.1
*/ */
public JavacOptions xLint(XLintKey... keys) { public JavacOptions xLint(XLintKey... keys) {
if (isNotEmpty(keys)) { return xLint(Arrays.asList(keys));
xLint(Arrays.asList(keys));
}
return this;
} }
/** /**
@ -1109,11 +848,8 @@ public class JavacOptions extends ArrayList<String> {
* @return this list of options * @return this list of options
* @since 2.3.1 * @since 2.3.1
*/ */
public JavacOptions xLint(Collection<XLintKey> keys) { public JavacOptions xLint(List<XLintKey> keys) {
if (isNotEmpty(keys)) { return addXLintOption(keys, "");
return addXLintOption(keys, "");
}
return this;
} }
/** /**
@ -1123,33 +859,30 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.3.1 * @since 2.3.1
*/ */
public JavacOptions xLintDisable(XLintKey... keys) { public JavacOptions xLintDisable(XLintKey... keys) {
if (isNotEmpty(keys)) { return xLintDisable(Arrays.asList(keys));
xLintDisable(Arrays.asList(keys));
}
return this;
} }
/** /**
* Warning categories to disable * Warning categories to disable
* *
* @return this list of options * @return this list of options
* @since 2.3.1 * @since 2.3.1
*/ */
public JavacOptions xLintDisable(Collection<XLintKey> keys) { public JavacOptions xLintDisable(List<XLintKey> keys) {
if (isNotEmpty(keys)) { return addXLintOption(keys, "-");
return addXLintOption(keys, "-"); }
private JavacOptions addXLintOption(List<XLintKey> keys, String prefix) {
if (keys == null || keys.isEmpty()) {
return this;
} }
var formattedKeys = keys.stream()
.map(key -> prefix + key.name().replace('_', '-').toLowerCase())
.collect(Collectors.joining(",", "-Xlint:", ""));
add(formattedKeys);
return this; return this;
} }
private JavacOptions addXLintOption(Collection<XLintKey> keys, String prefix) {
if (isNotEmpty(keys)) {
var keyString = keys.stream()
.map(key -> key.name().replace('_', '-').toLowerCase())
.collect(Collectors.joining("," + prefix, prefix, ""));
add("-Xlint:" + keyString);
}
return this;
}
} }

File diff suppressed because it is too large Load diff