diff options
16 files changed, 378 insertions, 28 deletions
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/taskUtils.kt b/buildSrc/src/main/kotlin/org/jetbrains/taskUtils.kt new file mode 100644 index 00000000..b018ba13 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/taskUtils.kt @@ -0,0 +1,13 @@ +package org.jetbrains + +import org.gradle.api.Task + +fun Task.dependsOnMavenLocalPublication() { + project.rootProject.allprojects.forEach { otherProject -> + otherProject.invokeWhenEvaluated { evaluatedProject -> + evaluatedProject.tasks.findByName("publishToMavenLocal")?.let { publishingTask -> + this.dependsOn(publishingTask) + } + } + } +} diff --git a/integration-tests/build.gradle.kts b/integration-tests/build.gradle.kts index 70b6db26..070091a0 100644 --- a/integration-tests/build.gradle.kts +++ b/integration-tests/build.gradle.kts @@ -37,4 +37,5 @@ subprojects { dependencies { implementation(kotlin("stdlib")) implementation(kotlin("test-junit")) -} + val coroutines_version: String by project + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")} diff --git a/integration-tests/cli/build.gradle.kts b/integration-tests/cli/build.gradle.kts index 5fdf0ff5..60d3a298 100644 --- a/integration-tests/cli/build.gradle.kts +++ b/integration-tests/cli/build.gradle.kts @@ -12,10 +12,6 @@ evaluationDependsOn(":plugins:base") dependencies { implementation(kotlin("stdlib")) implementation(kotlin("test-junit")) - - val coroutines_version: String by project - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version") - } /* Create a fat base plugin jar for cli tests */ @@ -35,6 +31,7 @@ val basePluginShadowJar by tasks.register("basePluginShadowJar", ShadowJar::clas } tasks.integrationTest { + inputs.dir((file("projects"))) val cliJar = tasks.getByPath(":runners:cli:shadowJar") as ShadowJar environment("CLI_JAR_PATH", cliJar.archiveFile.get()) environment("BASE_PLUGIN_JAR_PATH", basePluginShadowJar.archiveFile.get()) diff --git a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt index 49030c73..9f83c869 100644 --- a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt +++ b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.it.cli +import org.jetbrains.dokka.it.awaitProcessResult import java.io.File import kotlin.test.BeforeTest import kotlin.test.Test diff --git a/integration-tests/gradle/build.gradle.kts b/integration-tests/gradle/build.gradle.kts index 28e20cf9..3da416bb 100644 --- a/integration-tests/gradle/build.gradle.kts +++ b/integration-tests/gradle/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.invokeWhenEvaluated +import org.jetbrains.dependsOnMavenLocalPublication dependencies { implementation(kotlin("stdlib")) @@ -8,13 +8,7 @@ dependencies { tasks.integrationTest { inputs.dir(file("projects")) - rootProject.allprojects.forEach { otherProject -> - otherProject.invokeWhenEvaluated { evaluatedProject -> - evaluatedProject.tasks.findByName("publishToMavenLocal")?.let { publishingTask -> - this.dependsOn(publishingTask) - } - } - } + dependsOnMavenLocalPublication() } tasks.clean { diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt index e08dbca5..0a29555f 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt @@ -1,6 +1,8 @@ package org.jetbrains.dokka.it.gradle import org.gradle.testkit.runner.TaskOutcome +import org.jetbrains.dokka.it.isAndroidSdkInstalled +import org.jetbrains.dokka.it.isCI import org.junit.Assume import org.junit.runners.Parameterized.Parameters import java.io.File @@ -28,20 +30,10 @@ class Android0GradleIntegrationTest(override val versions: BuildVersions) : Abst @BeforeTest fun assumeAndroidInstallation() { - val isCI = System.getenv("CI") != null if (isCI) { return } - - val androidSdkRoot = System.getenv("ANDROID_SDK_ROOT") - val androidHome = System.getenv("ANDROID_HOME") - - val isAndroidSdkInstalled = androidSdkRoot != null || androidHome != null - - Assume.assumeTrue( - "Missing ANDROID_SDK_ROOT", - isAndroidSdkInstalled - ) + Assume.assumeTrue("Missing ANDROID_SDK_ROOT", isAndroidSdkInstalled) } @BeforeTest 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 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.jetbrains.dokka</groupId> + <artifactId>it-maven</artifactId> + <version>1.0-SNAPSHOT</version> + + <properties> + <kotlin.version>1.3.72</kotlin.version> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-maven-plugin</artifactId> + <version>${kotlin.version}</version> + <executions> + <execution> + <id>compile</id> + <goals> + <goal>compile</goal> + </goals> + <configuration> + <sourceDirs> + <sourceDir>${project.basedir}/src/main/kotlin</sourceDir> + <sourceDir>${project.basedir}/src/main/java</sourceDir> + </sourceDirs> + </configuration> + </execution> + <execution> + <id>test-compile</id> + <goals> + <goal>test-compile</goal> + </goals> + <configuration> + <sourceDirs> + <sourceDir>${project.basedir}/src/test/kotlin</sourceDir> + <sourceDir>${project.basedir}/src/test/java</sourceDir> + </sourceDirs> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.5.1</version> + <executions> + <!-- Replacing default-compile as it is treated specially by maven --> + <execution> + <id>default-compile</id> + <phase>none</phase> + </execution> + <!-- Replacing default-testCompile as it is treated specially by maven --> + <execution> + <id>default-testCompile</id> + <phase>none</phase> + </execution> + <execution> + <id>java-compile</id> + <phase>compile</phase> + <goals> + <goal>compile</goal> + </goals> + </execution> + <execution> + <id>java-test-compile</id> + <phase>test-compile</phase> + <goals> + <goal>testCompile</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jetbrains.dokka</groupId> + <artifactId>dokka-maven-plugin</artifactId> + <version>$dokka_version</version> + <executions> + <execution> + <phase>pre-site</phase> + <goals> + <goal>dokka</goal> + </goals> + </execution> + </executions> + <configuration> + + <!-- Set to true to skip dokka task, default: false --> + <skip>false</skip> + + <!-- Default: ${project.artifactId} --> + <moduleDisplayName>Maven Integration Test Module</moduleDisplayName> + + <!-- See list of possible formats below --> + <outputFormat>html</outputFormat> + <!-- Default: ${project.basedir}/target/dokka --> + <outputDir>${project.basedir}/output</outputDir> + + <!-- Use default or set to custom path to cache directory to enable package-list caching. --> + <!-- When set to default, caches stored in $USER_HOME/.cache/dokka --> + <cacheRoot>default</cacheRoot> + + + <!-- Used for linking to JDK, default: 6 --> + <jdkVersion>8</jdkVersion> + + <!-- Do not output deprecated members, applies globally, can be overridden by packageOptions --> + <skipDeprecated>false</skipDeprecated> + <!-- Emit warnings about not documented members, applies globally, also can be overridden by packageOptions --> + <reportUndocumented>true</reportUndocumented> + <!-- Do not create index pages for empty packages --> + <skipEmptyPackages>true</skipEmptyPackages> + + <!-- Short form list of sourceRoots, by default, set to ${project.compileSourceRoots} --> + <sourceDirectories> + <dir>${project.basedir}/src/main/kotlin</dir> + <dir>${project.basedir}/src/main/java</dir> + </sourceDirectories> + + + <!-- Disable linking to online kotlin-stdlib documentation --> + <noStdlibLink>false</noStdlibLink> + + <!-- Disable linking to online JDK documentation --> + <noJdkLink>false</noJdkLink> + + <!-- Allows to customize documentation generation options on a per-package basis --> + <perPackageOptions> + <packageOptions> + <!-- Will match kotlin and all sub-packages of it --> + <prefix>kotlin</prefix> + + <!-- All options are optional, default values are below: --> + <skipDeprecated>false</skipDeprecated> + <!-- Emit warnings about not documented members --> + <reportUndocumented>true</reportUndocumented> + <includeNonPublic>false</includeNonPublic> + </packageOptions> + </perPackageOptions> + </configuration> + </plugin> + </plugins> + <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> + <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> + </build> + + <pluginRepositories> + <pluginRepository> + <id>kotlin-dev</id> + <url>https://dl.bintray.com/kotlin/kotlin-dev/</url> + </pluginRepository> + <pluginRepository> + <id>jcenter</id> + <name>JCenter</name> + <url>https://jcenter.bintray.com/</url> + </pluginRepository> + </pluginRepositories> + + <dependencies> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib</artifactId> + <version>${kotlin.version}</version> + </dependency> + </dependencies> + + +</project> 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) + } + + } +} diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/environmentUtils.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/environmentUtils.kt new file mode 100644 index 00000000..eadf5a8c --- /dev/null +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/environmentUtils.kt @@ -0,0 +1,16 @@ +package org.jetbrains.dokka.it + +import java.io.File + +/** + * Indicating whether or not the current machine executing the test is a CI + */ +val isCI: Boolean get() = System.getenv("CI") == "true" + +val isAndroidSdkInstalled: Boolean = System.getenv("ANDROID_SDK_ROOT") != null || + System.getenv("ANDROID_HOME") != null + +val isMavenInstalled: Boolean = System.getenv("PATH").orEmpty() + .split(File.pathSeparator) + .flatMap { pathElement -> File(pathElement).listFiles().orEmpty().toList() } + .any { pathElement -> "mvn" == pathElement.name } diff --git a/integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/processUtils.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/processUtils.kt index d2fa3b31..d2c048ac 100644 --- a/integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/processUtils.kt +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/processUtils.kt @@ -1,4 +1,4 @@ -package org.jetbrains.dokka.it.cli +package org.jetbrains.dokka.it import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.async diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts index d9fc4f6f..8e412b43 100644 --- a/runners/maven-plugin/build.gradle.kts +++ b/runners/maven-plugin/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.configureBintrayPublication import org.jetbrains.CrossPlatformExec + /** * [mavenBin] configuration is used to download Maven Plugin Plugin * for generating plugin-help.xml and plugin.xml files @@ -30,6 +31,7 @@ dependencies { 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<Delete>("clean") { delete(mavenBinDir) @@ -48,6 +50,7 @@ val setupMaven by tasks.registering(Sync::class) { */ val generatePom by tasks.registering(Copy::class) { val dokka_version: String by project + inputs.property("dokka_version", dokka_version) from("$projectDir/pom.tpl.xml") { rename("(.*).tpl.xml", "$1.xml") diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 8160ab87..aa92516f 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -88,9 +88,6 @@ abstract class AbstractDokkaMojo : AbstractMojo() { var sourceDirectories: List<String> = emptyList() @Parameter - var sourceRoots: List<SourceRoot> = emptyList() - - @Parameter var samples: List<String> = emptyList() @Parameter diff --git a/settings.gradle.kts b/settings.gradle.kts index 409dca88..ecee8020 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,6 +21,7 @@ include("plugins:javadoc") include("integration-tests") include("integration-tests:gradle") include("integration-tests:cli") +include("integration-tests:maven") pluginManagement { val kotlin_version: String by settings |