aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-08-21 15:57:01 +0200
committerMarcin Aman <marcin.aman@gmail.com>2021-08-21 15:57:01 +0200
commit9044761979d08b3b116c9f8416dfb42ae216898c (patch)
tree700f3984d9078cec4914a27e2e7f977e2960464e /runners/gradle-plugin
parent79463f06a953de2f2c2ec877f34deaed658b3471 (diff)
downloaddokka-9044761979d08b3b116c9f8416dfb42ae216898c.tar.gz
dokka-9044761979d08b3b116c9f8416dfb42ae216898c.tar.bz2
dokka-9044761979d08b3b116c9f8416dfb42ae216898c.zip
Review comments + "unspecified" version fix
Diffstat (limited to 'runners/gradle-plugin')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt2
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt2
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt2
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt20
4 files changed, 20 insertions, 6 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt
index cffc8bf3..76213f14 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt
@@ -52,7 +52,7 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask() {
override fun buildDokkaConfiguration(): DokkaConfigurationImpl = DokkaConfigurationImpl(
moduleName = moduleName.getSafe(),
- moduleVersion = moduleVersion.getSafe(),
+ moduleVersion = moduleVersion.getValidVersionOrNull(),
outputDir = outputDirectory.getSafe(),
cacheRoot = cacheRoot.getSafe(),
pluginsConfiguration = buildPluginsConfiguration(),
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt
index b7e87c6c..51f6d297 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaProperty.kt
@@ -19,3 +19,5 @@ internal inline fun <reified T> Provider<T>.getSafe(): T =
if (typeOf<T>().isMarkedNullable) orNull as T
else get()
+internal fun Provider<String>.getValidVersionOrNull() = orNull?.takeIf { it != "unspecified" }
+
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt
index 6bb946c3..af2d3b1b 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt
@@ -9,7 +9,7 @@ abstract class DokkaTask : AbstractDokkaLeafTask() {
override fun buildDokkaConfiguration(): DokkaConfigurationImpl =
DokkaConfigurationImpl(
moduleName = moduleName.getSafe(),
- moduleVersion = moduleVersion.orNull?.takeIf { it != "unspecified" },
+ moduleVersion = moduleVersion.getValidVersionOrNull(),
outputDir = outputDirectory.getSafe(),
cacheRoot = cacheRoot.getSafe(),
offlineMode = offlineMode.getSafe(),
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt
index 97d1feea..73afdb43 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt
@@ -6,10 +6,7 @@ import org.gradle.kotlin.dsl.*
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.*
import java.io.File
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertFailsWith
-import kotlin.test.assertTrue
+import kotlin.test.*
class DokkaMultiModuleTaskTest {
@@ -100,6 +97,21 @@ class DokkaMultiModuleTaskTest {
}
@Test
+ fun `multimodule task should not include unspecified version`(){
+ childDokkaTask.apply {
+ dokkaSourceSets.create("main")
+ dokkaSourceSets.create("test")
+ }
+
+ multiModuleTask.apply {
+ moduleVersion by "unspecified"
+ }
+
+ val dokkaConfiguration = multiModuleTask.buildDokkaConfiguration()
+ assertNull(dokkaConfiguration.moduleVersion)
+ }
+
+ @Test
fun `setting dokkaTaskNames declares proper task dependencies`() {
val dependenciesInitial = multiModuleTask.taskDependencies.getDependencies(multiModuleTask).toSet()
assertEquals(1, dependenciesInitial.size, "Expected one dependency")