Cleaned up API to match bld operations and options APIs
Some checks failed
bld-ci / build-bld-project (17, 1.19.24) (push) Has been cancelled
bld-ci / build-bld-project (17, 2.0.0) (push) Has been cancelled
bld-ci / build-bld-project (21, 1.19.24) (push) Has been cancelled
bld-ci / build-bld-project (21, 2.0.0) (push) Has been cancelled
bld-ci / build-bld-project (22, 1.19.24) (push) Has been cancelled
bld-ci / build-bld-project (22, 2.0.0) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled

This commit is contained in:
Erik C. Thauvin 2024-08-27 23:20:08 -07:00
parent fdee1781b5
commit 61d41e2fbe
Signed by: erik
GPG key ID: 776702A6A2DA330E
8 changed files with 634 additions and 44 deletions

6
.idea/bld.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BldConfiguration">
<events />
</component>
</project>

View file

@ -1,9 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="rife.bld.extension.CompileKotlinOperationTest" />
<module name="app" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View file

@ -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

View file

@ -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;

View file

@ -26,7 +26,11 @@ import rife.tools.StringUtils;
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 class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @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 class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @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.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* 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 class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* This can be configured on per-package basis.
*
* @param files the markdown files
* @return this operation instance
*/
public DokkaOperation includesPaths(Collection<Path> files) {
includes_.addAll(files.stream().map(Path::toFile).toList());
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* This can be configured on per-package basis.
*
* @param files the markdown files
* @return this operation instance
*/
public DokkaOperation includesStrings(Collection<String> files) {
includes_.addAll(files.stream().map(File::new).toList());
return this;
}
/**
* JSON configuration file path.
*
@ -499,6 +546,33 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
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 class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
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.
* <p>
@ -598,8 +681,19 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @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.
* <p>
* 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 class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
/**
* 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<String, String> pluginConfiguratione) {
pluginsConfiguration_.putAll(pluginConfiguratione);
public DokkaOperation pluginConfigurations(Map<String, String> pluginConfigurations) {
pluginsConfiguration_.putAll(pluginConfigurations);
return this;
}
@ -666,8 +760,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @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 class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @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 class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
return this;
}
/**
* Sets the jars for Dokka plugins and their dependencies.
*
* @param jars the jars
* @return this operation instance
*/
public DokkaOperation pluginsClasspathPaths(Collection<Path> 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<String> jars) {
pluginsClasspath_.addAll(jars.stream().map(File::new).toList());
return this;
}
/**
* Sets the configurations for a source set.
* <p>

View file

@ -19,7 +19,11 @@ package rife.bld.extension.dokka;
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 class SourceSet {
* @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 class SourceSet {
* @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.
* <p>
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
* <p>
* 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 class SourceSet {
return classpath_;
}
/**
* Sets classpath for analysis and interactive samples.
* <p>
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
* <p>
* This option accepts both {@code .jar} and {@code .klib} files.
*
* @param files the collection of files
* @return this operation instance
*/
public SourceSet classpathPaths(Collection<Path> files) {
classpath_.addAll(files.stream().map(Path::toFile).toList());
return this;
}
/**
* Sets classpath for analysis and interactive samples.
* <p>
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
* <p>
* This option accepts both {@code .jar} and {@code .klib} files.
*
* @param files the collection of files
* @return this operation instance
*/
public SourceSet classpathStrings(Collection<String> files) {
classpath_.addAll(files.stream().map(File::new).toList());
return this;
}
/**
* Sets the names of dependent source sets.
*
@ -420,10 +466,25 @@ public class SourceSet {
* @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.
* <p>
* The Markdown files that contain module and package documentation.
* <p>
* 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 class SourceSet {
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The Markdown files that contain module and package documentation.
* <p>
* 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<Path> files) {
includes_.addAll(files.stream().map(Path::toFile).toList());
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The Markdown files that contain module and package documentation.
* <p>
* 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<String> files) {
includes_.addAll(files.stream().map(File::new).toList());
return this;
}
/**
* Sets the version of JDK to use for linking to JDK Javadocs.
* <p>
@ -465,6 +558,15 @@ public class SourceSet {
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.
* <p>
@ -657,8 +759,7 @@ public class SourceSet {
* @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 class SourceSet {
* @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.
* <p>
* 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.
* <p>
* 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<Path> samples) {
samples_.addAll(samples.stream().map(Path::toFile).toList());
return this;
}
/**
* Set the directories or files that contain sample functions.
* <p>
* 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<String> samples) {
samples_.addAll(samples.stream().map(File::new).toList());
return this;
}
@ -725,8 +866,7 @@ public class SourceSet {
* @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 class SourceSet {
* @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.
* <p>
* 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 class SourceSet {
return srcLinks_;
}
/**
* Sets the source code roots to be analyzed and documented.
* <p>
* 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<Path> src) {
src_.addAll(src.stream().map(Path::toFile).toList());
return this;
}
/**
* Sets the source code roots to be analyzed and documented.
* <p>
* 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<String> src) {
src_.addAll(src.stream().map(File::new).toList());
return this;
}
/**
* Sets the paths to files to be suppressed.
* <p>
@ -800,7 +980,6 @@ public class SourceSet {
return this;
}
/**
* Retrieves the paths to files to be suppressed.
*
@ -819,8 +998,7 @@ public class SourceSet {
* @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 class SourceSet {
* @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.
* <p>
* 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.
* <p>
* The files to be suppressed when generating documentation.
*
* @param suppressedFiles the suppressed files
* @return this operation instance
*/
public SourceSet suppressedFilesPaths(Collection<Path> suppressedFiles) {
suppressedFiles_.addAll(suppressedFiles.stream().map(Path::toFile).toList());
return this;
}
/**
* Sets the paths to files to be suppressed.
* <p>
* The files to be suppressed when generating documentation.
*
* @param suppressedFiles the suppressed files
* @return this operation instance
*/
public SourceSet suppressedFilesStrings(Collection<String> suppressedFiles) {
suppressedFiles_.addAll(suppressedFiles.stream().map(File::new).toList());
return this;
}
}

View file

@ -27,6 +27,7 @@ import rife.bld.operations.exceptions.ExitStatusException;
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 @@ class DokkaOperationTest {
.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();
}
}

View file

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
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 java.util.stream.IntStream;
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 @@ class SourceSetTest {
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();
}
}