mirror of
https://github.com/rife2/bld
synced 2026-05-02 03:54:10 +02:00
Compare commits
No commits in common. "3160161299c3b7158f5461973c5750c9fe35bc0f" and "25c77ed5dfa5f11fe3b7046abfe58342635a28c9" have entirely different histories.
3160161299
...
25c77ed5df
|
|
@ -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")
|
||||
*/
|
||||
package rife.bld.operations;
|
||||
|
||||
import rife.tools.Convert;
|
||||
import rife.tools.FileUtils;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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)
|
||||
* @since 1.5.18
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public class JavacOptions extends ArrayList<String> {
|
||||
public enum DebuggingInfo {
|
||||
ALL, NONE, LINES, VAR, SOURCE
|
||||
|
|
@ -78,38 +80,6 @@ public class JavacOptions extends ArrayList<String> {
|
|||
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
|
||||
*
|
||||
|
|
@ -130,10 +100,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addExports(String... modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
addExports(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
return addExports(Arrays.asList(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,20 +111,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addExports(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--add-exports", 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));
|
||||
}
|
||||
public JavacOptions addExports(List<String> modules) {
|
||||
add("--add-exports");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -167,8 +123,20 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addReads(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--add-reads", modules);
|
||||
public JavacOptions addReads(String... 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
|
||||
*/
|
||||
public JavacOptions addModules(String... modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
addModules(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
return addModules(Arrays.asList(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -192,8 +157,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions addModules(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--add-modules", modules);
|
||||
public JavacOptions addModules(List<String> modules) {
|
||||
add("--add-modules");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -250,10 +217,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions endorsedDirs(File... dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
endorsedDirs(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
return endorsedDirs(Arrays.asList(dirs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -262,7 +226,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions endorsedDirs(Collection<File> dirs) {
|
||||
public JavacOptions endorsedDirs(List<File> dirs) {
|
||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
|
|
@ -273,10 +237,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirs(Path... dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
endorsedDirsPaths(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
return endorsedDirsPaths(Arrays.asList(dirs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -285,7 +246,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsPaths(Collection<Path> dirs) {
|
||||
public JavacOptions endorsedDirsPaths(List<Path> dirs) {
|
||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
|
|
@ -296,10 +257,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirs(String... dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
endorsedDirsStrings(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
return endorsedDirsStrings(Arrays.asList(dirs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -308,11 +266,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsStrings(Collection<String> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
public JavacOptions endorsedDirsStrings(List<String> dirs) {
|
||||
add("-endorseddirs");
|
||||
add(String.join(",", dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -323,10 +279,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions extDirs(File... dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
extDirs(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
return extDirs(Arrays.asList(dirs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -335,7 +288,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions extDirs(Collection<File> dirs) {
|
||||
public JavacOptions extDirs(List<File> dirs) {
|
||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
|
|
@ -346,10 +299,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirs(Path... dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
extDirsPaths(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
return extDirsPaths(Arrays.asList(dirs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -358,7 +308,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsPaths(Collection<Path> dirs) {
|
||||
public JavacOptions extDirsPaths(List<Path> dirs) {
|
||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
|
|
@ -369,10 +319,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirs(String... dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
extDirsStrings(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
return extDirsStrings(Arrays.asList(dirs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -381,11 +328,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsStrings(Collection<String> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
public JavacOptions extDirsStrings(List<String> dirs) {
|
||||
add("-extdirs");
|
||||
add(String.join(",", dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -513,10 +458,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions limitModules(String... modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
limitModules(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
return limitModules(Arrays.asList(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -525,8 +467,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions limitModules(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--limit-modules", modules);
|
||||
public JavacOptions limitModules(List<String> modules) {
|
||||
add("--limit-modules");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -536,10 +480,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions module(String... modules) {
|
||||
if (isNotEmpty(modules)) {
|
||||
module(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
return module(Arrays.asList(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -548,22 +489,20 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions module(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--module", modules);
|
||||
public JavacOptions module(List<String> modules) {
|
||||
add("--module");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* /**
|
||||
* Specify where to find application modules
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions modulePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
modulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return modulePath(Arrays.asList(paths));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -572,7 +511,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.6.2
|
||||
*/
|
||||
public JavacOptions modulePath(Collection<File> paths) {
|
||||
public JavacOptions modulePath(List<File> paths) {
|
||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
|
|
@ -583,10 +522,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
modulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return modulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -595,8 +531,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePathPaths(Collection<Path> paths) {
|
||||
return modulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
public JavacOptions modulePathPaths(List<Path> paths) {
|
||||
return modulePath(paths.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -606,10 +542,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
modulePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return modulePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -618,38 +551,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePathStrings(Collection<String> paths) {
|
||||
return addPathOption(COMPILE_OPTION_MODULE_PATH, 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) {
|
||||
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());
|
||||
public JavacOptions modulePathStrings(List<String> paths) {
|
||||
add(COMPILE_OPTION_MODULE_PATH);
|
||||
add(FileUtils.joinPaths(paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -659,23 +564,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePath(Arrays.asList(paths));
|
||||
}
|
||||
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;
|
||||
return moduleSourcePath(Arrays.stream(paths)
|
||||
.map(File::getAbsolutePath)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -685,12 +576,33 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePathPaths(Arrays.asList(paths));
|
||||
return moduleSourcePath(Arrays.stream(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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
@ -743,10 +655,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processors(String... classnames) {
|
||||
if (isNotEmpty(classnames)) {
|
||||
processors(Arrays.asList(classnames));
|
||||
}
|
||||
return this;
|
||||
return processors(Arrays.asList(classnames));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -756,7 +665,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public JavacOptions processorModulePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return processorModulePath(Arrays.stream(paths)
|
||||
.map(File::getAbsolutePath)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -779,10 +689,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorModulePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return processorModulePath(Arrays.stream(paths)
|
||||
.map(Path::toString)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -792,9 +701,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorModulePath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
add("--processor-module-path");
|
||||
add(String.join(File.pathSeparator, paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -804,28 +712,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorModulePathPaths(Collection<Path> paths) {
|
||||
return processorModulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
public JavacOptions processorModulePath(Collection<String> paths) {
|
||||
return processorModulePath(paths.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -835,9 +723,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processorPath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPathStrings(Arrays.asList(paths));
|
||||
}
|
||||
add("--processor-path");
|
||||
add(String.join(File.pathSeparator, paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -848,10 +735,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return processorPath(Arrays.stream(paths)
|
||||
.map(File::getAbsolutePath)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -861,10 +747,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return processorPath(Arrays.stream(paths)
|
||||
.map(Path::toString)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -873,32 +758,12 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions processorPathStrings(Collection<String> paths) {
|
||||
return addPathOption("--processor-path", paths);
|
||||
public JavacOptions processorPath(Collection<String> paths) {
|
||||
return processorPath(paths.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
*
|
||||
* @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
|
||||
* Check that API used is available in the specified profile
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
|
|
@ -963,10 +828,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return upgradeModulePath(Arrays.stream(paths)
|
||||
.map(File::getAbsolutePath)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -976,10 +840,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
return upgradeModulePath(Arrays.stream(paths)
|
||||
.map(Path::toString)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -989,9 +852,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
add("--upgrade-module-path");
|
||||
add(String.join(File.pathSeparator, paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -1001,28 +863,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @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) {
|
||||
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());
|
||||
public JavacOptions upgradeModulePath(Collection<String> paths) {
|
||||
return upgradeModulePath(paths.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1054,10 +896,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLint(XLintKey... keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
xLint(Arrays.asList(keys));
|
||||
}
|
||||
return this;
|
||||
return xLint(Arrays.asList(keys));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1066,7 +905,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLint(Collection<XLintKey> keys) {
|
||||
public JavacOptions xLint(List<XLintKey> keys) {
|
||||
return addXLintOption(keys, "");
|
||||
}
|
||||
|
||||
|
|
@ -1077,10 +916,7 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLintDisable(XLintKey... keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
xLintDisable(Arrays.asList(keys));
|
||||
}
|
||||
return this;
|
||||
return xLintDisable(Arrays.asList(keys));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1089,21 +925,20 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLintDisable(Collection<XLintKey> keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
public JavacOptions xLintDisable(List<XLintKey> keys) {
|
||||
return addXLintOption(keys, "-");
|
||||
}
|
||||
|
||||
private JavacOptions addXLintOption(List<XLintKey> keys, String prefix) {
|
||||
if (keys == null || keys.isEmpty()) {
|
||||
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, ""));
|
||||
var formattedKeys = keys.stream()
|
||||
.map(key -> prefix + key.name().replace('_', '-').toLowerCase())
|
||||
.collect(Collectors.joining(",", "-Xlint:", ""));
|
||||
|
||||
add("-Xlint:" + keyString);
|
||||
}
|
||||
add(formattedKeys);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue