Convert parameters from String to File whenever applicable
This commit is contained in:
parent
2d5a3068cf
commit
af8e211feb
7 changed files with 429 additions and 92 deletions
|
@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
|
||||
class DokkaOperationTest {
|
||||
@Test
|
||||
@SuppressWarnings({"ExtractMethodRecommender", "PMD.AvoidDuplicateLiterals"})
|
||||
@SuppressWarnings({"PMD.AvoidDuplicateLiterals"})
|
||||
void executeConstructProcessCommandListTest() throws IOException {
|
||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt"));
|
||||
|
||||
|
@ -43,7 +43,7 @@ class DokkaOperationTest {
|
|||
|
||||
var examples = new File("examples");
|
||||
var jsonConf = new File("config.json");
|
||||
var params = new DokkaOperation()
|
||||
var op = new DokkaOperation()
|
||||
.delayTemplateSubstitution(true)
|
||||
.failOnWarning(true)
|
||||
.fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
|
||||
|
@ -53,8 +53,9 @@ class DokkaOperationTest {
|
|||
.globalPackageOptions(List.of("option3", "option4"))
|
||||
.globalSrcLink("link1", "link2")
|
||||
.globalSrcLink(List.of("link3", "link4"))
|
||||
.includes("file1", "file2")
|
||||
.includes(List.of("file3", "file4"))
|
||||
.includes(new File("file1"))
|
||||
.includes("file2")
|
||||
.includes(List.of(new File("file3"), new File("file4")))
|
||||
.json(jsonConf)
|
||||
.loggingLevel(LoggingLevel.DEBUG)
|
||||
.moduleName("name")
|
||||
|
@ -65,16 +66,24 @@ class DokkaOperationTest {
|
|||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.pluginConfigurations("name", "{\"json\"}")
|
||||
.pluginConfigurations(Map.of("{\"name2\"}", "json2", "name3}", "{json3"))
|
||||
.pluginsClasspath("path1", "path2")
|
||||
.pluginsClasspath(List.of("path3", "path4"))
|
||||
.pluginsClasspath(new File("path1"))
|
||||
.pluginsClasspath("path2")
|
||||
.pluginsClasspath(List.of(new File("path3"), new File("path4")))
|
||||
.sourceSet(new SourceSet().classpath(
|
||||
List.of(
|
||||
new File("examples/foo.jar"),
|
||||
new File("examples/bar.jar")
|
||||
)))
|
||||
.suppressInheritedMembers(true)
|
||||
.executeConstructProcessCommandList();
|
||||
.suppressInheritedMembers(true);
|
||||
|
||||
assertThat(op.globalLinks()).as("globalLinks").hasSize(2);
|
||||
assertThat(op.globalPackageOptions()).as("globalPackageOptions").hasSize(4);
|
||||
assertThat(op.globalSrcLink()).as("globalSrcLink").hasSize(4);
|
||||
assertThat(op.includes()).as("includes").hasSize(4);
|
||||
assertThat(op.pluginConfigurations()).as("pluginConfigurations").hasSize(3);
|
||||
assertThat(op.pluginsClasspath()).as("pluginsClasspath").hasSize(9);
|
||||
|
||||
var params = op.executeConstructProcessCommandList();
|
||||
for (var p : args) {
|
||||
var found = false;
|
||||
for (var a : params) {
|
||||
|
@ -94,15 +103,17 @@ class DokkaOperationTest {
|
|||
path + "/lib/bld/analysis-kotlin-descriptors-" + dokkaJar + ';' +
|
||||
path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' +
|
||||
path + "/lib/bld/korte-jvm-4.0.10.jar;" +
|
||||
path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ";path1;path2;path3;path4",
|
||||
"-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;" + path + "/bar.jar",
|
||||
path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ';' +
|
||||
TestUtil.localPath("path1", "path2", "path3", "path4"),
|
||||
"-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;"
|
||||
+ path + "/bar.jar",
|
||||
"-outputDir", path + "/build",
|
||||
"-delayTemplateSubstitution",
|
||||
"-failOnWarning",
|
||||
"-globalLinks", "s^link^^s2^link2",
|
||||
"-globalPackageOptions", "option1;option2;option3;option4",
|
||||
"-globalSrcLinks_", "link1;link2;link3;link4",
|
||||
"-includes", "file1;file2;file3;file4",
|
||||
"-includes", TestUtil.localPath("file1", "file2", "file3", "file4"),
|
||||
"-loggingLevel", "debug",
|
||||
"-moduleName", "name",
|
||||
"-moduleVersion", "1.0",
|
||||
|
|
40
src/test/java/rife/bld/extension/TestUtil.java
Normal file
40
src/test/java/rife/bld/extension/TestUtil.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static rife.bld.extension.DokkaOperation.SEMICOLON;
|
||||
|
||||
@SuppressWarnings("PMD.TestClassWithoutTestCases")
|
||||
public final class TestUtil {
|
||||
private TestUtil() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local path of the given file names.
|
||||
*
|
||||
* @param fileNames The file names
|
||||
* @return the local path
|
||||
*/
|
||||
public static String localPath(String... fileNames) {
|
||||
return Arrays.stream(fileNames).map(it -> new File(it).getAbsolutePath()).collect(Collectors.joining(SEMICOLON));
|
||||
}
|
||||
}
|
|
@ -14,13 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension;
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.extension.dokka.AnalysisPlatform;
|
||||
import rife.bld.extension.dokka.DocumentedVisibility;
|
||||
import rife.bld.extension.dokka.SourceSet;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -29,26 +27,36 @@ import java.util.Map;
|
|||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static rife.bld.extension.TestUtil.localPath;
|
||||
|
||||
class SourceSetTest {
|
||||
public static final String SAMPLES_1 = "samples1";
|
||||
public static final String SAMPLES_2 = "samples2";
|
||||
public static final String SUP_1 = "sup1";
|
||||
public static final String SUP_2 = "sup2";
|
||||
|
||||
@Test
|
||||
void sourceSetCollectionsTest() {
|
||||
var args = new SourceSet()
|
||||
.classpath(List.of("path1", "path2"))
|
||||
.classpath(List.of(new File("path1"), new File("path2")))
|
||||
.dependentSourceSets(Map.of("set1", "set2", "set3", "set4"))
|
||||
.externalDocumentationLinks(Map.of("link1", "link2", "link3", "link4"))
|
||||
.perPackageOptions(List.of("option1", "option2"))
|
||||
.samples(List.of("samples1", "samples1"))
|
||||
.suppressedFiles(List.of("sup1", "sup2"))
|
||||
.samples(List.of(new File(SAMPLES_1)))
|
||||
.samples(new File(SAMPLES_2))
|
||||
.samples("samples3")
|
||||
.suppressedFiles(List.of(new File(SUP_1)))
|
||||
.suppressedFiles(new File(SUP_2))
|
||||
.suppressedFiles("sup3")
|
||||
.args();
|
||||
|
||||
var matches = List.of(
|
||||
"-classpath", "path1;path2",
|
||||
"-classpath", localPath("path1", "path2"),
|
||||
"-dependentSourceSets", "set1/set2;set3/set4",
|
||||
"-externalDocumentationLinks", "link3^link4^^link1^link2",
|
||||
"-perPackageOptions", "option1;option2",
|
||||
"-samples", "samples1;samples1",
|
||||
"-suppressedFiles", "sup1;sup2"
|
||||
"-samples", localPath(SAMPLES_1, SAMPLES_2, "samples3"),
|
||||
"-suppressedFiles", localPath(SUP_1, SUP_2, "sup3")
|
||||
);
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
|
@ -66,13 +74,17 @@ class SourceSetTest {
|
|||
var sourceSet = new SourceSet()
|
||||
.analysisPlatform(AnalysisPlatform.JVM)
|
||||
.apiVersion("1.0")
|
||||
.classpath("classpath1", "classpath2")
|
||||
.classpath("classpath1")
|
||||
.classpath(new File("classpath2"))
|
||||
.dependentSourceSets("moduleName", "sourceSetName")
|
||||
.dependentSourceSets("moduleName2", "sourceSetName2")
|
||||
.displayName("name")
|
||||
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
||||
.externalDocumentationLinks("url1", "packageListUrl1")
|
||||
.externalDocumentationLinks("url2", "packageListUrl2")
|
||||
.includes("includes1", "includes2")
|
||||
.includes(new File("includes3"))
|
||||
.includes(List.of(new File("includes4")))
|
||||
.jdkVersion(18)
|
||||
.languageVersion("2.0")
|
||||
.noJdkLink(true)
|
||||
|
@ -80,13 +92,26 @@ class SourceSetTest {
|
|||
.noStdlibLink(true)
|
||||
.perPackageOptions("options1", "options2")
|
||||
.reportUndocumented(true)
|
||||
.samples("samples1", "sample2")
|
||||
.samples(SAMPLES_1, SAMPLES_2)
|
||||
.skipDeprecated(true)
|
||||
.sourceSetName("setName")
|
||||
.src("src1", "src2")
|
||||
.src(new File("src3"))
|
||||
.src(List.of(new File("src4")))
|
||||
.srcLink("path1", "remote1", "#suffix1")
|
||||
.srcLink("path2", "remote2", "#suffix2")
|
||||
.suppressedFiles("sup1", "sup2");
|
||||
.srcLink(new File("path2"), "remote2", "#suffix2")
|
||||
.suppressedFiles(SUP_1, SUP_2);
|
||||
|
||||
assertThat(sourceSet.classpath()).as("classpath").hasSize(2);
|
||||
assertThat(sourceSet.dependentSourceSets()).as("dependentSourceSets").hasSize(2);
|
||||
assertThat(sourceSet.documentedVisibilities()).as("documentedVisibilities").hasSize(2);
|
||||
assertThat(sourceSet.externalDocumentationLinks()).as("externalDocumentationLinks").hasSize(2);
|
||||
assertThat(sourceSet.includes()).as("includes").hasSize(4);
|
||||
assertThat(sourceSet.perPackageOptions()).as("perPackageOptions").hasSize(2);
|
||||
assertThat(sourceSet.samples()).as("samples").hasSize(2);
|
||||
assertThat(sourceSet.src()).as("src").hasSize(4);
|
||||
assertThat(sourceSet.srcLinks()).as("srcLinks").hasSize(2);
|
||||
assertThat(sourceSet.suppressedFiles()).as("suppressedFiles").hasSize(2);
|
||||
|
||||
var params = sourceSet.args();
|
||||
|
||||
|
@ -104,31 +129,31 @@ class SourceSetTest {
|
|||
var matches = List.of(
|
||||
"-analysisPlatform", "jvm",
|
||||
"-apiVersion", "1.0",
|
||||
"-classpath", "classpath1;classpath2",
|
||||
"-dependentSourceSets", "moduleName/sourceSetName",
|
||||
"-classpath", localPath("classpath1", "classpath2"),
|
||||
"-dependentSourceSets", "moduleName/sourceSetName;moduleName2/sourceSetName2",
|
||||
"-displayName", "name",
|
||||
"-documentedVisibilities", "package;private",
|
||||
"-externalDocumentationLinks", "url1^packageListUrl1^^url2^packageListUrl2",
|
||||
"-jdkVersion", "18",
|
||||
"-includes", "includes1;includes2",
|
||||
"-includes", localPath("includes1", "includes2", "includes3", "includes4"),
|
||||
"-languageVersion", "2.0",
|
||||
"-noJdkLink", "true",
|
||||
"-noSkipEmptyPackages", "true",
|
||||
"-noStdlibLink", "true",
|
||||
"-reportUndocumented", "true",
|
||||
"-perPackageOptions", "options1;options2",
|
||||
"-samples", "samples1;sample2",
|
||||
"-samples", localPath(SAMPLES_1, SAMPLES_2),
|
||||
"-skipDeprecated", "true",
|
||||
"-src", "src1;src2",
|
||||
"-srcLink", "path1=remote1#suffix1;path2=remote2#suffix2",
|
||||
"-src", localPath("src1", "src2", "src3", "src4"),
|
||||
"-srcLink", localPath("path2") + "=remote2#suffix2;path1=remote1#suffix1",
|
||||
"-sourceSetName", "setName",
|
||||
"-suppressedFiles", "sup1;sup2");
|
||||
"-suppressedFiles", localPath(SUP_1, SUP_2));
|
||||
|
||||
assertThat(params).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
||||
|
||||
sourceSet.classpath(List.of("classpath1", "classpath2"));
|
||||
sourceSet.classpath(List.of(new File("classpath1"), new File("classpath2")));
|
||||
|
||||
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue