From 61d41e2fbe8f9591c23423762d73f6b81b1a9fd0 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 27 Aug 2024 23:20:08 -0700 Subject: [PATCH] Cleaned up API to match bld operations and options APIs --- .idea/bld.xml | 6 + .idea/runConfigurations/Run Tests.xml | 9 - examples/lib/bld/bld-wrapper.properties | 4 +- .../bld/extension/DokkaOperationBuild.java | 2 +- .../rife/bld/extension/DokkaOperation.java | 152 ++++++++++- .../rife/bld/extension/dokka/SourceSet.java | 251 ++++++++++++++++-- .../bld/extension/DokkaOperationTest.java | 91 +++++++ .../bld/extension/dokka/SourceSetTest.java | 163 ++++++++++++ 8 files changed, 634 insertions(+), 44 deletions(-) create mode 100644 .idea/bld.xml delete mode 100644 .idea/runConfigurations/Run Tests.xml diff --git a/.idea/bld.xml b/.idea/bld.xml new file mode 100644 index 0000000..6600cee --- /dev/null +++ b/.idea/bld.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml deleted file mode 100644 index 057a90e..0000000 --- a/.idea/runConfigurations/Run Tests.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 7719b26..9834218 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,8 +1,8 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.0 -bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.0 +bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.1-SNAPSHOT +bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.1-SNAPSHOT bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.0.1 diff --git a/src/bld/java/rife/bld/extension/DokkaOperationBuild.java b/src/bld/java/rife/bld/extension/DokkaOperationBuild.java index 3438f3b..97d313c 100644 --- a/src/bld/java/rife/bld/extension/DokkaOperationBuild.java +++ b/src/bld/java/rife/bld/extension/DokkaOperationBuild.java @@ -33,7 +33,7 @@ public class DokkaOperationBuild extends Project { public DokkaOperationBuild() { pkg = "rife.bld.extension"; name = "bld-dokka"; - version = version(1, 0, 0); + version = version(1, 0, 1, "SNAPSHOT"); javaRelease = 17; diff --git a/src/main/java/rife/bld/extension/DokkaOperation.java b/src/main/java/rife/bld/extension/DokkaOperation.java index 03f9323..c3e71c0 100644 --- a/src/main/java/rife/bld/extension/DokkaOperation.java +++ b/src/main/java/rife/bld/extension/DokkaOperation.java @@ -26,7 +26,11 @@ import java.io.File; import java.io.IOException; -import java.util.*; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -446,8 +450,7 @@ public DokkaOperation globalSrcLink(Collection links) { * @return this operation instance */ public DokkaOperation includes(File... files) { - includes_.addAll(List.of(files)); - return this; + return includes(List.of(files)); } /** @@ -461,10 +464,24 @@ public DokkaOperation includes(File... files) { * @return this operation instance */ public DokkaOperation includes(String... files) { - includes_.addAll(Arrays.stream(files).map(File::new).toList()); - return this; + return includesStrings(List.of(files)); + } + + /** + * Sets the Markdown files that contain module and package documentation. + *

+ * The contents of specified files are parsed and embedded into documentation as module and package descriptions. + *

+ * This can be configured on per-package basis. + * + * @param files one or more files + * @return this operation instance + */ + public DokkaOperation includes(Path... files) { + return includesPaths(List.of(files)); } + /** * Retrieves the markdown files that contain the module and package documentation. * @@ -489,6 +506,36 @@ public DokkaOperation includes(Collection files) { return this; } + /** + * Sets the Markdown files that contain module and package documentation. + *

+ * The contents of specified files are parsed and embedded into documentation as module and package descriptions. + *

+ * This can be configured on per-package basis. + * + * @param files the markdown files + * @return this operation instance + */ + public DokkaOperation includesPaths(Collection files) { + includes_.addAll(files.stream().map(Path::toFile).toList()); + return this; + } + + /** + * Sets the Markdown files that contain module and package documentation. + *

+ * The contents of specified files are parsed and embedded into documentation as module and package descriptions. + *

+ * This can be configured on per-package basis. + * + * @param files the markdown files + * @return this operation instance + */ + public DokkaOperation includesStrings(Collection files) { + includes_.addAll(files.stream().map(File::new).toList()); + return this; + } + /** * JSON configuration file path. * @@ -499,6 +546,33 @@ public DokkaOperation json(File configuration) { return this; } + /** + * JSON configuration file path. + * + * @param configuration the configuration file path + */ + public DokkaOperation json(Path configuration) { + return json(configuration.toFile()); + } + + /** + * Retrieves the JSON configuration file path. + * + * @return the configuration file path + */ + public File json() { + return json_; + } + + /** + * JSON configuration file path. + * + * @param configuration the configuration file path + */ + public DokkaOperation json(String configuration) { + return json(new File(configuration)); + } + /** * Sets the logging level. * @@ -589,6 +663,15 @@ public DokkaOperation outputDir(File outputDir) { return this; } + /** + * Retrieves the output directory path. + * + * @return the output directory + */ + public File outputDir() { + return outputDir_; + } + /** * Sets the output directory path, {@code ./dokka} by default. *

@@ -598,8 +681,19 @@ public DokkaOperation outputDir(File outputDir) { * @return this operation instance */ public DokkaOperation outputDir(String outputDir) { - outputDir_ = new File(outputDir); - return this; + return outputDir(new File(outputDir)); + } + + /** + * Sets the output directory path, {@code ./dokka} by default. + *

+ * The directory to where documentation is generated, regardless of output format. + * + * @param outputDir the output directory + * @return this operation instance + */ + public DokkaOperation outputDir(Path outputDir) { + return outputDir(outputDir.toFile()); } /** @@ -641,12 +735,12 @@ public DokkaOperation pluginConfigurations(String name, String jsonConfiguration /** * Sets the configuration for Dokka plugins. * - * @param pluginConfiguratione the map of configurations + * @param pluginConfigurations the map of configurations * @return this operation instance * @see #pluginConfigurations(String, String) */ - public DokkaOperation pluginConfigurations(Map pluginConfiguratione) { - pluginsConfiguration_.putAll(pluginConfiguratione); + public DokkaOperation pluginConfigurations(Map pluginConfigurations) { + pluginsConfiguration_.putAll(pluginConfigurations); return this; } @@ -666,8 +760,7 @@ public Map pluginConfigurations() { * @return this operation instance */ public DokkaOperation pluginsClasspath(File... jars) { - pluginsClasspath_.addAll(List.of(jars)); - return this; + return pluginsClasspath(List.of(jars)); } /** @@ -677,8 +770,17 @@ public DokkaOperation pluginsClasspath(File... jars) { * @return this operation instance */ public DokkaOperation pluginsClasspath(String... jars) { - pluginsClasspath_.addAll(Arrays.stream(jars).map(File::new).toList()); - return this; + return pluginsClasspathStrings(List.of(jars)); + } + + /** + * Sets the jars for Dokka plugins and their dependencies. + * + * @param jars one or more jars + * @return this operation instance + */ + public DokkaOperation pluginsClasspath(Path... jars) { + return pluginsClasspathPaths(List.of(jars)); } /** @@ -701,6 +803,28 @@ public DokkaOperation pluginsClasspath(Collection jars) { return this; } + /** + * Sets the jars for Dokka plugins and their dependencies. + * + * @param jars the jars + * @return this operation instance + */ + public DokkaOperation pluginsClasspathPaths(Collection jars) { + pluginsClasspath_.addAll(jars.stream().map(Path::toFile).toList()); + return this; + } + + /** + * Sets the jars for Dokka plugins and their dependencies. + * + * @param jars the jars + * @return this operation instance + */ + public DokkaOperation pluginsClasspathStrings(Collection jars) { + pluginsClasspath_.addAll(jars.stream().map(File::new).toList()); + return this; + } + /** * Sets the configurations for a source set. *

diff --git a/src/main/java/rife/bld/extension/dokka/SourceSet.java b/src/main/java/rife/bld/extension/dokka/SourceSet.java index 2b5f24a..78a7074 100644 --- a/src/main/java/rife/bld/extension/dokka/SourceSet.java +++ b/src/main/java/rife/bld/extension/dokka/SourceSet.java @@ -19,7 +19,11 @@ import rife.bld.extension.DokkaOperation; import java.io.File; -import java.util.*; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -238,8 +242,7 @@ public List args() { * @return this operation instance */ public SourceSet classpath(File... files) { - classpath_.addAll(List.of(files)); - return this; + return classpath(List.of(files)); } /** @@ -253,8 +256,21 @@ public SourceSet classpath(File... files) { * @return this operation instance */ public SourceSet classpath(String... files) { - classpath_.addAll(Arrays.stream(files).map(File::new).toList()); - return this; + return classpathStrings(List.of(files)); + } + + /** + * Sets classpath for analysis and interactive samples. + *

+ * This is useful if some types that come from dependencies are not resolved/picked up automatically. + *

+ * This option accepts both {@code .jar} and {@code .klib} files. + * + * @param files one or more file + * @return this operation instance + */ + public SourceSet classpath(Path... files) { + return classpathPaths(List.of(files)); } /** @@ -281,6 +297,36 @@ public Collection classpath() { return classpath_; } + /** + * Sets classpath for analysis and interactive samples. + *

+ * This is useful if some types that come from dependencies are not resolved/picked up automatically. + *

+ * This option accepts both {@code .jar} and {@code .klib} files. + * + * @param files the collection of files + * @return this operation instance + */ + public SourceSet classpathPaths(Collection files) { + classpath_.addAll(files.stream().map(Path::toFile).toList()); + return this; + } + + /** + * Sets classpath for analysis and interactive samples. + *

+ * This is useful if some types that come from dependencies are not resolved/picked up automatically. + *

+ * This option accepts both {@code .jar} and {@code .klib} files. + * + * @param files the collection of files + * @return this operation instance + */ + public SourceSet classpathStrings(Collection files) { + classpath_.addAll(files.stream().map(File::new).toList()); + return this; + } + /** * Sets the names of dependent source sets. * @@ -420,10 +466,25 @@ public SourceSet includes(File... files) { * @return this operation instance */ public SourceSet includes(String... files) { - includes_.addAll(Arrays.stream(files).map(File::new).toList()); - return this; + return includesStrings(List.of(files)); } + /** + * Sets the Markdown files that contain module and package documentation. + *

+ * The Markdown files that contain module and package documentation. + *

+ * The contents of the specified files are parsed and embedded into documentation as module and package + * descriptions. + * + * @param files one or more files + * @return this operation instance + */ + public SourceSet includes(Path... files) { + return includesPaths(List.of(files)); + } + + /** * Retrieves the Markdown files that contain module and package documentation. * @@ -449,6 +510,38 @@ public SourceSet includes(Collection files) { return this; } + /** + * Sets the Markdown files that contain module and package documentation. + *

+ * The Markdown files that contain module and package documentation. + *

+ * The contents of the specified files are parsed and embedded into documentation as module and package + * descriptions. + * + * @param files the collection of files + * @return this operation instance + */ + public SourceSet includesPaths(Collection files) { + includes_.addAll(files.stream().map(Path::toFile).toList()); + return this; + } + + /** + * Sets the Markdown files that contain module and package documentation. + *

+ * The Markdown files that contain module and package documentation. + *

+ * The contents of the specified files are parsed and embedded into documentation as module and package + * descriptions. + * + * @param files the collection of files + * @return this operation instance + */ + public SourceSet includesStrings(Collection files) { + includes_.addAll(files.stream().map(File::new).toList()); + return this; + } + /** * Sets the version of JDK to use for linking to JDK Javadocs. *

@@ -465,6 +558,15 @@ public SourceSet jdkVersion(String jdkVersion) { return this; } + /** + * Retrieves the version of the JDK to use for linking to JDK Javadocs. + * + * @return the JDK version. + */ + public String jdkVersion() { + return jdkVersion_; + } + /** * Sets the version of JDK to use for linking to JDK Javadocs. *

@@ -657,8 +759,7 @@ public Collection samples() { * @return this operation instance */ public SourceSet samples(File... samples) { - samples_.addAll(List.of(samples)); - return this; + return samples(List.of(samples)); } /** @@ -671,7 +772,47 @@ public SourceSet samples(File... samples) { * @return this operation instance */ public SourceSet samples(String... samples) { - samples_.addAll(Arrays.stream(samples).map(File::new).toList()); + return samplesStrings(List.of(samples)); + } + + /** + * Set the directories or files that contain sample functions. + *

+ * The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc + * tag. + * + * @param samples nne or more samples + * @return this operation instance + */ + public SourceSet samples(Path... samples) { + return samplesPaths(List.of(samples)); + } + + /** + * Set the directories or files that contain sample functions. + *

+ * The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc + * tag. + * + * @param samples the samples + * @return this operation instance + */ + public SourceSet samplesPaths(Collection samples) { + samples_.addAll(samples.stream().map(Path::toFile).toList()); + return this; + } + + /** + * Set the directories or files that contain sample functions. + *

+ * The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc + * tag. + * + * @param samples the samples + * @return this operation instance + */ + public SourceSet samplesStrings(Collection samples) { + samples_.addAll(samples.stream().map(File::new).toList()); return this; } @@ -725,8 +866,7 @@ public SourceSet src(Collection src) { * @return this operation instance */ public SourceSet src(File... src) { - src_.addAll(List.of(src)); - return this; + return src(List.of(src)); } /** @@ -739,8 +879,20 @@ public SourceSet src(File... src) { * @return this operation instance */ public SourceSet src(String... src) { - src_.addAll(Arrays.stream(src).map(File::new).toList()); - return this; + return srcStrings(List.of(src)); + } + + /** + * Sets the source code roots to be analyzed and documented. + *

+ * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual + * {@code .kt} / {@code .java} files. + * + * @param src pne ore moe source code roots + * @return this operation instance + */ + public SourceSet src(Path... src) { + return srcPaths(List.of(src)); } /** @@ -787,6 +939,34 @@ public Map srcLinks() { return srcLinks_; } + /** + * Sets the source code roots to be analyzed and documented. + *

+ * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual + * {@code .kt} / {@code .java} files. + * + * @param src the source code roots + * @return this operation instance + */ + public SourceSet srcPaths(Collection src) { + src_.addAll(src.stream().map(Path::toFile).toList()); + return this; + } + + /** + * Sets the source code roots to be analyzed and documented. + *

+ * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual + * {@code .kt} / {@code .java} files. + * + * @param src the source code roots + * @return this operation instance + */ + public SourceSet srcStrings(Collection src) { + src_.addAll(src.stream().map(File::new).toList()); + return this; + } + /** * Sets the paths to files to be suppressed. *

@@ -800,7 +980,6 @@ public SourceSet suppressedFiles(Collection suppressedFiles) { return this; } - /** * Retrieves the paths to files to be suppressed. * @@ -819,8 +998,7 @@ public Collection suppressedFiles() { * @return this operation instance */ public SourceSet suppressedFiles(String... suppressedFiles) { - suppressedFiles_.addAll(Arrays.stream(suppressedFiles).map(File::new).toList()); - return this; + return suppressedFilesStrings(List.of(suppressedFiles)); } /** @@ -832,7 +1010,44 @@ public SourceSet suppressedFiles(String... suppressedFiles) { * @return this operation instance */ public SourceSet suppressedFiles(File... suppressedFiles) { - suppressedFiles_.addAll(List.of(suppressedFiles)); + return suppressedFiles(List.of(suppressedFiles)); + } + + /** + * Sets the paths to files to be suppressed. + *

+ * The files to be suppressed when generating documentation. + * + * @param suppressedFiles one or moe suppressed files + * @return this operation instance + */ + public SourceSet suppressedFiles(Path... suppressedFiles) { + return suppressedFilesPaths(List.of(suppressedFiles)); + } + + /** + * Sets the paths to files to be suppressed. + *

+ * The files to be suppressed when generating documentation. + * + * @param suppressedFiles the suppressed files + * @return this operation instance + */ + public SourceSet suppressedFilesPaths(Collection suppressedFiles) { + suppressedFiles_.addAll(suppressedFiles.stream().map(Path::toFile).toList()); + return this; + } + + /** + * Sets the paths to files to be suppressed. + *

+ * The files to be suppressed when generating documentation. + * + * @param suppressedFiles the suppressed files + * @return this operation instance + */ + public SourceSet suppressedFilesStrings(Collection suppressedFiles) { + suppressedFiles_.addAll(suppressedFiles.stream().map(File::new).toList()); return this; } } diff --git a/src/test/java/rife/bld/extension/DokkaOperationTest.java b/src/test/java/rife/bld/extension/DokkaOperationTest.java index 11c2bca..398fd22 100644 --- a/src/test/java/rife/bld/extension/DokkaOperationTest.java +++ b/src/test/java/rife/bld/extension/DokkaOperationTest.java @@ -27,6 +27,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import java.util.List; @@ -181,4 +182,94 @@ void executeTest() { .outputFormat(OutputFormat.JAVADOC); assertThatCode(op::execute).doesNotThrowAnyException(); } + + @Test + void includesTest() { + var op = new DokkaOperation(); + + op.includes(List.of(new File(FILE_1), new File(FILE_2))); + assertThat(op.includes()).as("List(File...)").containsExactly(new File(FILE_1), new File(FILE_2)); + op.includes().clear(); + + op.includes(new File(FILE_1), new File(FILE_2)); + assertThat(op.includes()).as("File...").containsExactly(new File(FILE_1), new File(FILE_2)); + op.includes().clear(); + + op.includes(FILE_1, FILE_2); + assertThat(op.includes()).as("String...") + .containsExactly(new File(FILE_1), new File(FILE_2)); + op.includes().clear(); + + op = op.includes(Path.of(FILE_1), Path.of(FILE_2)); + assertThat(op.includes()).as("Path...") + .containsExactly(new File(FILE_1), new File(FILE_2)); + op.includes().clear(); + + op.includesPaths(List.of(new File(FILE_1).toPath(), new File(FILE_2).toPath())); + assertThat(op.includes()).as("List(Path...)").containsExactly(new File(FILE_1), new File(FILE_2)); + op.includes().clear(); + + op.includesStrings(List.of(FILE_1, FILE_2)); + assertThat(op.includes()).as("List(String...)").containsExactly(new File(FILE_1), new File(FILE_2)); + op.includes().clear(); + } + + @Test + void jsonTest() { + var file1 = new File(FILE_1); + var op = new DokkaOperation().json(file1); + assertThat(op.json()).isEqualTo(file1); + + var file2 = Path.of(FILE_2); + op = op.json(file2); + assertThat(op.json()).isEqualTo(file2.toFile()); + + op = op.json(FILE_3); + assertThat(op.json()).isEqualTo(new File(FILE_3)); + } + + @Test + void outputDirTest() { + var javadoc = "build/javadoc"; + var op = new DokkaOperation().outputDir(javadoc); + assertThat(op.outputDir()).isEqualTo(new File(javadoc)); + + var build = "build"; + op = op.outputDir(Path.of(build)); + assertThat(op.outputDir()).isEqualTo(new File(build)); + + op = op.outputDir(new File(javadoc)); + assertThat(op.outputDir()).isEqualTo(new File(javadoc)); + } + + @Test + void pluginClasspathTest() { + var op = new DokkaOperation(); + + op.pluginsClasspath(List.of(new File(FILE_1), new File(FILE_2))); + assertThat(op.pluginsClasspath()).as("List(File...)").containsExactly(new File(FILE_1), new File(FILE_2)); + op.pluginsClasspath().clear(); + + op.pluginsClasspath(new File(FILE_1), new File(FILE_2)); + assertThat(op.pluginsClasspath()).as("File...").containsExactly(new File(FILE_1), new File(FILE_2)); + op.pluginsClasspath().clear(); + + op.pluginsClasspath(FILE_1, FILE_2); + assertThat(op.pluginsClasspath()).as("String...") + .containsExactly(new File(FILE_1), new File(FILE_2)); + op.pluginsClasspath().clear(); + + op = op.pluginsClasspath(Path.of(FILE_1), Path.of(FILE_2)); + assertThat(op.pluginsClasspath()).as("Path...") + .containsExactly(new File(FILE_1), new File(FILE_2)); + op.pluginsClasspath().clear(); + + op.pluginsClasspathPaths(List.of(new File(FILE_1).toPath(), new File(FILE_2).toPath())); + assertThat(op.pluginsClasspath()).as("List(Path...)").containsExactly(new File(FILE_1), new File(FILE_2)); + op.pluginsClasspath().clear(); + + op.pluginsClasspathStrings(List.of(FILE_1, FILE_2)); + assertThat(op.pluginsClasspath()).as("List(String...)").containsExactly(new File(FILE_1), new File(FILE_2)); + op.pluginsClasspath().clear(); + } } diff --git a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java b/src/test/java/rife/bld/extension/dokka/SourceSetTest.java index 95453c4..031a818 100644 --- a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java +++ b/src/test/java/rife/bld/extension/dokka/SourceSetTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Map; @@ -29,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static rife.bld.extension.TestUtils.localPath; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class SourceSetTest { private static final String CLASSPATH_1 = "classpath1"; private static final String CLASSPATH_2 = "classpath2"; @@ -51,6 +53,104 @@ class SourceSetTest { private static final String SUP_2 = "sup2"; private static final String SUP_3 = "sup3"; + @Test + void classpathTest() { + var args = new SourceSet(); + + args.classpath(new File(CLASSPATH_1), new File(CLASSPATH_2)); + assertThat(args.classpath()).as("File...").containsExactly(new File(CLASSPATH_1), new File(CLASSPATH_2)); + args.classpath().clear(); + + args = args.classpath(Path.of(CLASSPATH_1), Path.of(CLASSPATH_2)); + assertThat(args.classpath()).as("Path...") + .containsExactly(new File(CLASSPATH_1), new File(CLASSPATH_2)); + args.classpath().clear(); + + args.classpath(CLASSPATH_1, CLASSPATH_2); + assertThat(args.classpath()).as("String...") + .containsExactly(new File(CLASSPATH_1), new File(CLASSPATH_2)); + args.classpath().clear(); + + args.classpath(List.of(new File(CLASSPATH_1), new File(CLASSPATH_2))); + assertThat(args.classpath()).as("File(List...)").containsExactly(new File(CLASSPATH_1), new File(CLASSPATH_2)); + args.classpath().clear(); + + args.classpathPaths(List.of(new File(CLASSPATH_1).toPath(), new File(CLASSPATH_2).toPath())); + assertThat(args.classpath()).as("List(Path...)").containsExactly(new File(CLASSPATH_1), new File(CLASSPATH_2)); + args.classpath().clear(); + + args.classpathStrings(List.of(CLASSPATH_1, CLASSPATH_2)); + assertThat(args.classpath()).as("List(String...)").containsExactly(new File(CLASSPATH_1), new File(CLASSPATH_2)); + args.classpath().clear(); + } + + @Test + void includesTest() { + var args = new SourceSet(); + + args.includes(new File(INCLUDES_1), new File(INCLUDES_2)); + assertThat(args.includes()).as("File...").containsExactly(new File(INCLUDES_1), new File(INCLUDES_2)); + args.includes().clear(); + + args = args.includes(Path.of(INCLUDES_1), Path.of(INCLUDES_2)); + assertThat(args.includes()).as("Path...").containsExactly(new File(INCLUDES_1), new File(INCLUDES_2)); + args.includes().clear(); + + args.includes(INCLUDES_1, INCLUDES_2); + assertThat(args.includes()).as("String...").containsExactly(new File(INCLUDES_1), new File(INCLUDES_2)); + args.includes().clear(); + + args.includes(List.of(new File(INCLUDES_1), new File(INCLUDES_2))); + assertThat(args.includes()).as("List(File...)").containsExactly(new File(INCLUDES_1), new File(INCLUDES_2)); + args.includes().clear(); + + args.includesPaths(List.of(new File(INCLUDES_1).toPath(), new File(INCLUDES_2).toPath())); + assertThat(args.includes()).as("List(Path...)").containsExactly(new File(INCLUDES_1), new File(INCLUDES_2)); + args.includes().clear(); + + args.includesStrings(List.of(INCLUDES_1, INCLUDES_2)); + assertThat(args.includes()).as("List(String...)").containsExactly(new File(INCLUDES_1), new File(INCLUDES_2)); + args.includes().clear(); + } + + @Test + void jdkVersionTest() { + var args = new SourceSet().jdkVersion("22"); + assertThat(args.jdkVersion()).isEqualTo("22"); + args = args.jdkVersion(19); + assertThat(args.jdkVersion()).isEqualTo("19"); + } + + @Test + void samplesTest() { + var args = new SourceSet(); + args.samples(new File(SAMPLES_1), new File(SAMPLES_2)); + assertThat(args.samples()).as("File...").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.samples().clear(); + + args = args.samples(Path.of(SAMPLES_1), Path.of(SAMPLES_2)); + assertThat(args.samples()).as("Path...") + .containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.samples().clear(); + + args.samples(SAMPLES_1, SAMPLES_2); + assertThat(args.samples()).as("String...") + .containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.samples().clear(); + + args.samples(List.of(new File(SAMPLES_1), new File(SAMPLES_2))); + assertThat(args.samples()).as("List(File...)").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.samples().clear(); + + args.samplesPaths(List.of(new File(SAMPLES_1).toPath(), new File(SAMPLES_2).toPath())); + assertThat(args.samples()).as("List(Path...)").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.samples().clear(); + + args.samplesStrings(List.of(SAMPLES_1, SAMPLES_2)); + assertThat(args.samples()).as("List(String...)").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.samples().clear(); + } + @Test void sourceSetCollectionsTest() { var args = new SourceSet() @@ -179,4 +279,67 @@ void sourceSetTest() throws IOException { IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i))); } + + @Test + void srcTest() { + var src = "src"; + var main = "src/main"; + var test = "src/test"; + var srcFile = new File(src); + var mainFile = new File(main); + var testFile = new File(test); + + var args = new SourceSet().src(src, main); + assertThat(args.src()).as("String...").containsExactly(srcFile, mainFile); + args.src().clear(); + + args = new SourceSet().srcStrings(List.of(src, main)); + assertThat(args.src()).as("List(String...)").containsExactly(srcFile, mainFile); + args.src().clear(); + + args = args.src(srcFile.toPath(), mainFile.toPath()); + assertThat(args.src()).as("Path...").containsExactly(srcFile, mainFile); + args.src().clear(); + + args = args.srcPaths(List.of(srcFile.toPath(), testFile.toPath())); + assertThat(args.src()).as("List(Path...)").containsExactly(srcFile, testFile); + args.src().clear(); + + args = args.src(srcFile, mainFile); + assertThat(args.src()).as("File...").containsExactly(srcFile, mainFile); + args.src().clear(); + + args = args.src(List.of(srcFile, mainFile)); + assertThat(args.src()).as("List(File...)").containsExactly(srcFile, mainFile); + args.src().clear(); + } + + @Test + void suppressedFilesTest() { + var args = new SourceSet(); + + args.suppressedFiles(new File(SAMPLES_1), new File(SAMPLES_2)); + assertThat(args.suppressedFiles()).as("File...").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.suppressedFiles().clear(); + + args = args.suppressedFiles(Path.of(SAMPLES_1), Path.of(SAMPLES_2)); + assertThat(args.suppressedFiles()).as("Path...").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.suppressedFiles().clear(); + + args.suppressedFiles(SAMPLES_1, SAMPLES_2); + assertThat(args.suppressedFiles()).as("String...").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.suppressedFiles().clear(); + + args.suppressedFiles(List.of(new File(SAMPLES_1), new File(SAMPLES_2))); + assertThat(args.suppressedFiles()).as("List(File...)").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.suppressedFiles().clear(); + + args.suppressedFilesPaths(List.of(new File(SAMPLES_1).toPath(), new File(SAMPLES_2).toPath())); + assertThat(args.suppressedFiles()).as("List(Path...)").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.suppressedFiles().clear(); + + args.suppressedFilesStrings(List.of(SAMPLES_1, SAMPLES_2)); + assertThat(args.suppressedFiles()).as("List(String...)").containsExactly(new File(SAMPLES_1), new File(SAMPLES_2)); + args.suppressedFiles().clear(); + } }