aboutsummaryrefslogtreecommitdiff
path: root/runners
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-13 10:52:08 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-13 14:23:08 +0200
commit1df542dcb7edced840692ac4397debcc2556f4c2 (patch)
treed5914a396485be5ec132b17a37d2c4ebfe244fee /runners
parent8ec106388209543434f990fe3af6fb02a7caceb4 (diff)
downloaddokka-1df542dcb7edced840692ac4397debcc2556f4c2.tar.gz
dokka-1df542dcb7edced840692ac4397debcc2556f4c2.tar.bz2
dokka-1df542dcb7edced840692ac4397debcc2556f4c2.zip
Remove `global` dokka source set (in favor of configureEach)
Diffstat (limited to 'runners')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt5
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt48
2 files changed, 20 insertions, 33 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
index 27d25884..0270dbe2 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
@@ -1,10 +1,7 @@
package org.jetbrains.dokka.gradle
import org.gradle.api.DefaultTask
-import org.gradle.api.Project
-import org.gradle.api.UnknownTaskException
import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import java.lang.IllegalStateException
@@ -43,7 +40,7 @@ open class DokkaCollectorTask : DefaultTask() {
acc.pluginsClasspath = (acc.pluginsClasspath + it.pluginsClasspath).distinct()
acc
}
- project.tasks.withType(DokkaTask::class.java).configureEach { it.config = configuration }
+ project.tasks.withType(DokkaTask::class.java).configureEach { it.enforcedConfiguration = configuration }
}
init {
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 db25fc47..75ca66d1 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
@@ -20,7 +20,6 @@ import java.util.concurrent.Callable
open class DokkaTask : AbstractDokkaTask() {
private val ANDROID_REFERENCE_URL = Builder("https://developer.android.com/reference/").build()
- private val GLOBAL_CONFIGURATION_NAME = "global" // Used for copying perPackageOptions to other platforms
private val configExtractor = ConfigurationExtractor(project)
@Suppress("MemberVisibilityCanBePrivate")
@@ -52,7 +51,7 @@ open class DokkaTask : AbstractDokkaTask() {
@get:Internal
- internal var config: GradleDokkaConfigurationImpl? = null
+ internal var enforcedConfiguration: GradleDokkaConfigurationImpl? = null
@get:Nested
val dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSet> =
@@ -119,7 +118,7 @@ open class DokkaTask : AbstractDokkaTask() {
}
@TaskAction
- override fun generate() = config?.let { generate(it) } ?: generate(getConfigurationOrThrow())
+ override fun generate() = enforcedConfiguration?.let { generate(it) } ?: generate(getConfigurationOrThrow())
protected open fun generate(configuration: GradleDokkaConfigurationImpl) {
outputDiagnosticInfo = true
@@ -142,11 +141,10 @@ open class DokkaTask : AbstractDokkaTask() {
@Internal
internal fun getConfigurationOrNull(): GradleDokkaConfigurationImpl? {
- val globalConfig = dokkaSourceSets.toList().find { it.name.toLowerCase() == GLOBAL_CONFIGURATION_NAME }
val defaultModulesConfiguration = configuredDokkaSourceSets
- .map { configureDefault(it, globalConfig) }.takeIf { it.isNotEmpty() }
+ .map { configureDefault(it) }.takeIf { it.isNotEmpty() }
?: listOf(
- configureDefault(configureDokkaSourceSet(GradleDokkaSourceSet("main", project)), null)
+ configureDefault(configureDokkaSourceSet(GradleDokkaSourceSet("main", project)))
).takeIf { project.isNotMultiplatformProject() } ?: emptyList()
if (defaultModulesConfiguration.isEmpty()) {
@@ -185,11 +183,9 @@ open class DokkaTask : AbstractDokkaTask() {
@get:Internal
protected val configuredDokkaSourceSets: List<GradleDokkaSourceSet>
- get() = dokkaSourceSets
- .filterNot { it.name.toLowerCase() == GLOBAL_CONFIGURATION_NAME }
- .map { configureDokkaSourceSet(it) }
+ get() = dokkaSourceSets.map { configureDokkaSourceSet(it) }
- protected fun configureDokkaSourceSet(config: GradleDokkaSourceSet): GradleDokkaSourceSet {
+ private fun configureDokkaSourceSet(config: GradleDokkaSourceSet): GradleDokkaSourceSet {
val userConfig = config
.apply {
collectKotlinTasks?.let {
@@ -236,7 +232,7 @@ open class DokkaTask : AbstractDokkaTask() {
}
}
- protected fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradleDokkaSourceSet) =
+ private fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradleDokkaSourceSet) =
kotlinTasks.find { it.name == name }
?.let { configExtractor.extractFromKotlinTasks(listOf(it)) }
?.singleOrNull()
@@ -245,7 +241,7 @@ open class DokkaTask : AbstractDokkaTask() {
?.let { mergeUserConfigurationAndPlatformData(userConfig, it) }
?: userConfig
- protected fun mergeUserConfigurationAndPlatformData(
+ private fun mergeUserConfigurationAndPlatformData(
userConfig: GradleDokkaSourceSet,
autoConfig: PlatformData
) = userConfig.copy().apply {
@@ -257,10 +253,7 @@ open class DokkaTask : AbstractDokkaTask() {
platform = autoConfig.platform
}
- protected fun configureDefault(
- config: GradleDokkaSourceSet,
- globalConfig: GradleDokkaSourceSet?
- ): GradleDokkaSourceSet {
+ private fun configureDefault(config: GradleDokkaSourceSet): GradleDokkaSourceSet {
if (config.moduleDisplayName.isBlank()) {
config.moduleDisplayName = project.name
}
@@ -268,25 +261,22 @@ open class DokkaTask : AbstractDokkaTask() {
if (config.displayName.isBlank()) {
config.displayName = config.name.substringBeforeLast("Main", config.platform.toString())
}
- config.classpath =
- (config.classpath as List<Any>).map { it.toString() }.distinct() // Workaround for Groovy's GStringImpl
- config.sourceRoots = config.sourceRoots.distinct().toMutableList()
- config.samples = config.samples.map { project.file(it).absolutePath }
- config.includes = config.includes.map { project.file(it).absolutePath }
- config.suppressedFiles += collectSuppressedFiles(config.sourceRoots)
+
if (project.isAndroidProject() && !config.noAndroidSdkLink) {
config.externalDocumentationLinks.add(ANDROID_REFERENCE_URL)
}
+
if (config.platform?.isNotBlank() == true) {
config.analysisPlatform = dokkaPlatformFromString(config.platform.toString())
}
- globalConfig?.let {
- config.perPackageOptions.addAll(globalConfig.perPackageOptions)
- config.externalDocumentationLinks.addAll(globalConfig.externalDocumentationLinks)
- config.sourceLinks.addAll(globalConfig.sourceLinks)
- config.samples += globalConfig.samples.map { project.file(it).absolutePath }
- config.includes += globalConfig.includes.map { project.file(it).absolutePath }
- }
+
+ // Workaround for Groovy's GStringImpl
+ config.classpath = (config.classpath as List<Any>).map { it.toString() }.distinct()
+ config.sourceRoots = config.sourceRoots.distinct().toMutableList()
+ config.samples = config.samples.map { project.file(it).absolutePath }
+ config.includes = config.includes.map { project.file(it).absolutePath }
+ config.suppressedFiles += collectSuppressedFiles(config.sourceRoots)
+
return config
}