mirror of
https://github.com/rife2/bld
synced 2026-05-01 19:44:09 +02:00
Compare commits
No commits in common. "7b542ac5d015b89d94a8408a2d228ec8186e974e" and "737927da26f21baf2af59e69945479de873371b7" have entirely different histories.
7b542ac5d0
...
737927da26
|
|
@ -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")
|
||||
*/
|
||||
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.Objects;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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)
|
||||
* @since 1.5.18
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public class JavacOptions extends ArrayList<String> {
|
||||
public enum DebuggingInfo {
|
||||
ALL, NONE, LINES, VAR, SOURCE
|
||||
|
|
@ -79,46 +79,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 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
|
||||
*
|
||||
|
|
@ -139,10 +99,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -153,20 +110,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;
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +122,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -188,10 +146,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -201,8 +156,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -259,10 +216,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -271,11 +225,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions endorsedDirs(Collection<File> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
public JavacOptions endorsedDirs(List<File> dirs) {
|
||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -285,10 +236,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -297,11 +245,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsPaths(Collection<Path> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
return this;
|
||||
public JavacOptions endorsedDirsPaths(List<Path> dirs) {
|
||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -311,10 +256,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -323,8 +265,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions endorsedDirsStrings(Collection<String> dirs) {
|
||||
return addCommaSeparatedOption("-endorseddirs", dirs);
|
||||
public JavacOptions endorsedDirsStrings(List<String> dirs) {
|
||||
add("-endorseddirs");
|
||||
add(String.join(",", dirs));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -334,10 +278,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -346,11 +287,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions extDirs(Collection<File> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
public JavacOptions extDirs(List<File> dirs) {
|
||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -360,10 +298,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -372,11 +307,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsPaths(Collection<Path> dirs) {
|
||||
if (isNotEmpty(dirs)) {
|
||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
return this;
|
||||
public JavacOptions extDirsPaths(List<Path> dirs) {
|
||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -386,10 +318,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -398,8 +327,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions extDirsStrings(Collection<String> dirs) {
|
||||
return addCommaSeparatedOption("-extdirs", dirs);
|
||||
public JavacOptions extDirsStrings(List<String> dirs) {
|
||||
add("-extdirs");
|
||||
add(String.join(",", dirs));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -526,10 +457,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -538,8 +466,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -549,10 +479,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -561,22 +488,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -585,11 +510,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.6.2
|
||||
*/
|
||||
public JavacOptions modulePath(Collection<File> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
return this;
|
||||
public JavacOptions modulePath(List<File> paths) {
|
||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -599,10 +521,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -611,11 +530,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions modulePathPaths(Collection<Path> paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
return modulePathStrings(paths.stream().map(Path::toString).toList());
|
||||
}
|
||||
return this;
|
||||
public JavacOptions modulePathPaths(List<Path> paths) {
|
||||
return modulePath(paths.stream().map(Path::toFile).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -625,10 +541,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -637,43 +550,9 @@ 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) {
|
||||
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());
|
||||
}
|
||||
public JavacOptions modulePathStrings(List<String> paths) {
|
||||
add(COMPILE_OPTION_MODULE_PATH);
|
||||
add(FileUtils.joinPaths(paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -683,11 +562,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions moduleSourcePath(File path) {
|
||||
return moduleSourcePath(path.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -696,11 +572,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePathStrings(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions moduleSourcePath(Path path) {
|
||||
return moduleSourcePath(path.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -709,10 +582,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions moduleSourcePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
moduleSourcePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
public JavacOptions moduleSourcePath(String path) {
|
||||
add("--module-source-path");
|
||||
add(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -768,10 +640,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -780,8 +649,10 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processors(Collection<String> classnames) {
|
||||
return addCommaSeparatedOption("-processor", classnames);
|
||||
public JavacOptions processors(List<String> classnames) {
|
||||
add("-processor");
|
||||
add(StringUtils.join(classnames, ","));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -790,11 +661,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processorModulePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions processorModulePath(File path) {
|
||||
return processorModulePath(path.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -803,11 +671,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorModulePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorModulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions processorModulePath(Path path) {
|
||||
return processorModulePath(path.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -816,46 +681,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
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());
|
||||
}
|
||||
public JavacOptions processorModulePath(String path) {
|
||||
add("--processor-module-path");
|
||||
add(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -865,11 +693,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions processorPath(String... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPathStrings(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions processorPath(File path) {
|
||||
return processorPath(path.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -878,11 +703,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions processorPath(Path path) {
|
||||
return processorPath(path.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -891,51 +713,14 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions processorPath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
processorPathPaths(Arrays.asList(paths));
|
||||
}
|
||||
public JavacOptions processorPath(String path) {
|
||||
add("--processor-path");
|
||||
add(path);
|
||||
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
|
||||
* Check that API used is available in the specified profile
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
|
|
@ -999,11 +784,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 1.5.18
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(File... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePath(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions upgradeModulePath(File path) {
|
||||
return upgradeModulePath(path.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1012,11 +794,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
public JavacOptions upgradeModulePath(Path... paths) {
|
||||
if (isNotEmpty(paths)) {
|
||||
upgradeModulePathPaths(Arrays.asList(paths));
|
||||
}
|
||||
return this;
|
||||
public JavacOptions upgradeModulePath(Path path) {
|
||||
return upgradeModulePath(path.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1025,46 +804,9 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.1
|
||||
*/
|
||||
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());
|
||||
}
|
||||
public JavacOptions upgradeModulePath(String path) {
|
||||
add("--upgrade-module-path");
|
||||
add(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -1097,10 +839,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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1109,11 +848,8 @@ public class JavacOptions extends ArrayList<String> {
|
|||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLint(Collection<XLintKey> keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
return addXLintOption(keys, "");
|
||||
}
|
||||
return this;
|
||||
public JavacOptions xLint(List<XLintKey> keys) {
|
||||
return addXLintOption(keys, "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1123,33 +859,30 @@ 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning categories to disable
|
||||
*
|
||||
* @return this list of options
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public JavacOptions xLintDisable(Collection<XLintKey> keys) {
|
||||
if (isNotEmpty(keys)) {
|
||||
return addXLintOption(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;
|
||||
}
|
||||
|
||||
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