From 254f319aadf9327261da7c623fb22a632ce9bab8 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Wed, 2 Dec 2020 15:34:32 +0100 Subject: Fix gradle passing 'unspecified' version to dokka configuration (#1650) --- .../src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 2 +- .../test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'runners/gradle-plugin') 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 caee0d92..078ef925 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 @@ -35,7 +35,7 @@ abstract class DokkaTask : AbstractDokkaTask() { override fun buildDokkaConfiguration(): DokkaConfigurationImpl = DokkaConfigurationImpl( moduleName = moduleName.getSafe(), - moduleVersion = moduleVersion.orNull, + moduleVersion = moduleVersion.orNull?.takeIf { it != "unspecified" }, outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), offlineMode = offlineMode.getSafe(), diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt index 139ebd3a..546a59db 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt @@ -4,6 +4,7 @@ import org.gradle.kotlin.dsl.create import org.gradle.testfixtures.ProjectBuilder import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertNull class DokkaTaskTest { @Test @@ -24,4 +25,14 @@ class DokkaTaskTest { "Expected only unsuppressed source sets `main` and `test` to be present in built configuration" ) } + + @Test + fun `module version is not present if not specified`(){ + val project = ProjectBuilder.builder().build() + val task = project.tasks.create("dokkaTask") + project.configurations.all { configuration -> configuration.withDependencies { it.clear() } } + + task.dokkaSourceSets.register("main") + assertNull(task.buildDokkaConfiguration().moduleVersion) + } } -- cgit