From 7a4aa33a03381a21049c7447f2f70f6959664302 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 5 Jun 2019 15:07:22 +0200 Subject: Implement configuration avoidance --- .../main/kotlin/org/jetbrains/dokka/gradle/main.kt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains') diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index 3e65e6d4..209e812b 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka.gradle import org.gradle.api.Plugin import org.gradle.api.Project -import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin +import org.gradle.util.GradleVersion import java.io.File import java.io.InputStream import java.util.* @@ -15,17 +15,23 @@ open class DokkaPlugin : Plugin { override fun apply(project: Project) { DokkaVersion.loadFrom(javaClass.getResourceAsStream("/META-INF/gradle-plugins/org.jetbrains.dokka.properties")) - // TODO: Register instead of create for Gradle >= 4.10 - project.tasks.create("dokka", DokkaTask::class.java).apply { - moduleName = project.name - outputDirectory = File(project.buildDir, "dokka").absolutePath - } - val dokkaRuntimeConfiguration = project.configurations.create("dokkaRuntime") val defaultDokkaRuntimeConfiguration = project.configurations.create("defaultDokkaRuntime") defaultDokkaRuntimeConfiguration.defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}")) } + if(GradleVersion.current() >= GradleVersion.version("4.10")) { + project.tasks.register("dokka", DokkaTask::class.java).configure { + it.moduleName = project.name + it.outputDirectory = File(project.buildDir, "dokka").absolutePath + } + } else { + project.tasks.create("dokka", DokkaTask::class.java).apply { + moduleName = project.name + outputDirectory = File(project.buildDir, "dokka").absolutePath + } + } + project.tasks.withType(DokkaTask::class.java) { task -> val passConfiguration = project.container(GradlePassConfigurationImpl::class.java) task.multiplatform = passConfiguration -- cgit