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/projects/it-maven/pom.xml | 170 +++++++++++++++++++++ .../main/java/it/basic/java/SampleJavaClass.java | 22 +++ .../src/main/kotlin/it/basic/PublicClass.kt | 48 ++++++ 3 files changed, 240 insertions(+) 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 (limited to 'integration-tests/maven/projects/it-maven') 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 +} -- 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/projects/it-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 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/projects/it-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