Compare commits

..

No commits in common. "3160161299c3b7158f5461973c5750c9fe35bc0f" and "25c77ed5dfa5f11fe3b7046abfe58342635a28c9" have entirely different histories.

2 changed files with 418 additions and 2019 deletions

View file

@ -1,16 +1,19 @@
/* /*
* 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.Collection;
import java.util.List;
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;
@ -21,7 +24,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
@ -78,38 +80,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 path-based options
*/
private JavacOptions addPathOption(String option, Collection<String> paths) {
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) {
if (isNotEmpty(values)) {
add(option);
add(String.join(",", values));
}
return this;
}
/** /**
* Option to pass to annotation processors * Option to pass to annotation processors
* *
@ -130,10 +100,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;
} }
/** /**
@ -144,20 +111,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;
} }
@ -167,8 +123,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;
} }
/** /**
@ -179,10 +147,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;
} }
/** /**
@ -192,8 +157,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;
} }
/** /**
@ -250,10 +217,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;
} }
/** /**
@ -262,7 +226,7 @@ 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) {
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList()); return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
} }
@ -273,10 +237,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;
} }
/** /**
@ -285,7 +246,7 @@ 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) {
return endorsedDirs(dirs.stream().map(Path::toFile).toList()); return endorsedDirs(dirs.stream().map(Path::toFile).toList());
} }
@ -296,10 +257,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;
} }
/** /**
@ -308,11 +266,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 endorsedDirsStrings(Collection<String> dirs) { public JavacOptions endorsedDirsStrings(List<String> dirs) {
if (isNotEmpty(dirs)) {
add("-endorseddirs"); add("-endorseddirs");
add(String.join(",", dirs)); add(String.join(",", dirs));
}
return this; return this;
} }
@ -323,10 +279,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;
} }
/** /**
@ -335,7 +288,7 @@ 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) {
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList()); return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
} }
@ -346,10 +299,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;
} }
/** /**
@ -358,7 +308,7 @@ 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) {
return extDirs(dirs.stream().map(Path::toFile).toList()); return extDirs(dirs.stream().map(Path::toFile).toList());
} }
@ -369,10 +319,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;
} }
/** /**
@ -381,11 +328,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 extDirsStrings(Collection<String> dirs) { public JavacOptions extDirsStrings(List<String> dirs) {
if (isNotEmpty(dirs)) {
add("-extdirs"); add("-extdirs");
add(String.join(",", dirs)); add(String.join(",", dirs));
}
return this; return this;
} }
@ -513,10 +458,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;
} }
/** /**
@ -525,8 +467,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;
} }
/** /**
@ -536,10 +480,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;
} }
/** /**
@ -548,22 +489,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;
} }
/** /**
@ -572,7 +511,7 @@ 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) {
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList()); return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
} }
@ -583,10 +522,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;
} }
/** /**
@ -595,8 +531,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) {
return modulePathStrings(paths.stream().map(Path::toString).toList()); return modulePath(paths.stream().map(Path::toFile).toList());
} }
/** /**
@ -606,10 +542,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;
} }
/** /**
@ -618,38 +551,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 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));
return this;
/**
* 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) {
return moduleSourcePathStrings(paths.stream().map(Path::toString).toList());
}
/**
* 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) {
return moduleSourcePathStrings(paths.stream().map(File::getPath).toList());
} }
/** /**
@ -659,23 +564,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions moduleSourcePath(File... paths) { public JavacOptions moduleSourcePath(File... paths) {
if (isNotEmpty(paths)) { return moduleSourcePath(Arrays.stream(paths)
moduleSourcePath(Arrays.asList(paths)); .map(File::getAbsolutePath)
} .toArray(String[]::new));
return this;
}
/**
* Specify where to find input source files for multiple modules
*
* @return this list of options
* @since 2.1
*/
public JavacOptions moduleSourcePath(String... paths) {
if (isNotEmpty(paths)) {
moduleSourcePathStrings(Arrays.asList(paths));
}
return this;
} }
/** /**
@ -685,12 +576,33 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions moduleSourcePath(Path... paths) { public JavacOptions moduleSourcePath(Path... paths) {
if (isNotEmpty(paths)) { return moduleSourcePath(Arrays.stream(paths)
moduleSourcePathPaths(Arrays.asList(paths)); .map(Path::toString)
.toArray(String[]::new));
} }
/**
* Specify where to find input source files for multiple modules
*
* @return this list of options
* @since 2.1
*/
public JavacOptions moduleSourcePath(String... paths) {
add("--module-source-path");
add(String.join(File.pathSeparator, paths));
return this; 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<String> paths) {
return moduleSourcePath(paths.toArray(new String[0]));
}
/** /**
* Specify version of modules that are being compiled * Specify version of modules that are being compiled
* *
@ -743,10 +655,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;
} }
/** /**
@ -756,7 +665,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions processors(Collection<String> classnames) { public JavacOptions processors(Collection<String> classnames) {
return addCommaSeparatedOption("-processor", classnames); add("-processor");
add(StringUtils.join(classnames, ","));
return this;
} }
/** /**
@ -766,10 +677,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions processorModulePath(File... paths) { public JavacOptions processorModulePath(File... paths) {
if (isNotEmpty(paths)) { return processorModulePath(Arrays.stream(paths)
processorModulePath(Arrays.asList(paths)); .map(File::getAbsolutePath)
} .toArray(String[]::new));
return this;
} }
/** /**
@ -779,10 +689,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorModulePath(Path... paths) { public JavacOptions processorModulePath(Path... paths) {
if (isNotEmpty(paths)) { return processorModulePath(Arrays.stream(paths)
processorModulePathPaths(Arrays.asList(paths)); .map(Path::toString)
} .toArray(String[]::new));
return this;
} }
/** /**
@ -792,9 +701,8 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorModulePath(String... paths) { public JavacOptions processorModulePath(String... paths) {
if (isNotEmpty(paths)) { add("--processor-module-path");
processorModulePathStrings(Arrays.asList(paths)); add(String.join(File.pathSeparator, paths));
}
return this; return this;
} }
@ -804,28 +712,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 processorModulePathPaths(Collection<Path> paths) { public JavacOptions processorModulePath(Collection<String> paths) {
return processorModulePathStrings(paths.stream().map(Path::toString).toList()); return processorModulePath(paths.toArray(new String[0]));
}
/**
* 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) {
return processorModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
} }
/** /**
@ -835,9 +723,8 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions processorPath(String... paths) { public JavacOptions processorPath(String... paths) {
if (isNotEmpty(paths)) { add("--processor-path");
processorPathStrings(Arrays.asList(paths)); add(String.join(File.pathSeparator, paths));
}
return this; return this;
} }
@ -848,10 +735,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorPath(File... paths) { public JavacOptions processorPath(File... paths) {
if (isNotEmpty(paths)) { return processorPath(Arrays.stream(paths)
processorPath(Arrays.asList(paths)); .map(File::getAbsolutePath)
} .toArray(String[]::new));
return this;
} }
/** /**
@ -861,10 +747,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions processorPath(Path... paths) { public JavacOptions processorPath(Path... paths) {
if (isNotEmpty(paths)) { return processorPath(Arrays.stream(paths)
processorPathPaths(Arrays.asList(paths)); .map(Path::toString)
} .toArray(String[]::new));
return this;
} }
/** /**
@ -873,32 +758,12 @@ 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 processorPathStrings(Collection<String> paths) { public JavacOptions processorPath(Collection<String> paths) {
return addPathOption("--processor-path", paths); return processorPath(paths.toArray(new String[0]));
} }
/** /**
* 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 processorPath(Collection<File> paths) {
return processorPathStrings(paths.stream().map(File::getAbsolutePath).toList());
}
/**
* Specify where to find annotation processors
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions processorPathPaths(Collection<Path> paths) {
return processorPathStrings(paths.stream().map(Path::toString).toList());
}
/**
* 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
@ -963,10 +828,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 1.5.18 * @since 1.5.18
*/ */
public JavacOptions upgradeModulePath(File... paths) { public JavacOptions upgradeModulePath(File... paths) {
if (isNotEmpty(paths)) { return upgradeModulePath(Arrays.stream(paths)
upgradeModulePath(Arrays.asList(paths)); .map(File::getAbsolutePath)
} .toArray(String[]::new));
return this;
} }
/** /**
@ -976,10 +840,9 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions upgradeModulePath(Path... paths) { public JavacOptions upgradeModulePath(Path... paths) {
if (isNotEmpty(paths)) { return upgradeModulePath(Arrays.stream(paths)
upgradeModulePathPaths(Arrays.asList(paths)); .map(Path::toString)
} .toArray(String[]::new));
return this;
} }
/** /**
@ -989,9 +852,8 @@ public class JavacOptions extends ArrayList<String> {
* @since 2.1 * @since 2.1
*/ */
public JavacOptions upgradeModulePath(String... paths) { public JavacOptions upgradeModulePath(String... paths) {
if (isNotEmpty(paths)) { add("--upgrade-module-path");
upgradeModulePathStrings(Arrays.asList(paths)); add(String.join(File.pathSeparator, paths));
}
return this; return this;
} }
@ -1001,28 +863,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 upgradeModulePathStrings(Collection<String> paths) { public JavacOptions upgradeModulePath(Collection<String> paths) {
return addPathOption("--upgrade-module-path", paths); return upgradeModulePath(paths.toArray(new String[0]));
}
/**
* Override location of upgradeable modules
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions upgradeModulePath(Collection<File> paths) {
return upgradeModulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
}
/**
* Override location of upgradeable modules
*
* @return this list of options
* @since 2.3.1
*/
public JavacOptions upgradeModulePathPaths(Collection<Path> paths) {
return upgradeModulePathStrings(paths.stream().map(Path::toString).toList());
} }
/** /**
@ -1054,10 +896,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;
} }
/** /**
@ -1066,7 +905,7 @@ 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) {
return addXLintOption(keys, ""); return addXLintOption(keys, "");
} }
@ -1077,10 +916,7 @@ 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;
} }
/** /**
@ -1089,21 +925,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 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; return this;
} }
private JavacOptions addXLintOption(Collection<XLintKey> keys, String prefix) { var formattedKeys = keys.stream()
if (isNotEmpty(keys)) { .map(key -> prefix + key.name().replace('_', '-').toLowerCase())
var keyString = keys.stream() .collect(Collectors.joining(",", "-Xlint:", ""));
.map(key -> key.name().replace('_', '-').toLowerCase())
.collect(Collectors.joining("," + prefix, prefix, ""));
add("-Xlint:" + keyString); add(formattedKeys);
}
return this; return this;
} }
} }

File diff suppressed because it is too large Load diff