aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-07-14 11:36:47 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-07-15 11:42:35 +0200
commit34e696f92aaa3802f13a0074003bc8957218aeba (patch)
tree11a06c92bed6992b2f163728e2b27d8a7f750972
parent6f04a8cfd6587b59f9ce62cfe575eafdc9f09501 (diff)
downloaddokka-34e696f92aaa3802f13a0074003bc8957218aeba.tar.gz
dokka-34e696f92aaa3802f13a0074003bc8957218aeba.tar.bz2
dokka-34e696f92aaa3802f13a0074003bc8957218aeba.zip
Refactor and add integration tests
-rw-r--r--integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt98
-rw-r--r--runners/maven-plugin/src/main/kotlin/DokkaMojo.kt15
2 files changed, 82 insertions, 31 deletions
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<Dependency>) : 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<Dependency> = emptyList()
+ var dokkaPlugins: List<Dependency> = 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()) {