From caf48e76f3bff5e9907cd094cf0719f623e528d5 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 8 Jul 2020 10:47:05 +0200 Subject: Implement simple MavenIntegrationTest.kt --- integration-tests/maven/build.gradle.kts | 17 +++ integration-tests/maven/projects/it-maven/pom.xml | 170 +++++++++++++++++++++ .../main/java/it/basic/java/SampleJavaClass.java | 22 +++ .../src/main/kotlin/it/basic/PublicClass.kt | 48 ++++++ .../dokka/it/maven/MavenIntegrationTest.kt | 78 ++++++++++ 5 files changed, 335 insertions(+) create mode 100644 integration-tests/maven/build.gradle.kts create mode 100644 integration-tests/maven/projects/it-maven/pom.xml create mode 100644 integration-tests/maven/projects/it-maven/src/main/java/it/basic/java/SampleJavaClass.java create mode 100644 integration-tests/maven/projects/it-maven/src/main/kotlin/it/basic/PublicClass.kt create mode 100644 integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt (limited to 'integration-tests/maven') diff --git a/integration-tests/maven/build.gradle.kts b/integration-tests/maven/build.gradle.kts new file mode 100644 index 00000000..b0187b13 --- /dev/null +++ b/integration-tests/maven/build.gradle.kts @@ -0,0 +1,17 @@ +import org.jetbrains.dependsOnMavenLocalPublication + +evaluationDependsOn(":runners:maven-plugin") + +dependencies { + implementation(kotlin("stdlib")) + implementation(kotlin("test-junit")) +} + +tasks.integrationTest { + dependsOnMavenLocalPublication() + dependsOn(":runners:maven-plugin:setupMaven") + + val dokka_version: String by project + environment("DOKKA_VERSION", dokka_version) + environment("MVN_BINARY_PATH", project(":runners:maven-plugin").extra["MVN_BINARY_PATH"].toString()) +} diff --git a/integration-tests/maven/projects/it-maven/pom.xml b/integration-tests/maven/projects/it-maven/pom.xml new file mode 100644 index 00000000..47bd633c --- /dev/null +++ b/integration-tests/maven/projects/it-maven/pom.xml @@ -0,0 +1,170 @@ + + 4.0.0 + + org.jetbrains.dokka + it-maven + 1.0-SNAPSHOT + + + 1.3.72 + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + org.jetbrains.dokka + dokka-maven-plugin + $dokka_version + + + pre-site + + dokka + + + + + + + false + + + Maven Integration Test Module + + + html + + ${project.basedir}/output + + + + default + + + + 8 + + + false + + true + + true + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + false + + + false + + + + + + kotlin + + + false + + true + false + + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + + + kotlin-dev + https://dl.bintray.com/kotlin/kotlin-dev/ + + + jcenter + JCenter + https://jcenter.bintray.com/ + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + + diff --git a/integration-tests/maven/projects/it-maven/src/main/java/it/basic/java/SampleJavaClass.java b/integration-tests/maven/projects/it-maven/src/main/java/it/basic/java/SampleJavaClass.java new file mode 100644 index 00000000..e08bb66a --- /dev/null +++ b/integration-tests/maven/projects/it-maven/src/main/java/it/basic/java/SampleJavaClass.java @@ -0,0 +1,22 @@ +package it.basic.java; + +import it.basic.PublicClass; + +/** + * This class is, unlike {@link PublicClass}, written in Java + */ +@SuppressWarnings("unused") +public class SampleJavaClass { + + /** + * @return Empty instance of {@link PublicClass} + */ + public PublicClass publicDocumentedFunction() { + return new PublicClass(); + } + + + public PublicClass publicUndocumentedFunction() { + return new PublicClass(); + } +} diff --git a/integration-tests/maven/projects/it-maven/src/main/kotlin/it/basic/PublicClass.kt b/integration-tests/maven/projects/it-maven/src/main/kotlin/it/basic/PublicClass.kt new file mode 100644 index 00000000..71bc7e63 --- /dev/null +++ b/integration-tests/maven/projects/it-maven/src/main/kotlin/it/basic/PublicClass.kt @@ -0,0 +1,48 @@ +@file:Suppress("unused") + +package it.basic + +class PublicClass { + /** + * This function is public and documented + */ + fun publicDocumentedFunction(): String = "" + + fun publicUndocumentedFunction(): String = "" + + /** + * This function is internal and documented + */ + internal fun internalDocumentedFunction(): String = "" + + internal fun internalUndocumentedFunction(): String = "" + + /** + * This function is private and documented + */ + private fun privateDocumentedFunction(): String = "" + + private fun privateUndocumentedFunction(): String = "" + + + /** + * This property is public and documented + */ + val publicDocumentedProperty: Int = 0 + + val publicUndocumentedProperty: Int = 0 + + /** + * This property internal and documented + */ + val internalDocumentedProperty: Int = 0 + + val internalUndocumentedProperty: Int = 0 + + /** + * This property private and documented + */ + private val privateDocumentedProperty: Int = 0 + + private val privateUndocumentedProperty: Int = 0 +} diff --git a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt new file mode 100644 index 00000000..e52debf4 --- /dev/null +++ b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt @@ -0,0 +1,78 @@ +package org.jetbrains.dokka.it.maven + +import org.jetbrains.dokka.it.AbstractIntegrationTest +import org.jetbrains.dokka.it.awaitProcessResult +import java.io.File +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class MavenIntegrationTest : AbstractIntegrationTest() { + + val currentDokkaVersion: String = checkNotNull(System.getenv("DOKKA_VERSION")) + + val mavenBinaryFile: File = File(checkNotNull(System.getenv("MVN_BINARY_PATH"))) + + @BeforeTest + fun prepareProjectFiles() { + val templateProjectDir = File("projects", "it-maven") + templateProjectDir.copyRecursively(projectDir) + val pomXml = File(projectDir, "pom.xml") + assertTrue(pomXml.isFile) + pomXml.apply { + writeText(readText().replace("\$dokka_version", currentDokkaVersion)) + } + } + + @Test + fun run() { + val result = ProcessBuilder().directory(projectDir) + .command(mavenBinaryFile.absolutePath, "dokka:dokka", "-U", "-e").start().awaitProcessResult() + + assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)") + + val extensionLoadedRegex = Regex("""Extension: org\.jetbrains\.dokka\.base\.DokkaBase""") + val amountOfExtensionsLoaded = extensionLoadedRegex.findAll(result.output).count() + + assertTrue( + amountOfExtensionsLoaded > 10, + "Expected more than 10 extensions being present (found $amountOfExtensionsLoaded)" + ) + + val undocumentedReportRegex = Regex("""Undocumented:""") + val amountOfUndocumentedReports = undocumentedReportRegex.findAll(result.output).count() + assertTrue( + amountOfUndocumentedReports > 0, + "Expected at least one report of undocumented code (found $amountOfUndocumentedReports)" + ) + + val undocumentedJavaReportRegex = Regex("""Undocumented: it\.basic\.java""") + val amountOfUndocumentedJavaReports = undocumentedJavaReportRegex.findAll(result.output).count() + assertTrue( + amountOfUndocumentedJavaReports > 0, + "Expected at least one report of undocumented java code (found $amountOfUndocumentedJavaReports)" + ) + + val dokkaOutputDir = File(projectDir, "output") + assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory") + + val imagesDir = File(dokkaOutputDir, "images") + assertTrue(imagesDir.isDirectory, "Missing images directory") + + val scriptsDir = File(dokkaOutputDir, "scripts") + assertTrue(scriptsDir.isDirectory, "Missing scripts directory") + + val stylesDir = File(dokkaOutputDir, "styles") + assertTrue(stylesDir.isDirectory, "Missing styles directory") + + val navigationHtml = File(dokkaOutputDir, "navigation.html") + assertTrue(navigationHtml.isFile, "Missing navigation.html") + + projectDir.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) + assertNoUnresolvedLInks(file) + } + + } +} -- cgit From 4f9e180a1f9e9e0432bf1aed379c024736623d12 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 8 Jul 2020 12:15:30 +0200 Subject: Implement SetupMaven task --- .../src/main/kotlin/org/jetbrains/SetupMaven.kt | 49 +++++++++++++++++ integration-tests/maven/build.gradle.kts | 7 ++- runners/maven-plugin/build.gradle.kts | 63 ++++++++-------------- 3 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt (limited to 'integration-tests/maven') diff --git a/buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt b/buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt new file mode 100644 index 00000000..519eea13 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/SetupMaven.kt @@ -0,0 +1,49 @@ +package org.jetbrains + +import org.gradle.api.DefaultTask +import org.gradle.api.artifacts.Configuration +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.Sync +import org.gradle.kotlin.dsl.creating +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.getValue +import java.io.File + +@Suppress("LeakingThis") +open class SetupMaven : Sync() { + @get:Input + var mavenVersion = "3.5.0" + + @get:Input + var mavenPluginToolsVersion = "3.5.2" + + @get:Input + var aetherVersion = "1.1.0" + + @get:Internal + val mavenBuildDir = "${project.buildDir}/maven" + + @get:Internal + val mavenBinDir = "${project.buildDir}/maven-bin" + + @get:Internal + val mvn = File(mavenBinDir, "apache-maven-$mavenVersion/bin/mvn") + + private val mavenBinaryConfiguration: Configuration by project.configurations.creating { + project.dependencies { + this@creating.invoke( + group = "org.apache.maven", + name = "apache-maven", + version = mavenVersion, + classifier = "bin", ext = "zip" + ) + } + } + + init { + from(mavenBinaryConfiguration.map { file -> project.zipTree(file) }) + into(mavenBinDir) + } + +} diff --git a/integration-tests/maven/build.gradle.kts b/integration-tests/maven/build.gradle.kts index b0187b13..1c747bbc 100644 --- a/integration-tests/maven/build.gradle.kts +++ b/integration-tests/maven/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.SetupMaven import org.jetbrains.dependsOnMavenLocalPublication evaluationDependsOn(":runners:maven-plugin") @@ -9,9 +10,11 @@ dependencies { tasks.integrationTest { dependsOnMavenLocalPublication() - dependsOn(":runners:maven-plugin:setupMaven") + + val setupMavenTask = project(":runners:maven-plugin").tasks.withType().single() + dependsOn(setupMavenTask) val dokka_version: String by project environment("DOKKA_VERSION", dokka_version) - environment("MVN_BINARY_PATH", project(":runners:maven-plugin").extra["MVN_BINARY_PATH"].toString()) + environment("MVN_BINARY_PATH", setupMavenTask.mvn.absolutePath) } diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts index 8e412b43..6214da6d 100644 --- a/runners/maven-plugin/build.gradle.kts +++ b/runners/maven-plugin/build.gradle.kts @@ -1,48 +1,29 @@ import org.jetbrains.configureBintrayPublication import org.jetbrains.CrossPlatformExec +import org.jetbrains.SetupMaven -/** - * [mavenBin] configuration is used to download Maven Plugin Plugin - * for generating plugin-help.xml and plugin.xml files - */ -val mavenBin: Configuration by configurations.creating -val mavenVersion = "3.5.0" -val mavenPluginToolsVersion = "3.5.2" -val aetherVersion = "1.1.0" +val setupMaven by tasks.register("setupMaven") dependencies { implementation(project(":core")) - implementation("org.apache.maven:maven-core:$mavenVersion") - implementation("org.apache.maven:maven-plugin-api:$mavenVersion") - implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:$mavenPluginToolsVersion") + implementation("org.apache.maven:maven-core:${setupMaven.mavenVersion}") + implementation("org.apache.maven:maven-plugin-api:${setupMaven.mavenVersion}") + implementation("org.apache.maven.plugin-tools:maven-plugin-annotations:${setupMaven.mavenPluginToolsVersion}") implementation("org.apache.maven:maven-archiver:2.5") implementation(kotlin("stdlib-jdk8")) - implementation("org.eclipse.aether:aether-api:${aetherVersion}") - implementation("org.eclipse.aether:aether-spi:${aetherVersion}") - implementation("org.eclipse.aether:aether-impl:${aetherVersion}") - implementation("org.eclipse.aether:aether-connector-basic:${aetherVersion}") - implementation("org.eclipse.aether:aether-transport-file:${aetherVersion}") - implementation("org.eclipse.aether:aether-transport-http:${aetherVersion}") + implementation("org.eclipse.aether:aether-api:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-spi:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-impl:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-connector-basic:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-transport-file:${setupMaven.aetherVersion}") + implementation("org.eclipse.aether:aether-transport-http:${setupMaven.aetherVersion}") implementation("org.apache.maven:maven-aether-provider:3.3.3") - mavenBin(group = "org.apache.maven", name = "apache-maven", version = mavenVersion, classifier = "bin", ext = "zip") } -val mavenBinDir = "$buildDir/maven-bin" -val mavenBuildDir = "$buildDir/maven" -val mvn = File(mavenBinDir, "apache-maven-$mavenVersion/bin/mvn") -extra.set("MVN_BINARY_PATH", mvn.absolutePath) - tasks.named("clean") { - delete(mavenBinDir) -} - -/** - * Copy Maven Plugin Plugin to [mavenBinDir] directory - */ -val setupMaven by tasks.registering(Sync::class) { - from(mavenBin.map { zipTree(it) }) - into(mavenBinDir) + delete(setupMaven.mavenBuildDir) + delete(setupMaven.mavenBinDir) } /** @@ -55,17 +36,17 @@ val generatePom by tasks.registering(Copy::class) { from("$projectDir/pom.tpl.xml") { rename("(.*).tpl.xml", "$1.xml") } - into(mavenBuildDir) + into(setupMaven.mavenBuildDir) eachFile { filter { line -> - line.replace("", "$mavenVersion") + line.replace("", "${setupMaven.mavenVersion}") } filter { line -> line.replace("dokka_version", "$dokka_version") } filter { line -> - line.replace("maven-plugin-plugin", "$mavenPluginToolsVersion") + line.replace("maven-plugin-plugin", "${setupMaven.mavenPluginToolsVersion}") } } } @@ -76,7 +57,7 @@ val generatePom by tasks.registering(Copy::class) { val syncClasses by tasks.registering(Sync::class) { dependsOn(tasks.compileKotlin, tasks.compileJava) from("$buildDir/classes/kotlin", "$buildDir/classes/java") - into("$mavenBuildDir/classes/java") + into("${setupMaven.mavenBuildDir}/classes/java") preserve { include("**/*.class") @@ -85,14 +66,14 @@ val syncClasses by tasks.registering(Sync::class) { val helpMojo by tasks.registering(CrossPlatformExec::class) { dependsOn(setupMaven, generatePom, syncClasses) - workingDir(mavenBuildDir) - commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo") + workingDir(setupMaven.mavenBuildDir) + commandLine(setupMaven.mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:helpmojo") } val pluginDescriptor by tasks.registering(CrossPlatformExec::class) { dependsOn(setupMaven, generatePom, syncClasses) - workingDir(mavenBuildDir) - commandLine(mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:descriptor") + workingDir(setupMaven.mavenBuildDir) + commandLine(setupMaven.mvn, "-e", "-B", "org.apache.maven.plugins:maven-plugin-plugin:descriptor") } val sourceJar by tasks.registering(Jar::class) { @@ -103,7 +84,7 @@ val sourceJar by tasks.registering(Jar::class) { tasks.named("jar") { dependsOn(pluginDescriptor, helpMojo) metaInf { - from("$mavenBuildDir/classes/java/main/META-INF") + from("${setupMaven.mavenBuildDir}/classes/java/main/META-INF") } manifest { attributes("Class-Path" to configurations.runtimeClasspath.get().files.joinToString(" ") { it.name }) -- cgit From e9b3fead277bdbf0aced2801812cd22c3b8fd625 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Fri, 10 Jul 2020 13:50:01 +0200 Subject: Fix first integration tests --- .../dokka/it/gradle/MultiModule0IntegrationTest.kt | 42 --------------- .../dokka/it/gradle/Multimodule0IntegrationTest.kt | 61 ++++++++++++++++++++++ .../gradle/Multiplatform0GradleIntegrationTest.kt | 6 +-- integration-tests/maven/projects/it-maven/pom.xml | 2 - .../jetbrains/dokka/it/AbstractIntegrationTest.kt | 12 +++-- 5 files changed, 72 insertions(+), 51 deletions(-) delete mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt create mode 100644 integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt (limited to 'integration-tests/maven') diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt deleted file mode 100644 index e4f8b189..00000000 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/MultiModule0IntegrationTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package org.jetbrains.dokka.it.gradle - -import org.gradle.testkit.runner.TaskOutcome -import org.junit.runners.Parameterized -import java.io.File -import kotlin.test.* - -class MultiModule0IntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() { - companion object { - @get:JvmStatic - @get:Parameterized.Parameters(name = "{0}") - val versions = BuildVersions.permutations( - gradleVersions = listOf("6.5.1", "6.1.1"), - kotlinVersions = listOf("1.4-M2-eap-70") - ) - } - - @BeforeTest - fun prepareProjectFiles() { - val templateProjectDir = File("projects", "it-multimodule-0") - templateProjectDir.listFiles().orEmpty() - .filter { it.isFile } - .forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) } - File(templateProjectDir, "moduleA").copyRecursively(File(projectDir, "moduleA")) - } - - @Test - fun execute() { - val result = createGradleRunner("dokkaKdoc", ":moduleA:dokkaKdocMultimodule", "--stacktrace").build() - - assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":moduleA:dokkaKdocMultimodule")).outcome) - - val dokkaOutputDir = File(projectDir, "moduleA/build/dokka/kdocMultimodule") - assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory") - - dokkaOutputDir.allHtmlFiles().forEach { file -> - assertContainsNoErrorClass(file) - assertNoUnresolvedLInks(file) - assertNoHrefToMissingLocalFileOrDirectory(file) - } - } -} diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt new file mode 100644 index 00000000..75ef547a --- /dev/null +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt @@ -0,0 +1,61 @@ +package org.jetbrains.dokka.it.gradle + +import org.gradle.testkit.runner.TaskOutcome +import org.junit.runners.Parameterized +import java.io.File +import kotlin.test.* + +class Multimodule0IntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() { + companion object { + @get:JvmStatic + @get:Parameterized.Parameters(name = "{0}") + val versions = BuildVersions.permutations( + gradleVersions = listOf("6.5.1", "6.1.1"), + kotlinVersions = listOf("1.4-M2-eap-70") + ) + } + + @BeforeTest + fun prepareProjectFiles() { + val templateProjectDir = File("projects", "it-multimodule-0") + templateProjectDir.listFiles().orEmpty() + .filter { it.isFile } + .forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) } + File(templateProjectDir, "moduleA").copyRecursively(File(projectDir, "moduleA")) + } + + @Test + fun execute() { + val result = createGradleRunner("dokkaKdoc", ":moduleA:dokkaKdocMultimodule", "--stacktrace").build() + + assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":moduleA:dokkaKdocMultimodule")).outcome) + + val outputDir = File(projectDir, "moduleA/build/dokka/kdocMultimodule") + assertTrue(outputDir.isDirectory, "Missing dokka output directory") + + assertTrue( + outputDir.allHtmlFiles().any(), + "Expected at least one html file being generated" + ) + + outputDir.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) + assertNoUnresolvedLInks(file) + assertNoHrefToMissingLocalFileOrDirectory(file) + } + + val modulesFile = File(outputDir, "-modules.html") + assertTrue(modulesFile.isFile, "Missing -modules.html file") + + val modulesFileText = modulesFile.readText() + assertTrue( + "moduleB" in modulesFileText, + "Expected moduleB being mentioned in -modules.html" + ) + assertTrue( + "moduleC" in modulesFileText, + "Expected moduleC being mentioned in -modules.html" + ) + + } +} diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt index 491f5610..8fa1d3de 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt @@ -27,11 +27,11 @@ class Multiplatform0GradleIntegrationTest(override val versions: BuildVersions) @Test fun execute() { - val result = createGradleRunner("dokka", "--stacktrace").build() + val result = createGradleRunner("dokkaKdoc", "--stacktrace").build() - assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokka")).outcome) + assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaKdoc")).outcome) - val dokkaOutputDir = File(projectDir, "build/dokka") + val dokkaOutputDir = File(projectDir, "build/dokka/kdoc") assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory") dokkaOutputDir.allHtmlFiles().forEach { file -> diff --git a/integration-tests/maven/projects/it-maven/pom.xml b/integration-tests/maven/projects/it-maven/pom.xml index 47bd633c..9be87779 100644 --- a/integration-tests/maven/projects/it-maven/pom.xml +++ b/integration-tests/maven/projects/it-maven/pom.xml @@ -93,8 +93,6 @@ Maven Integration Test Module - - html ${project.basedir}/output diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt index 0a83045e..aeebe552 100644 --- a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/AbstractIntegrationTest.kt @@ -45,13 +45,17 @@ abstract class AbstractIntegrationTest { val fileText = file.readText() val html = Jsoup.parse(fileText) html.allElements.toList().forEach { element -> - val href = element.attr("href") ?: return@forEach - - if (href.startsWith("#")) return@forEach + val href = (element.attr("href") ?: return@forEach) if (href.startsWith("https")) return@forEach if (href.startsWith("http")) return@forEach - val targetFile = File(file.parent, href) + val hrefWithoutAnchors = if (href.contains("#")) { + val hrefSplits = href.split("#") + if (hrefSplits.count() != 2) return@forEach + hrefSplits.first() + } else href + + val targetFile = File(file.parent, hrefWithoutAnchors) if (targetFile.extension.isNotEmpty() && targetFile.extension !in fileExtensions) return@forEach if ( -- cgit From 304b644dffac5dec74ae2e47cbb1917fab90b66a Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Fri, 10 Jul 2020 13:51:35 +0200 Subject: MavenIntegrationTest: Let all fields be private --- .../kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'integration-tests/maven') diff --git a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt index e52debf4..8690d5d6 100644 --- a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt +++ b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt @@ -10,9 +10,9 @@ import kotlin.test.assertTrue class MavenIntegrationTest : AbstractIntegrationTest() { - val currentDokkaVersion: String = checkNotNull(System.getenv("DOKKA_VERSION")) + private val currentDokkaVersion: String = checkNotNull(System.getenv("DOKKA_VERSION")) - val mavenBinaryFile: File = File(checkNotNull(System.getenv("MVN_BINARY_PATH"))) + private val mavenBinaryFile: File = File(checkNotNull(System.getenv("MVN_BINARY_PATH"))) @BeforeTest fun prepareProjectFiles() { -- cgit From 34e696f92aaa3802f13a0074003bc8957218aeba Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Tue, 14 Jul 2020 11:36:47 +0200 Subject: Refactor and add integration tests --- .../dokka/it/maven/MavenIntegrationTest.kt | 98 +++++++++++++++++----- runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 15 ++-- 2 files changed, 82 insertions(+), 31 deletions(-) (limited to 'integration-tests/maven') diff --git a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt index 8690d5d6..86cc2f41 100644 --- a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt +++ b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt @@ -2,6 +2,7 @@ package org.jetbrains.dokka.it.maven import org.jetbrains.dokka.it.AbstractIntegrationTest import org.jetbrains.dokka.it.awaitProcessResult +import org.jetbrains.dokka.it.ProcessResult import java.io.File import kotlin.test.BeforeTest import kotlin.test.Test @@ -26,10 +27,84 @@ class MavenIntegrationTest : AbstractIntegrationTest() { } @Test - fun run() { + fun `dokka dokka`() { val result = ProcessBuilder().directory(projectDir) .command(mavenBinaryFile.absolutePath, "dokka:dokka", "-U", "-e").start().awaitProcessResult() + diagnosticAsserts(result) + + val dokkaOutputDir = File(projectDir, "output") + assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory") + + val imagesDir = File(dokkaOutputDir, "images") + assertTrue(imagesDir.isDirectory, "Missing images directory") + + val scriptsDir = File(dokkaOutputDir, "scripts") + assertTrue(scriptsDir.isDirectory, "Missing scripts directory") + + val stylesDir = File(dokkaOutputDir, "styles") + assertTrue(stylesDir.isDirectory, "Missing styles directory") + + val navigationHtml = File(dokkaOutputDir, "navigation.html") + assertTrue(navigationHtml.isFile, "Missing navigation.html") + + projectDir.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) + assertNoUnresolvedLInks(file) + } + } + + @Test + fun `dokka javadoc`() { + val result = ProcessBuilder().directory(projectDir) + .command(mavenBinaryFile.absolutePath, "dokka:javadoc", "-U", "-e").start().awaitProcessResult() + + diagnosticAsserts(result) + + val dokkaOutputDir = File(projectDir, "output") + assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory") + + val scriptsDir = File(dokkaOutputDir, "jquery") + assertTrue(scriptsDir.isDirectory, "Missing jquery directory") + + val stylesDir = File(dokkaOutputDir, "resources") + assertTrue(stylesDir.isDirectory, "Missing resources directory") + + projectDir.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) + assertNoUnresolvedLInks(file) + } + } + + @Test + fun `dokka javadocJar`() { + val result = ProcessBuilder().directory(projectDir) + .command(mavenBinaryFile.absolutePath, "dokka:javadocJar", "-U", "-e").start().awaitProcessResult() + + diagnosticAsserts(result) + + val dokkaOutputDir = File(projectDir, "output") + assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory") + + val scriptsDir = File(dokkaOutputDir, "jquery") + assertTrue(scriptsDir.isDirectory, "Missing jquery directory") + + val stylesDir = File(dokkaOutputDir, "resources") + assertTrue(stylesDir.isDirectory, "Missing resources directory") + + val dokkaTargetDir = File(projectDir, "target") + assertTrue(dokkaOutputDir.isDirectory, "Missing dokka target directory") + + val jarFile = File(dokkaTargetDir, "it-maven-1.0-SNAPSHOT-javadoc.jar") + assertTrue(jarFile.isFile, "Missing dokka jar file") + + projectDir.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) + assertNoUnresolvedLInks(file) + } + } + + private fun diagnosticAsserts(result: ProcessResult) { assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)") val extensionLoadedRegex = Regex("""Extension: org\.jetbrains\.dokka\.base\.DokkaBase""") @@ -53,26 +128,5 @@ class MavenIntegrationTest : AbstractIntegrationTest() { amountOfUndocumentedJavaReports > 0, "Expected at least one report of undocumented java code (found $amountOfUndocumentedJavaReports)" ) - - val dokkaOutputDir = File(projectDir, "output") - assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory") - - val imagesDir = File(dokkaOutputDir, "images") - assertTrue(imagesDir.isDirectory, "Missing images directory") - - val scriptsDir = File(dokkaOutputDir, "scripts") - assertTrue(scriptsDir.isDirectory, "Missing scripts directory") - - val stylesDir = File(dokkaOutputDir, "styles") - assertTrue(stylesDir.isDirectory, "Missing styles directory") - - val navigationHtml = File(dokkaOutputDir, "navigation.html") - assertTrue(navigationHtml.isFile, "Missing navigation.html") - - projectDir.allHtmlFiles().forEach { file -> - assertContainsNoErrorClass(file) - assertNoUnresolvedLInks(file) - } - } } diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 5b904dce..514df151 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -52,7 +52,7 @@ class ExternalDocumentationLinkBuilder : DokkaConfiguration.ExternalDocumentatio override var packageListUrl: URL? = null } -abstract class AbstractDokkaMojo : AbstractMojo() { +abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List) : AbstractMojo() { class SourceRoot : DokkaConfiguration.SourceRoot { @Parameter(required = true) override var path: String = "" @@ -166,7 +166,8 @@ abstract class AbstractDokkaMojo : AbstractMojo() { var failOnWarning: Boolean = DokkaDefaults.failOnWarning @Parameter - open var dokkaPlugins: List = emptyList() + var dokkaPlugins: List = emptyList() + get() = field + defaultDokkaPlugins protected abstract fun getOutDir(): String @@ -315,7 +316,7 @@ abstract class AbstractDokkaMojo : AbstractMojo() { requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true ) -class DokkaMojo : AbstractDokkaMojo() { +class DokkaMojo : AbstractDokkaMojo(emptyList()) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokka") var outputDir: String = "" @@ -329,12 +330,10 @@ class DokkaMojo : AbstractDokkaMojo() { requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true ) -class DokkaJavadocMojo : AbstractDokkaMojo() { +class DokkaJavadocMojo : AbstractDokkaMojo(listOf(javadocDependency)) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokkaJavadoc") var outputDir: String = "" - override var dokkaPlugins = super.dokkaPlugins + javadocDependency - override fun getOutDir() = outputDir } @@ -345,7 +344,7 @@ class DokkaJavadocMojo : AbstractDokkaMojo() { requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true ) -class DokkaJavadocJarMojo : AbstractDokkaMojo() { +class DokkaJavadocJarMojo : AbstractDokkaMojo(listOf(javadocDependency)) { @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokkaJavadocJar") var outputDir: String = "" @@ -392,8 +391,6 @@ class DokkaJavadocJarMojo : AbstractDokkaMojo() { override fun getOutDir() = outputDir - override var dokkaPlugins = super.dokkaPlugins + javadocDependency - override fun execute() { super.execute() if (!File(outputDir).exists()) { -- cgit From 17fd70cd03182abe3374ddcf49029e03b8863c96 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Fri, 17 Jul 2020 15:20:25 +0200 Subject: Add kotlin-eap repository consistently to the project --- build.gradle.kts | 1 + integration-tests/gradle/projects/template.root.gradle.kts | 1 + integration-tests/gradle/projects/template.settings.gradle.kts | 1 + integration-tests/maven/projects/it-maven/pom.xml | 4 ++++ settings.gradle.kts | 3 ++- 5 files changed, 9 insertions(+), 1 deletion(-) (limited to 'integration-tests/maven') diff --git a/build.gradle.kts b/build.gradle.kts index 0d56106c..cae9ecca 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,6 +28,7 @@ allprojects { repositories { jcenter() mavenCentral() + maven(url = "https://dl.bintray.com/kotlin/kotlin-eap") maven(url = "https://dl.bintray.com/kotlin/kotlin-dev") } } diff --git a/integration-tests/gradle/projects/template.root.gradle.kts b/integration-tests/gradle/projects/template.root.gradle.kts index de516cb0..51d199ff 100644 --- a/integration-tests/gradle/projects/template.root.gradle.kts +++ b/integration-tests/gradle/projects/template.root.gradle.kts @@ -1,5 +1,6 @@ allprojects { repositories { + maven("https://dl.bintray.com/kotlin/kotlin-eap/") maven("https://dl.bintray.com/kotlin/kotlin-dev/") jcenter() mavenLocal() diff --git a/integration-tests/gradle/projects/template.settings.gradle.kts b/integration-tests/gradle/projects/template.settings.gradle.kts index 253c4e1b..7fe3c510 100644 --- a/integration-tests/gradle/projects/template.settings.gradle.kts +++ b/integration-tests/gradle/projects/template.settings.gradle.kts @@ -26,6 +26,7 @@ pluginManagement { } } repositories { + maven("https://dl.bintray.com/kotlin/kotlin-eap") maven("https://dl.bintray.com/kotlin/kotlin-dev/") mavenLocal() mavenCentral() diff --git a/integration-tests/maven/projects/it-maven/pom.xml b/integration-tests/maven/projects/it-maven/pom.xml index 9be87779..c6e0ef45 100644 --- a/integration-tests/maven/projects/it-maven/pom.xml +++ b/integration-tests/maven/projects/it-maven/pom.xml @@ -145,6 +145,10 @@ + + kotlin-eap + https://dl.bintray.com/kotlin/kotlin-eap/ + kotlin-dev https://dl.bintray.com/kotlin/kotlin-dev/ diff --git a/settings.gradle.kts b/settings.gradle.kts index 3e6d1d8d..a9c50387 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -32,7 +32,8 @@ pluginManagement { } repositories { - maven(url = "https://dl.bintray.com/kotlin/kotlin-dev/") + maven("https://dl.bintray.com/kotlin/kotlin-eap/") + maven("https://dl.bintray.com/kotlin/kotlin-dev/") mavenCentral() jcenter() gradlePluginPortal() -- cgit