aboutsummaryrefslogtreecommitdiff
path: root/integration-tests/maven
diff options
context:
space:
mode:
Diffstat (limited to 'integration-tests/maven')
-rw-r--r--integration-tests/maven/build.gradle.kts20
-rw-r--r--integration-tests/maven/projects/it-maven/pom.xml172
-rw-r--r--integration-tests/maven/projects/it-maven/src/main/java/it/basic/java/SampleJavaClass.java22
-rw-r--r--integration-tests/maven/projects/it-maven/src/main/kotlin/it/basic/PublicClass.kt48
-rw-r--r--integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt132
5 files changed, 394 insertions, 0 deletions
diff --git a/integration-tests/maven/build.gradle.kts b/integration-tests/maven/build.gradle.kts
new file mode 100644
index 00000000..1c747bbc
--- /dev/null
+++ b/integration-tests/maven/build.gradle.kts
@@ -0,0 +1,20 @@
+import org.jetbrains.SetupMaven
+import org.jetbrains.dependsOnMavenLocalPublication
+
+evaluationDependsOn(":runners:maven-plugin")
+
+dependencies {
+ implementation(kotlin("stdlib"))
+ implementation(kotlin("test-junit"))
+}
+
+tasks.integrationTest {
+ dependsOnMavenLocalPublication()
+
+ val setupMavenTask = project(":runners:maven-plugin").tasks.withType<SetupMaven>().single()
+ dependsOn(setupMavenTask)
+
+ val dokka_version: String by project
+ environment("DOKKA_VERSION", dokka_version)
+ environment("MVN_BINARY_PATH", setupMavenTask.mvn.absolutePath)
+}
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..c6e0ef45
--- /dev/null
+++ b/integration-tests/maven/projects/it-maven/pom.xml
@@ -0,0 +1,172 @@
+<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>
+
+ <!-- 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-eap</id>
+ <url>https://dl.bintray.com/kotlin/kotlin-eap/</url>
+ </pluginRepository>
+ <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..86cc2f41
--- /dev/null
+++ b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt
@@ -0,0 +1,132 @@
+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
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class MavenIntegrationTest : AbstractIntegrationTest() {
+
+ private val currentDokkaVersion: String = checkNotNull(System.getenv("DOKKA_VERSION"))
+
+ private 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 `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""")
+ 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)"
+ )
+ }
+}