Added tests for Dokka
This commit is contained in:
parent
c58145117a
commit
ffc9ab4bf8
4 changed files with 202 additions and 10 deletions
|
@ -32,6 +32,7 @@ import java.util.logging.Logger;
|
||||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
|
||||||
public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||||
private final Logger LOGGER = Logger.getLogger(DokkaOperation.class.getName());
|
private final Logger LOGGER = Logger.getLogger(DokkaOperation.class.getName());
|
||||||
private final Map<String, String> globalLinks_ = new ConcurrentHashMap<>();
|
private final Map<String, String> globalLinks_ = new ConcurrentHashMap<>();
|
||||||
|
@ -107,10 +108,8 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||||
|
|
||||||
// -outputDir
|
// -outputDir
|
||||||
if (outputDir_ != null) {
|
if (outputDir_ != null) {
|
||||||
if (!outputDir_.exists()) {
|
if (!outputDir_.exists() && !outputDir_.mkdirs()) {
|
||||||
if (!outputDir_.mkdirs()) {
|
throw new RuntimeException("Could not create: " + outputDir_.getAbsolutePath());
|
||||||
throw new RuntimeException("Could not create: " + outputDir_.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
args.add("-outputDir");
|
args.add("-outputDir");
|
||||||
|
@ -244,10 +243,8 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||||
var files = directory.listFiles();
|
var files = directory.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (var f : files) {
|
for (var f : files) {
|
||||||
if (!f.getName().contains("-sources")) {
|
if (!f.getName().contains("-sources") && f.getName().matches(regex)) {
|
||||||
if (f.getName().matches(regex)) {
|
jars.add(f.getAbsolutePath());
|
||||||
jars.add(f.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ public class SourceSet {
|
||||||
|
|
||||||
// -sourceSetName
|
// -sourceSetName
|
||||||
if (sourceSetName_ != null) {
|
if (sourceSetName_ != null) {
|
||||||
args.add("sourceSetName");
|
args.add("-sourceSetName");
|
||||||
args.add(sourceSetName_);
|
args.add(sourceSetName_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ public class SourceSet {
|
||||||
* @param files the list of files
|
* @param files the list of files
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public SourceSet includss(Collection<String> files) {
|
public SourceSet includes(Collection<String> files) {
|
||||||
includes_.addAll(files);
|
includes_.addAll(files);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 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.dokka;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import rife.bld.blueprints.BaseProjectBlueprint;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class DokkaOperationTest {
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings({"ExtractMethodRecommender", "PMD.AvoidDuplicateLiterals"})
|
||||||
|
void executeConstructProcessCommandListTest() {
|
||||||
|
var examples = new File("examples");
|
||||||
|
var args = new DokkaOperation()
|
||||||
|
.fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
|
||||||
|
.globalLinks("s", "link")
|
||||||
|
.globalLinks(Map.of("s2", "link2"))
|
||||||
|
.globalPackageOptions("option1", "option2")
|
||||||
|
.globalPackageOptions(List.of("option3", "option4"))
|
||||||
|
.globalSrcLink("link1", "link2")
|
||||||
|
.globalSrcLink(List.of("link3", "link4"))
|
||||||
|
.includes("file1", "file2")
|
||||||
|
.pluginConfiguration("name", "\"json\"")
|
||||||
|
.pluginConfiguration(Map.of("\"name2\"", "json2"))
|
||||||
|
.pluginClassPath("path1", "path2")
|
||||||
|
.pluginClassPath(List.of("path3", "path4"))
|
||||||
|
.delayTemplateSubstitution(true)
|
||||||
|
.failOnWarning(true)
|
||||||
|
.loggingLevel(LoggingLevel.DEBUG)
|
||||||
|
.moduleName("name")
|
||||||
|
.moduleVersion("1.0")
|
||||||
|
.noSuppressObviousFunctions(true)
|
||||||
|
.offlineMode(true)
|
||||||
|
.outputDir(new File(examples, "build"))
|
||||||
|
.suppressInheritedMembers(true)
|
||||||
|
.executeConstructProcessCommandList();
|
||||||
|
|
||||||
|
var path = examples.getAbsolutePath();
|
||||||
|
var matches = List.of("java",
|
||||||
|
"-jar", path + "/lib/bld/dokka-cli-1.9.10.jar",
|
||||||
|
"-pluginsClasspath", path + "/lib/bld/dokka-base-1.9.10.jar;" +
|
||||||
|
path + "/lib/bld/analysis-kotlin-descriptors-1.9.10.jar;" +
|
||||||
|
path + "/lib/bld/korte-jvm-2.7.0.jar;" +
|
||||||
|
path + "/lib/bld/javadoc-plugin-1.9.10.jar;" +
|
||||||
|
path + "/lib/bld/kotlin-as-java-plugin-1.9.10.jar;path1;path2;path3;path4",
|
||||||
|
"-sourceSet", "-src " + path + "/src/main/kotlin",
|
||||||
|
"-outputDir", path + "/build",
|
||||||
|
"-delayTemplateSubstitution", "true",
|
||||||
|
"-failOnWarning", "true",
|
||||||
|
"-globalLinks", "{s}^{link}^^{s2}^{link2}",
|
||||||
|
"-globalPackageOptions", "option1;option2;option3;option4",
|
||||||
|
"-globalSrcLinks_", "link1;link2;link3;link4",
|
||||||
|
"-includes", "file1;file2",
|
||||||
|
"-loggingLevel", "debug",
|
||||||
|
"-moduleName", "name",
|
||||||
|
"-moduleVersion", "1.0",
|
||||||
|
"-noSuppressObviousFunctions", "true",
|
||||||
|
"-offlineMode", "true",
|
||||||
|
"-pluginConfiguration", "{name}={\\\"json\\\"}^^{\\\"name2\\\"}={json2}",
|
||||||
|
"-suppressInheritedMembers", "true");
|
||||||
|
|
||||||
|
assertThat(args).hasSize(matches.size());
|
||||||
|
|
||||||
|
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||||
|
}
|
||||||
|
}
|
109
src/test/java/rife/bld/extension/dokka/SourceSetTest.java
Normal file
109
src/test/java/rife/bld/extension/dokka/SourceSetTest.java
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023 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.dokka;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class SourceSetTest {
|
||||||
|
@Test
|
||||||
|
void sourceSetCollectionsTest() {
|
||||||
|
var args = new SourceSet()
|
||||||
|
.classpath(List.of("path1", "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"))
|
||||||
|
.args();
|
||||||
|
|
||||||
|
var matches = List.of(
|
||||||
|
"-classpath", "path1;path2",
|
||||||
|
"-dependentSourceSets", "set1/set2;set3/set4",
|
||||||
|
"-externalDocumentationLinks", "{link3}^{link4}^^{link1}^{link2}",
|
||||||
|
"-perPackageOptions", "option1;option2",
|
||||||
|
"-samples", "samples1;samples1",
|
||||||
|
"-suppressedFiles", "sup1;sup2"
|
||||||
|
);
|
||||||
|
|
||||||
|
assertThat(args).hasSize(matches.size());
|
||||||
|
|
||||||
|
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
|
void sourceSetTest() {
|
||||||
|
var args = new SourceSet()
|
||||||
|
.classpath("classpath1", "classpath2")
|
||||||
|
.dependentSourceSets("moduleName", "sourceSetName")
|
||||||
|
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
||||||
|
.externalDocumentationLinks("url1", "packageListUrl1")
|
||||||
|
.externalDocumentationLinks("url2", "packageListUrl2")
|
||||||
|
.includes("includes1", "includes2")
|
||||||
|
.perPackageOptions("options1", "options2")
|
||||||
|
.samples("samples1", "sample2")
|
||||||
|
.srcLinks("path1", "remote1", "suffix1")
|
||||||
|
.srcLinks("path2", "remote2", "suffix2")
|
||||||
|
.src("src1", "src2")
|
||||||
|
.suppressedFiles("sup1", "sup2")
|
||||||
|
.analysisPlatform(AnalysisPlatform.JVM)
|
||||||
|
.apiVersion("1.0")
|
||||||
|
.displayName("name")
|
||||||
|
.jdkVersion(18)
|
||||||
|
.languageVersion("2.0")
|
||||||
|
.noJdkLink(true)
|
||||||
|
.noSkipEmptyPackages(true)
|
||||||
|
.noStdlibLink(true)
|
||||||
|
.reportUndocumented(true)
|
||||||
|
.skipDeprecated(true)
|
||||||
|
.sourceSetName("setName")
|
||||||
|
.args();
|
||||||
|
|
||||||
|
var matches = List.of(
|
||||||
|
"-analysisPlatform", "jvm",
|
||||||
|
"-apiVersion", "1.0",
|
||||||
|
"-classpath", "classpath1;classpath2",
|
||||||
|
"-dependentSourceSets", "moduleName/sourceSetName",
|
||||||
|
"-displayName", "name",
|
||||||
|
"-documentedVisibilities", "package;private",
|
||||||
|
"-externalDocumentationLinks", "{url1}^{packageListUrl1}^^{url2}^{packageListUrl2}",
|
||||||
|
"-jdkVersion", "18",
|
||||||
|
"-includes", "includes1;includes2",
|
||||||
|
"-languageVersion", "2.0",
|
||||||
|
"-noJdkLink", "true",
|
||||||
|
"-noSkipEmptyPackages", "true",
|
||||||
|
"-noStdlibLink", "true",
|
||||||
|
"-reportUndocumented", "true",
|
||||||
|
"-perPackageOptions", "options1;options2",
|
||||||
|
"-samples", "samples1;sample2",
|
||||||
|
"-skipDeprecated", "true",
|
||||||
|
"-src", "src1;src2",
|
||||||
|
"-srcLinks", "{path1}={remote1#suffix1};{path2}={remote2#suffix2}",
|
||||||
|
"-sourceSetName", "setName",
|
||||||
|
"-suppressedFiles", "sup1;sup2");
|
||||||
|
|
||||||
|
assertThat(args).hasSize(matches.size());
|
||||||
|
|
||||||
|
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue