mirror of
https://github.com/rife2/bld
synced 2026-02-04 01:03:42 +01:00
Merge aa10006ce2 into 737927da26
This commit is contained in:
commit
ebd2f0b861
|
|
@ -1,18 +1,17 @@
|
|||
/*
|
||||
* Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
|
||||
* Copyright 2001-2026 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.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
|
||||
|
|
@ -23,6 +22,7 @@ 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
|
||||
|
|
@ -79,6 +79,46 @@ 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 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
|
||||
*
|
||||
|
|
@ -99,7 +139,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addExports(String... modules) {
|
||||
return addExports(Arrays.asList(modules));
|
||||
if (isNotEmpty(modules)) {
|
||||
addExports(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,10 +153,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addExports(List<String> modules) {
|
||||
add("--add-exports");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
public JavacOptions addExports(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--add-exports", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -123,7 +164,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addReads(String... modules) {
|
||||
return addReads(Arrays.asList(modules));
|
||||
if (isNotEmpty(modules)) {
|
||||
addReads(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -132,10 +176,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions addReads(List<String> modules) {
|
||||
add("--add-reads");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
public JavacOptions addReads(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--add-reads", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -146,7 +188,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions addModules(String... modules) {
|
||||
return addModules(Arrays.asList(modules));
|
||||
if (isNotEmpty(modules)) {
|
||||
addModules(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,10 +201,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions addModules(List<String> modules) {
|
||||
add("--add-modules");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
public JavacOptions addModules(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--add-modules", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,7 +259,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions endorsedDirs(File... dirs) {
|
||||
return endorsedDirs(Arrays.asList(dirs));
|
||||
if (isNotEmpty(dirs)) {
|
||||
endorsedDirs(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -225,8 +271,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions endorsedDirs(List<File> dirs) {
|
||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
public JavacOptions endorsedDirs(Collection<File> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -236,7 +285,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirs(Path... dirs) {
|
||||
return endorsedDirsPaths(Arrays.asList(dirs));
|
||||
if (isNotEmpty(dirs)) {
|
||||
endorsedDirsPaths(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -245,8 +297,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsPaths(List<Path> dirs) {
|
||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
||||
public JavacOptions endorsedDirsPaths(Collection<Path> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -256,7 +311,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirs(String... dirs) {
|
||||
return endorsedDirsStrings(Arrays.asList(dirs));
|
||||
if (isNotEmpty(dirs)) {
|
||||
endorsedDirsStrings(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -265,10 +323,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsStrings(List<String> dirs) {
|
||||
add("-endorseddirs");
|
||||
add(String.join(",", dirs));
|
||||
return this;
|
||||
public JavacOptions endorsedDirsStrings(Collection<String> dirs) {
|
||||
return addCommaSeparatedOption("-endorseddirs", dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -278,7 +334,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions extDirs(File... dirs) {
|
||||
return extDirs(Arrays.asList(dirs));
|
||||
if (isNotEmpty(dirs)) {
|
||||
extDirs(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -287,8 +346,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions extDirs(List<File> dirs) {
|
||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
public JavacOptions extDirs(Collection<File> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -298,7 +360,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirs(Path... dirs) {
|
||||
return extDirsPaths(Arrays.asList(dirs));
|
||||
if (isNotEmpty(dirs)) {
|
||||
extDirsPaths(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -307,8 +372,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsPaths(List<Path> dirs) {
|
||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
||||
public JavacOptions extDirsPaths(Collection<Path> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -318,7 +386,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirs(String... dirs) {
|
||||
return extDirsStrings(Arrays.asList(dirs));
|
||||
if (isNotEmpty(dirs)) {
|
||||
extDirsStrings(Arrays.asList(dirs));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -327,10 +398,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsStrings(List<String> dirs) {
|
||||
add("-extdirs");
|
||||
add(String.join(",", dirs));
|
||||
return this;
|
||||
public JavacOptions extDirsStrings(Collection<String> dirs) {
|
||||
return addCommaSeparatedOption("-extdirs", dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -457,7 +526,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions limitModules(String... modules) {
|
||||
return limitModules(Arrays.asList(modules));
|
||||
if (isNotEmpty(modules)) {
|
||||
limitModules(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -466,10 +538,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions limitModules(List<String> modules) {
|
||||
add("--limit-modules");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
public JavacOptions limitModules(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--limit-modules", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -479,7 +549,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions module(String... modules) {
|
||||
return module(Arrays.asList(modules));
|
||||
if (isNotEmpty(modules)) {
|
||||
module(Arrays.asList(modules));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -488,20 +561,22 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions module(List<String> modules) {
|
||||
add("--module");
|
||||
add(StringUtils.join(modules, ","));
|
||||
return this;
|
||||
public JavacOptions module(Collection<String> modules) {
|
||||
return addCommaSeparatedOption("--module", modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* /**
|
||||
* Specify where to find application modules
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions modulePath(File... paths) {
|
||||
return modulePath(Arrays.asList(paths));
|
||||
if (isNotEmpty(paths)) {
|
||||
modulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -510,8 +585,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.6.2
|
||||
*/
|
||||
public JavacOptions modulePath(List<File> paths) {
|
||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
public JavacOptions modulePath(Collection<File> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -521,7 +599,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePath(Path... paths) {
|
||||
return modulePathPaths(Arrays.asList(paths));
|
||||
if (isNotEmpty(paths)) {
|
||||
modulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -530,8 +611,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePathPaths(List<Path> paths) {
|
||||
return modulePath(paths.stream().map(Path::toFile).toList());
|
||||
public JavacOptions modulePathPaths(Collection<Path> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return modulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -541,7 +625,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePath(String... paths) {
|
||||
return modulePathStrings(Arrays.asList(paths));
|
||||
if (isNotEmpty(paths)) {
|
||||
modulePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -550,9 +637,43 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePathStrings(List<String> paths) {
|
||||
add(COMPILE_OPTION_MODULE_PATH);
|
||||
add(FileUtils.joinPaths(paths));
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -562,8 +683,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(File path) {
|
||||
return moduleSourcePath(path.getAbsolutePath());
|
||||
public JavacOptions moduleSourcePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -572,8 +696,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(Path path) {
|
||||
return moduleSourcePath(path.toFile());
|
||||
public JavacOptions moduleSourcePath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -582,9 +709,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(String path) {
|
||||
add("--module-source-path");
|
||||
add(path);
|
||||
public JavacOptions moduleSourcePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -640,7 +768,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processors(String... classnames) {
|
||||
return processors(Arrays.asList(classnames));
|
||||
if (isNotEmpty(classnames)) {
|
||||
processors(Arrays.asList(classnames));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -649,10 +780,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processors(List<String> classnames) {
|
||||
add("-processor");
|
||||
add(StringUtils.join(classnames, ","));
|
||||
return this;
|
||||
public JavacOptions processors(Collection<String> classnames) {
|
||||
return addCommaSeparatedOption("-processor", classnames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -661,8 +790,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processorModulePath(File path) {
|
||||
return processorModulePath(path.getAbsolutePath());
|
||||
public JavacOptions processorModulePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -671,8 +803,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorModulePath(Path path) {
|
||||
return processorModulePath(path.toFile());
|
||||
public JavacOptions processorModulePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -681,9 +816,46 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorModulePath(String path) {
|
||||
add("--processor-module-path");
|
||||
add(path);
|
||||
public JavacOptions processorModulePath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -693,34 +865,77 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processorPath(File path) {
|
||||
return processorPath(path.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(Path path) {
|
||||
return processorPath(path.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(String path) {
|
||||
add("--processor-path");
|
||||
add(path);
|
||||
public JavacOptions processorPath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPathStrings(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that API used is available in the specified profile
|
||||
* Specify where to find annotation processors
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify where to find annotation processors
|
||||
*
|
||||
* @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
|
||||
* @since 1.5.18
|
||||
|
|
@ -784,8 +999,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(File path) {
|
||||
return upgradeModulePath(path.getAbsolutePath());
|
||||
public JavacOptions upgradeModulePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -794,8 +1012,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(Path path) {
|
||||
return upgradeModulePath(path.toFile());
|
||||
public JavacOptions upgradeModulePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -804,9 +1025,46 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(String path) {
|
||||
add("--upgrade-module-path");
|
||||
add(path);
|
||||
public JavacOptions upgradeModulePath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +1097,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLint(XLintKey... keys) {
|
||||
return xLint(Arrays.asList(keys));
|
||||
if (isNotEmpty(keys)) {
|
||||
xLint(Arrays.asList(keys));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -848,8 +1109,11 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLint(List<XLintKey> keys) {
|
||||
return addXLintOption(keys, "");
|
||||
public JavacOptions xLint(Collection<XLintKey> keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
return addXLintOption(keys, "");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -859,30 +1123,33 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLintDisable(XLintKey... keys) {
|
||||
return xLintDisable(Arrays.asList(keys));
|
||||
if (isNotEmpty(keys)) {
|
||||
xLintDisable(Arrays.asList(keys));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning categories to disable
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLintDisable(List<XLintKey> keys) {
|
||||
return addXLintOption(keys, "-");
|
||||
}
|
||||
|
||||
|
||||
private JavacOptions addXLintOption(List<XLintKey> keys, String prefix) {
|
||||
if (keys == null || keys.isEmpty()) {
|
||||
return this;
|
||||
public JavacOptions xLintDisable(Collection<XLintKey> keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
return addXLintOption(keys, "-");
|
||||
}
|
||||
|
||||
var formattedKeys = keys.stream()
|
||||
.map(key -> prefix + key.name().replace('_', '-').toLowerCase())
|
||||
.collect(Collectors.joining(",", "-Xlint:", ""));
|
||||
|
||||
add(formattedKeys);
|
||||
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
Loading…
Reference in a new issue