From 29a4cc77cb981265c3a420a47fd35e4f8da18a25 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 18 Dec 2019 12:33:01 +0100 Subject: Make key methods of plugin and task protected open Addresses https://github.com/Kotlin/dokka/issues/534 --- .../main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 15 +++++++-------- .../src/main/kotlin/org/jetbrains/dokka/gradle/main.kt | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'runners/gradle-plugin/src') 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 97deb100..c5863318 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 @@ -75,7 +75,6 @@ open class DokkaTask : DefaultTask() { // Configure Dokka with closure in Gradle Kotlin DSL fun configuration(action: Action) = action.execute(configuration) - private val kotlinTasks: List by lazy { extractKotlinCompileTasks(configuration.collectKotlinTasks ?: { defaultKotlinTasks() }) } private val configExtractor = ConfigurationExtractor(project) @@ -126,7 +125,7 @@ open class DokkaTask : DefaultTask() { private fun Iterable.toSourceRoots(): List = this.filter { it.exists() }.map { GradleSourceRootImpl().apply { path = it.path } } private fun Iterable.toProjects(): List = project.subprojects.toList().filter { this.contains(it.name) } - private fun collectSuppressedFiles(sourceRoots: List) = + protected open fun collectSuppressedFiles(sourceRoots: List) = if(project.isAndroidProject()) { val generatedRoot = project.buildDir.resolve("generated").absoluteFile sourceRoots @@ -188,14 +187,14 @@ open class DokkaTask : DefaultTask() { } } - private fun collectConfigurations() = + protected open fun collectConfigurations() = if (this.isMultiplatformProject()) collectMultiplatform() else listOf(collectSinglePlatform(configuration)) - private fun collectMultiplatform() = multiplatform + protected open fun collectMultiplatform() = multiplatform .filterNot { it.name.toLowerCase() == GLOBAL_PLATFORM_NAME } .map { collectSinglePlatform(it) } - private fun collectSinglePlatform(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl { + protected open fun collectSinglePlatform(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl { val userConfig = config.let { if (it.collectKotlinTasks != null) { configExtractor.extractFromKotlinTasks(extractKotlinCompileTasks(it.collectKotlinTasks!!)) @@ -237,14 +236,14 @@ open class DokkaTask : DefaultTask() { } } - private fun collectFromSinglePlatformOldPlugin() = + protected open fun collectFromSinglePlatformOldPlugin() = configExtractor.extractFromKotlinTasks(kotlinTasks) ?.let { mergeUserConfigurationAndPlatformData(configuration, it) } ?: configExtractor.extractFromJavaPlugin() ?.let { mergeUserConfigurationAndPlatformData(configuration, it) } ?: configuration - private fun mergeUserConfigurationAndPlatformData(userConfig: GradlePassConfigurationImpl, autoConfig: PlatformData) = + protected open fun mergeUserConfigurationAndPlatformData(userConfig: GradlePassConfigurationImpl, autoConfig: PlatformData) = userConfig.copy().apply { sourceRoots.addAll(userConfig.sourceRoots.union(autoConfig.sourceRoots.toSourceRoots()).distinct()) classpath = userConfig.classpath.union(autoConfig.classpath.map { it.absolutePath }).distinct() @@ -252,7 +251,7 @@ open class DokkaTask : DefaultTask() { platform = autoConfig.platform } - private fun defaultPassConfiguration( + protected open fun defaultPassConfiguration( config: GradlePassConfigurationImpl, globalConfig: GradlePassConfigurationImpl? ): GradlePassConfigurationImpl { 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 6f8d55e4..7ed29c58 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 @@ -27,7 +27,7 @@ open class DokkaPlugin : Plugin { defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}")) } } - private fun addTasks(project: Project, runtimeConfiguration: Configuration, taskClass: Class) { + protected open fun addTasks(project: Project, runtimeConfiguration: Configuration, taskClass: Class) { if(GradleVersion.current() >= GradleVersion.version("4.10")) { project.tasks.register(taskName, taskClass) } else { -- cgit