mirror of
https://github.com/rife2/bld
synced 2026-02-23 08:33:45 +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")
|
* 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.List;
|
import java.util.Collection;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
|
import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
|
||||||
|
|
@ -23,6 +22,7 @@ import static rife.bld.operations.CompileOperation.COMPILE_OPTION_MODULE_PATH;
|
||||||
* @author Geert Bevin (gbevin[remove] at uwyn dot com)
|
* @author Geert Bevin (gbevin[remove] at uwyn dot com)
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public class JavacOptions extends ArrayList<String> {
|
public class JavacOptions extends ArrayList<String> {
|
||||||
public enum DebuggingInfo {
|
public enum DebuggingInfo {
|
||||||
ALL, NONE, LINES, VAR, SOURCE
|
ALL, NONE, LINES, VAR, SOURCE
|
||||||
|
|
@ -79,6 +79,46 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
VARARGS
|
VARARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper method to check if an array is not empty
|
||||||
|
private static <T> boolean isNotEmpty(T[] array) {
|
||||||
|
return array != null && array.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to check if a collection is not empty
|
||||||
|
private static boolean isNotEmpty(Collection<?> collection) {
|
||||||
|
return collection != null && !collection.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to add delimited options
|
||||||
|
*/
|
||||||
|
private JavacOptions addDelimitedOption(String option, Collection<String> values, String separator) {
|
||||||
|
if (isNotEmpty(values)) {
|
||||||
|
var joined = values.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.joining(separator));
|
||||||
|
if (!joined.isEmpty()) {
|
||||||
|
add(option);
|
||||||
|
add(joined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to add path-based options
|
||||||
|
*/
|
||||||
|
private JavacOptions addPathOption(String option, Collection<String> paths) {
|
||||||
|
return addDelimitedOption(option, paths, File.pathSeparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to add comma-separated options
|
||||||
|
*/
|
||||||
|
private JavacOptions addCommaSeparatedOption(String option, Collection<String> values) {
|
||||||
|
return addDelimitedOption(option, values, ",");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option to pass to annotation processors
|
* Option to pass to annotation processors
|
||||||
*
|
*
|
||||||
|
|
@ -99,7 +139,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions addExports(String... modules) {
|
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
|
* @return this list of options
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions addExports(List<String> modules) {
|
public JavacOptions addExports(Collection<String> modules) {
|
||||||
add("--add-exports");
|
return addCommaSeparatedOption("--add-exports", modules);
|
||||||
add(StringUtils.join(modules, ","));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,7 +164,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions addReads(String... modules) {
|
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
|
* @return this list of options
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions addReads(List<String> modules) {
|
public JavacOptions addReads(Collection<String> modules) {
|
||||||
add("--add-reads");
|
return addCommaSeparatedOption("--add-reads", modules);
|
||||||
add(StringUtils.join(modules, ","));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -146,7 +188,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions addModules(String... modules) {
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions addModules(List<String> modules) {
|
public JavacOptions addModules(Collection<String> modules) {
|
||||||
add("--add-modules");
|
return addCommaSeparatedOption("--add-modules", modules);
|
||||||
add(StringUtils.join(modules, ","));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -216,7 +259,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions endorsedDirs(File... dirs) {
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions endorsedDirs(List<File> dirs) {
|
public JavacOptions endorsedDirs(Collection<File> dirs) {
|
||||||
return endorsedDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
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
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions endorsedDirs(Path... dirs) {
|
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
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions endorsedDirsPaths(List<Path> dirs) {
|
public JavacOptions endorsedDirsPaths(Collection<Path> dirs) {
|
||||||
return endorsedDirs(dirs.stream().map(Path::toFile).toList());
|
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
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions endorsedDirs(String... dirs) {
|
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
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions endorsedDirsStrings(List<String> dirs) {
|
public JavacOptions endorsedDirsStrings(Collection<String> dirs) {
|
||||||
add("-endorseddirs");
|
return addCommaSeparatedOption("-endorseddirs", dirs);
|
||||||
add(String.join(",", dirs));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -278,7 +334,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions extDirs(File... dirs) {
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions extDirs(List<File> dirs) {
|
public JavacOptions extDirs(Collection<File> dirs) {
|
||||||
return extDirsStrings(dirs.stream().map(File::getAbsolutePath).toList());
|
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
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions extDirs(Path... dirs) {
|
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
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions extDirsPaths(List<Path> dirs) {
|
public JavacOptions extDirsPaths(Collection<Path> dirs) {
|
||||||
return extDirs(dirs.stream().map(Path::toFile).toList());
|
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
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions extDirs(String... dirs) {
|
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
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions extDirsStrings(List<String> dirs) {
|
public JavacOptions extDirsStrings(Collection<String> dirs) {
|
||||||
add("-extdirs");
|
return addCommaSeparatedOption("-extdirs", dirs);
|
||||||
add(String.join(",", dirs));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -457,7 +526,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions limitModules(String... modules) {
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions limitModules(List<String> modules) {
|
public JavacOptions limitModules(Collection<String> modules) {
|
||||||
add("--limit-modules");
|
return addCommaSeparatedOption("--limit-modules", modules);
|
||||||
add(StringUtils.join(modules, ","));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -479,7 +549,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions module(String... modules) {
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions module(List<String> modules) {
|
public JavacOptions module(Collection<String> modules) {
|
||||||
add("--module");
|
return addCommaSeparatedOption("--module", modules);
|
||||||
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) {
|
||||||
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
|
* @return this list of options
|
||||||
* @since 1.6.2
|
* @since 1.6.2
|
||||||
*/
|
*/
|
||||||
public JavacOptions modulePath(List<File> paths) {
|
public JavacOptions modulePath(Collection<File> paths) {
|
||||||
return modulePathStrings(paths.stream().map(File::getAbsolutePath).toList());
|
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
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions modulePath(Path... paths) {
|
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
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions modulePathPaths(List<Path> paths) {
|
public JavacOptions modulePathPaths(Collection<Path> paths) {
|
||||||
return modulePath(paths.stream().map(Path::toFile).toList());
|
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
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions modulePath(String... paths) {
|
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
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions modulePathStrings(List<String> paths) {
|
public JavacOptions modulePathStrings(Collection<String> paths) {
|
||||||
add(COMPILE_OPTION_MODULE_PATH);
|
return addPathOption(COMPILE_OPTION_MODULE_PATH, paths);
|
||||||
add(FileUtils.joinPaths(paths));
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify where to find input source files for multiple modules
|
||||||
|
*
|
||||||
|
* @return this list of options
|
||||||
|
* @since 2.3.1
|
||||||
|
*/
|
||||||
|
public JavacOptions moduleSourcePathStrings(Collection<String> paths) {
|
||||||
|
return addPathOption("--module-source-path", paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify where to find input source files for multiple modules
|
||||||
|
*
|
||||||
|
* @return this list of options
|
||||||
|
* @since 2.3.1
|
||||||
|
*/
|
||||||
|
public JavacOptions moduleSourcePathPaths(Collection<Path> paths) {
|
||||||
|
if (isNotEmpty(paths)) {
|
||||||
|
return moduleSourcePathStrings(paths.stream().map(Path::toString).toList());
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify where to find input source files for multiple modules
|
||||||
|
*
|
||||||
|
* @return this list of options
|
||||||
|
* @since 2.3.1
|
||||||
|
*/
|
||||||
|
public JavacOptions moduleSourcePath(Collection<File> paths) {
|
||||||
|
if (isNotEmpty(paths)) {
|
||||||
|
return moduleSourcePathStrings(paths.stream().map(File::getPath).toList());
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -562,8 +683,11 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions moduleSourcePath(File path) {
|
public JavacOptions moduleSourcePath(File... paths) {
|
||||||
return moduleSourcePath(path.getAbsolutePath());
|
if (isNotEmpty(paths)) {
|
||||||
|
moduleSourcePath(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -572,8 +696,11 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions moduleSourcePath(Path path) {
|
public JavacOptions moduleSourcePath(String... paths) {
|
||||||
return moduleSourcePath(path.toFile());
|
if (isNotEmpty(paths)) {
|
||||||
|
moduleSourcePathStrings(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -582,9 +709,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 moduleSourcePath(String path) {
|
public JavacOptions moduleSourcePath(Path... paths) {
|
||||||
add("--module-source-path");
|
if (isNotEmpty(paths)) {
|
||||||
add(path);
|
moduleSourcePathPaths(Arrays.asList(paths));
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -640,7 +768,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions processors(String... classnames) {
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions processors(List<String> classnames) {
|
public JavacOptions processors(Collection<String> classnames) {
|
||||||
add("-processor");
|
return addCommaSeparatedOption("-processor", classnames);
|
||||||
add(StringUtils.join(classnames, ","));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -661,8 +790,11 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions processorModulePath(File path) {
|
public JavacOptions processorModulePath(File... paths) {
|
||||||
return processorModulePath(path.getAbsolutePath());
|
if (isNotEmpty(paths)) {
|
||||||
|
processorModulePath(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -671,8 +803,11 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions processorModulePath(Path path) {
|
public JavacOptions processorModulePath(Path... paths) {
|
||||||
return processorModulePath(path.toFile());
|
if (isNotEmpty(paths)) {
|
||||||
|
processorModulePathPaths(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -681,9 +816,46 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions processorModulePath(String path) {
|
public JavacOptions processorModulePath(String... paths) {
|
||||||
add("--processor-module-path");
|
if (isNotEmpty(paths)) {
|
||||||
add(path);
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -693,34 +865,77 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions processorPath(File path) {
|
public JavacOptions processorPath(String... paths) {
|
||||||
return processorPath(path.getAbsolutePath());
|
if (isNotEmpty(paths)) {
|
||||||
}
|
processorPathStrings(Arrays.asList(paths));
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
return this;
|
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
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
|
|
@ -784,8 +999,11 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions upgradeModulePath(File path) {
|
public JavacOptions upgradeModulePath(File... paths) {
|
||||||
return upgradeModulePath(path.getAbsolutePath());
|
if (isNotEmpty(paths)) {
|
||||||
|
upgradeModulePath(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -794,8 +1012,11 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions upgradeModulePath(Path path) {
|
public JavacOptions upgradeModulePath(Path... paths) {
|
||||||
return upgradeModulePath(path.toFile());
|
if (isNotEmpty(paths)) {
|
||||||
|
upgradeModulePathPaths(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -804,9 +1025,46 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions upgradeModulePath(String path) {
|
public JavacOptions upgradeModulePath(String... paths) {
|
||||||
add("--upgrade-module-path");
|
if (isNotEmpty(paths)) {
|
||||||
add(path);
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -839,7 +1097,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions xLint(XLintKey... keys) {
|
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
|
* @return this list of options
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions xLint(List<XLintKey> keys) {
|
public JavacOptions xLint(Collection<XLintKey> keys) {
|
||||||
return addXLintOption(keys, "");
|
if (isNotEmpty(keys)) {
|
||||||
|
return addXLintOption(keys, "");
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -859,30 +1123,33 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions xLintDisable(XLintKey... keys) {
|
public JavacOptions xLintDisable(XLintKey... keys) {
|
||||||
return xLintDisable(Arrays.asList(keys));
|
if (isNotEmpty(keys)) {
|
||||||
|
xLintDisable(Arrays.asList(keys));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warning categories to disable
|
* Warning categories to disable
|
||||||
*
|
*
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 2.3.1
|
* @since 2.3.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions xLintDisable(List<XLintKey> keys) {
|
public JavacOptions xLintDisable(Collection<XLintKey> keys) {
|
||||||
return addXLintOption(keys, "-");
|
if (isNotEmpty(keys)) {
|
||||||
}
|
return addXLintOption(keys, "-");
|
||||||
|
|
||||||
|
|
||||||
private JavacOptions addXLintOption(List<XLintKey> keys, String prefix) {
|
|
||||||
if (keys == null || keys.isEmpty()) {
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var formattedKeys = keys.stream()
|
|
||||||
.map(key -> prefix + key.name().replace('_', '-').toLowerCase())
|
|
||||||
.collect(Collectors.joining(",", "-Xlint:", ""));
|
|
||||||
|
|
||||||
add(formattedKeys);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JavacOptions addXLintOption(Collection<XLintKey> keys, String prefix) {
|
||||||
|
if (isNotEmpty(keys)) {
|
||||||
|
var keyString = keys.stream()
|
||||||
|
.map(key -> key.name().replace('_', '-').toLowerCase())
|
||||||
|
.collect(Collectors.joining("," + prefix, prefix, ""));
|
||||||
|
|
||||||
|
add("-Xlint:" + keyString);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue