mirror of
https://github.com/rife2/bld
synced 2026-03-12 14:34:09 +01:00
Add support for multiple input types (Collection, Varargs, File, Path) in JavacOptions path-related methods.
This commit is contained in:
parent
737927da26
commit
21ed5912f0
|
|
@ -12,6 +12,7 @@ import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -562,8 +563,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions moduleSourcePath(File path) {
|
public JavacOptions moduleSourcePath(File... paths) {
|
||||||
return moduleSourcePath(path.getAbsolutePath());
|
return moduleSourcePath(Arrays.stream(paths)
|
||||||
|
.map(File::getAbsolutePath)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -572,8 +575,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(Path path) {
|
public JavacOptions moduleSourcePath(Path... paths) {
|
||||||
return moduleSourcePath(path.toFile());
|
return moduleSourcePath(Arrays.stream(paths)
|
||||||
|
.map(Path::toString)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -582,9 +587,19 @@ 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(String... paths) {
|
||||||
|
return moduleSourcePath(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
add("--module-source-path");
|
add("--module-source-path");
|
||||||
add(path);
|
add(String.join(File.pathSeparator, paths));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -649,7 +664,7 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions processors(List<String> classnames) {
|
public JavacOptions processors(Collection<String> classnames) {
|
||||||
add("-processor");
|
add("-processor");
|
||||||
add(StringUtils.join(classnames, ","));
|
add(StringUtils.join(classnames, ","));
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -661,8 +676,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions processorModulePath(File path) {
|
public JavacOptions processorModulePath(File... paths) {
|
||||||
return processorModulePath(path.getAbsolutePath());
|
return processorModulePath(Arrays.stream(paths)
|
||||||
|
.map(File::getAbsolutePath)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -671,8 +688,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 processorModulePath(Path path) {
|
public JavacOptions processorModulePath(Path... paths) {
|
||||||
return processorModulePath(path.toFile());
|
return processorModulePath(Arrays.stream(paths)
|
||||||
|
.map(Path::toString)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -681,9 +700,19 @@ 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) {
|
||||||
|
return processorModulePath(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify a module path where to find annotation processors
|
||||||
|
*
|
||||||
|
* @return this list of options
|
||||||
|
* @since 2.3.1
|
||||||
|
*/
|
||||||
|
public JavacOptions processorModulePath(Collection<String> paths) {
|
||||||
add("--processor-module-path");
|
add("--processor-module-path");
|
||||||
add(path);
|
add(String.join(File.pathSeparator, paths));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -693,8 +722,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 processorPath(File path) {
|
public JavacOptions processorPath(String... paths) {
|
||||||
return processorPath(path.getAbsolutePath());
|
return processorPath(Arrays.asList(paths));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -703,8 +732,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 processorPath(Path path) {
|
public JavacOptions processorPath(File... paths) {
|
||||||
return processorPath(path.toFile());
|
return processorPath(Arrays.stream(paths)
|
||||||
|
.map(File::getAbsolutePath)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -713,9 +744,21 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public JavacOptions processorPath(String path) {
|
public JavacOptions processorPath(Path... paths) {
|
||||||
|
return processorPath(Arrays.stream(paths)
|
||||||
|
.map(Path::toString)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify where to find annotation processors
|
||||||
|
*
|
||||||
|
* @return this list of options
|
||||||
|
* @since 2.3.1
|
||||||
|
*/
|
||||||
|
public JavacOptions processorPath(Collection<String> paths) {
|
||||||
add("--processor-path");
|
add("--processor-path");
|
||||||
add(path);
|
add(String.join(File.pathSeparator, paths));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -784,8 +827,10 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
* @return this list of options
|
* @return this list of options
|
||||||
* @since 1.5.18
|
* @since 1.5.18
|
||||||
*/
|
*/
|
||||||
public JavacOptions upgradeModulePath(File path) {
|
public JavacOptions upgradeModulePath(File... paths) {
|
||||||
return upgradeModulePath(path.getAbsolutePath());
|
return upgradeModulePath(Arrays.stream(paths)
|
||||||
|
.map(File::getAbsolutePath)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -794,8 +839,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 upgradeModulePath(Path path) {
|
public JavacOptions upgradeModulePath(Path... paths) {
|
||||||
return upgradeModulePath(path.toFile());
|
return upgradeModulePath(Arrays.stream(paths)
|
||||||
|
.map(Path::toString)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -804,9 +851,19 @@ 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) {
|
||||||
|
return upgradeModulePath(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override location of upgradeable modules
|
||||||
|
*
|
||||||
|
* @return this list of options
|
||||||
|
* @since 2.3.1
|
||||||
|
*/
|
||||||
|
public JavacOptions upgradeModulePath(Collection<String> paths) {
|
||||||
add("--upgrade-module-path");
|
add("--upgrade-module-path");
|
||||||
add(path);
|
add(String.join(File.pathSeparator, paths));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -861,6 +918,7 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
public JavacOptions xLintDisable(XLintKey... keys) {
|
public JavacOptions xLintDisable(XLintKey... keys) {
|
||||||
return xLintDisable(Arrays.asList(keys));
|
return xLintDisable(Arrays.asList(keys));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warning categories to disable
|
* Warning categories to disable
|
||||||
*
|
*
|
||||||
|
|
@ -871,7 +929,6 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
return addXLintOption(keys, "-");
|
return addXLintOption(keys, "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JavacOptions addXLintOption(List<XLintKey> keys, String prefix) {
|
private JavacOptions addXLintOption(List<XLintKey> keys, String prefix) {
|
||||||
if (keys == null || keys.isEmpty()) {
|
if (keys == null || keys.isEmpty()) {
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -884,5 +941,4 @@ public class JavacOptions extends ArrayList<String> {
|
||||||
add(formattedKeys);
|
add(formattedKeys);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -9,6 +9,8 @@ import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import rife.bld.operations.JavacOptions.XLintKey;
|
import rife.bld.operations.JavacOptions.XLintKey;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -171,7 +173,7 @@ class TestJavacOptions {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testAddReadsWithList() {
|
void testAddReadsWithList() {
|
||||||
List<String> modules = Arrays.asList("mod1=mod2", "mod3=mod4", "mod5=mod6");
|
var modules = Arrays.asList("mod1=mod2", "mod3=mod4", "mod5=mod6");
|
||||||
options.addReads(modules);
|
options.addReads(modules);
|
||||||
|
|
||||||
assertEquals(2, options.size());
|
assertEquals(2, options.size());
|
||||||
|
|
@ -960,4 +962,401 @@ class TestJavacOptions {
|
||||||
assertEquals(1, options.size());
|
assertEquals(1, options.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class ModuleSourcePathTests {
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathMethodChaining() {
|
||||||
|
options.moduleSourcePath("src/module1", "src/module2")
|
||||||
|
.parameters()
|
||||||
|
.deprecation();
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertTrue(options.contains("--module-source-path"));
|
||||||
|
assertTrue(options.contains("-parameters"));
|
||||||
|
assertTrue(options.contains("-deprecation"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathMultipleCalls() {
|
||||||
|
options.moduleSourcePath("src/module1")
|
||||||
|
.moduleSourcePath("src/module2");
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
assertEquals("--module-source-path", options.get(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathReturnsThis() {
|
||||||
|
var result = options.moduleSourcePath("src/modules");
|
||||||
|
assertSame(options, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathWithCollection() {
|
||||||
|
var paths = Arrays.asList("src/mod1", "src/mod2", "src/mod3");
|
||||||
|
options.moduleSourcePath(paths);
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("src/mod1"));
|
||||||
|
assertTrue(options.get(1).contains("src/mod2"));
|
||||||
|
assertTrue(options.get(1).contains("src/mod3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathWithEmptyCollection() {
|
||||||
|
options.moduleSourcePath(List.of());
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
assertEquals("", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathWithEmptyVarargs() {
|
||||||
|
options.moduleSourcePath("");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathWithFile() {
|
||||||
|
options.moduleSourcePath(new File("src/modules"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("src"));
|
||||||
|
assertTrue(options.get(1).contains("modules"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathWithPath() {
|
||||||
|
options.moduleSourcePath(Path.of("src/modules"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("src"));
|
||||||
|
assertTrue(options.get(1).contains("modules"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathWithSingleString() {
|
||||||
|
options.moduleSourcePath("src/modules");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
assertEquals("src/modules", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testModuleSourcePathWithVarargs() {
|
||||||
|
options.moduleSourcePath("src/mod1", "src/mod2", "src/mod3");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--module-source-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("src/mod1"));
|
||||||
|
assertTrue(options.get(1).contains("src/mod2"));
|
||||||
|
assertTrue(options.get(1).contains("src/mod3"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class ProcessorModulePathTests {
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathMethodChaining() {
|
||||||
|
options.processorModulePath("lib/processors")
|
||||||
|
.parameters()
|
||||||
|
.deprecation();
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertTrue(options.contains("--processor-module-path"));
|
||||||
|
assertTrue(options.contains("-parameters"));
|
||||||
|
assertTrue(options.contains("-deprecation"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathMultipleCalls() {
|
||||||
|
options.processorModulePath("lib/proc1")
|
||||||
|
.processorModulePath("lib/proc2");
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
assertEquals("--processor-module-path", options.get(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathReturnsThis() {
|
||||||
|
var result = options.processorModulePath("lib/processors");
|
||||||
|
assertSame(options, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathWithCollection() {
|
||||||
|
var paths = Arrays.asList("lib/proc1", "lib/proc2", "lib/proc3");
|
||||||
|
options.processorModulePath(paths);
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc1"));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc2"));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathWithEmptyCollection() {
|
||||||
|
options.processorModulePath(List.of());
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
assertEquals("", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathWithEmptyVarargs() {
|
||||||
|
options.processorModulePath(new String[]{});
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathWithFile() {
|
||||||
|
options.processorModulePath(new File("lib/processors"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib"));
|
||||||
|
assertTrue(options.get(1).contains("processors"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathWithPath() {
|
||||||
|
options.processorModulePath(Path.of("lib/processors"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib"));
|
||||||
|
assertTrue(options.get(1).contains("processors"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathWithSingleString() {
|
||||||
|
options.processorModulePath("lib/processors");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
assertEquals("lib/processors", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorModulePathWithVarargs() {
|
||||||
|
options.processorModulePath("lib/proc1", "lib/proc2");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc1"));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class ProcessorPathTests {
|
||||||
|
@Test
|
||||||
|
void testProcessorPathMethodChaining() {
|
||||||
|
options.processorPath("lib/processors.jar")
|
||||||
|
.parameters()
|
||||||
|
.deprecation();
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertTrue(options.contains("--processor-path"));
|
||||||
|
assertTrue(options.contains("-parameters"));
|
||||||
|
assertTrue(options.contains("-deprecation"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathMultipleCalls() {
|
||||||
|
options.processorPath("lib/proc1.jar")
|
||||||
|
.processorPath("lib/proc2.jar");
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
assertEquals("--processor-path", options.get(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathReturnsThis() {
|
||||||
|
var result = options.processorPath("lib/processors.jar");
|
||||||
|
assertSame(options, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathWithCollection() {
|
||||||
|
var paths = Arrays.asList("lib/proc1.jar", "lib/proc2.jar", "lib/proc3.jar");
|
||||||
|
options.processorPath(paths);
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc1.jar"));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc2.jar"));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc3.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathWithEmptyCollection() {
|
||||||
|
options.processorPath(List.of());
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
assertEquals("", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathWithEmptyVarargs() {
|
||||||
|
options.processorPath(new String[]{});
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathWithFile() {
|
||||||
|
options.processorPath(new File("lib/processors.jar"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib"));
|
||||||
|
assertTrue(options.get(1).contains("processors.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathWithPath() {
|
||||||
|
options.processorPath(Path.of("lib/processors.jar"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib"));
|
||||||
|
assertTrue(options.get(1).contains("processors.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathWithSingleString() {
|
||||||
|
options.processorPath("lib/processors.jar");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
assertEquals("lib/processors.jar", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testProcessorPathWithVarargs() {
|
||||||
|
options.processorPath("lib/proc1.jar", "lib/proc2.jar");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--processor-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc1.jar"));
|
||||||
|
assertTrue(options.get(1).contains("lib/proc2.jar"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class UpgradeModulePathTests {
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathMethodChaining() {
|
||||||
|
options.upgradeModulePath("lib/upgrades")
|
||||||
|
.parameters()
|
||||||
|
.deprecation();
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertTrue(options.contains("--upgrade-module-path"));
|
||||||
|
assertTrue(options.contains("-parameters"));
|
||||||
|
assertTrue(options.contains("-deprecation"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathMultipleCalls() {
|
||||||
|
options.upgradeModulePath("lib/upgrade1")
|
||||||
|
.upgradeModulePath("lib/upgrade2");
|
||||||
|
|
||||||
|
assertEquals(4, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
assertEquals("--upgrade-module-path", options.get(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathReturnsThis() {
|
||||||
|
var result = options.upgradeModulePath("lib/upgrades");
|
||||||
|
assertSame(options, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathWithCollection() {
|
||||||
|
var paths = Arrays.asList("lib/upg1", "lib/upg2", "lib/upg3");
|
||||||
|
options.upgradeModulePath(paths);
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib/upg1"));
|
||||||
|
assertTrue(options.get(1).contains("lib/upg2"));
|
||||||
|
assertTrue(options.get(1).contains("lib/upg3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathWithEmptyCollection() {
|
||||||
|
options.upgradeModulePath(List.of());
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
assertEquals("", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathWithEmptyVarargs() {
|
||||||
|
options.upgradeModulePath(new String[]{});
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathWithFile() {
|
||||||
|
options.upgradeModulePath(new File("lib/upgrades"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib"));
|
||||||
|
assertTrue(options.get(1).contains("upgrades"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathWithPath() {
|
||||||
|
options.upgradeModulePath(Path.of("lib/upgrades"));
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib"));
|
||||||
|
assertTrue(options.get(1).contains("upgrades"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathWithSingleString() {
|
||||||
|
options.upgradeModulePath("lib/upgrades");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
assertEquals("lib/upgrades", options.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpgradeModulePathWithVarargs() {
|
||||||
|
options.upgradeModulePath("lib/upg1", "lib/upg2");
|
||||||
|
|
||||||
|
assertEquals(2, options.size());
|
||||||
|
assertEquals("--upgrade-module-path", options.get(0));
|
||||||
|
assertTrue(options.get(1).contains("lib/upg1"));
|
||||||
|
assertTrue(options.get(1).contains("lib/upg2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue