aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin
diff options
context:
space:
mode:
authorAndrey Tyrin <andrei.tyrin@jetbrains.com>2023-02-14 10:59:17 +0100
committerGitHub <noreply@github.com>2023-02-14 10:59:17 +0100
commite8423ecf9f430758398eabc0d35077fff17f1f6c (patch)
tree06b2f778abb049b10fdb58ae7eda88406a496757 /runners/gradle-plugin
parent00210fd03e89169615d08449c405e3f710984f47 (diff)
downloaddokka-e8423ecf9f430758398eabc0d35077fff17f1f6c.tar.gz
dokka-e8423ecf9f430758398eabc0d35077fff17f1f6c.tar.bz2
dokka-e8423ecf9f430758398eabc0d35077fff17f1f6c.zip
Deprecate methods for adding/removing task dependencies (#2857)
Diffstat (limited to 'runners/gradle-plugin')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTask.kt19
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTask.kt3
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaPlugin.kt3
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt3
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt5
5 files changed, 29 insertions, 4 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTask.kt
index 92314c52..e912b083 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTask.kt
@@ -6,6 +6,15 @@ import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Nested
import org.gradle.work.DisableCachingByDefault
+private const val DEPRECATION_MESSAGE = """
+ It is an anti-pattern to declare cross-project dependencies as it leads to various build problems.
+ For this reason, this API wil be removed with the introduction of project isolation.
+ When it happens, we will provide a migration guide. In the meantime, you can keep using this API
+ if you have to, but please don't rely on it if possible. If you don't want to document a certain project,
+ don't apply the Dokka plugin for it, or disable individual project tasks using the Gradle API .
+"""
+
+@Suppress("DEPRECATION")
@DisableCachingByDefault(because = "Abstract super-class, not to be instantiated directly")
abstract class AbstractDokkaParentTask : AbstractDokkaTask() {
@@ -21,50 +30,60 @@ abstract class AbstractDokkaParentTask : AbstractDokkaTask() {
.toSet()
/* By task reference */
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun addChildTask(task: AbstractDokkaTask) {
childDokkaTaskPaths = childDokkaTaskPaths + task.path
}
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun removeChildTask(task: AbstractDokkaTask) {
childDokkaTaskPaths = childDokkaTaskPaths - task.path
}
/* By path */
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun addChildTask(path: String) {
childDokkaTaskPaths = childDokkaTaskPaths + project.absoluteProjectPath(path)
}
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun removeChildTask(path: String) {
childDokkaTaskPaths = childDokkaTaskPaths - project.absoluteProjectPath(path)
}
/* By project reference and name */
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun addChildTasks(projects: Iterable<Project>, childTasksName: String) {
projects.forEach { project ->
addChildTask(project.absoluteProjectPath(childTasksName))
}
}
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun removeChildTasks(projects: Iterable<Project>, childTasksName: String) {
projects.forEach { project ->
removeChildTask(project.absoluteProjectPath(childTasksName))
}
}
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun addSubprojectChildTasks(childTasksName: String) {
addChildTasks(project.subprojects, childTasksName)
}
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun removeSubprojectChildTasks(childTasksName: String) {
removeChildTasks(project.subprojects, childTasksName)
}
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun removeChildTasks(project: Project) {
childDokkaTaskPaths = childDokkaTaskPaths.filter { path ->
parsePath(path).parent != parsePath(project.path)
}.toSet()
}
+ @Deprecated(message = DEPRECATION_MESSAGE, level = DeprecationLevel.WARNING)
fun removeChildTasks(projects: Iterable<Project>) {
projects.forEach { project -> removeChildTasks(project) }
}
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 4186bdda..db2a219c 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
@@ -67,6 +67,9 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask() {
task.path to task.dokkaSourceSets.flatMap { it.includes }.toSet()
}
+ // The method contains a reference to internal Gradle API that is nice not to use.
+ // There was an attempt to get rid of it, but it was not successful
+ // See: https://github.com/Kotlin/dokka/pull/2835
@Internal
override fun getTaskDependencies(): TaskDependencyInternal =
super.getTaskDependencies() + childDokkaTasks
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaPlugin.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaPlugin.kt
index 4027f844..c6878963 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaPlugin.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaPlugin.kt
@@ -4,7 +4,6 @@ import org.gradle.api.DefaultTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
-import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.kotlin.dsl.register
import org.gradle.util.GradleVersion
@@ -69,6 +68,7 @@ open class DokkaPlugin : Plugin<Project> {
project.maybeCreateDokkaRuntimeConfiguration(multiModuleName)
project.tasks.register<DokkaMultiModuleTask>(multiModuleName) {
+ @Suppress("DEPRECATION")
addSubprojectChildTasks("${name}Partial")
configuration()
description = "Runs all subprojects '$name' tasks and generates module navigation page"
@@ -85,6 +85,7 @@ open class DokkaPlugin : Plugin<Project> {
}
project.tasks.register<DokkaCollectorTask>("${name}Collector") {
+ @Suppress("DEPRECATION")
addSubprojectChildTasks(name)
description =
"Generates documentation merging all subprojects '$name' tasks into one virtual module"
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt
index f0e05637..173c0b53 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt
@@ -1,7 +1,8 @@
+@file:Suppress("DEPRECATION")
+
package org.jetbrains.dokka.gradle
import org.gradle.api.Project
-import org.gradle.api.UnknownTaskException
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.getByName
import org.gradle.testfixtures.ProjectBuilder
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 e308742e..4bace6d0 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
@@ -1,8 +1,9 @@
-@file:Suppress("UnstableApiUsage")
+@file:Suppress("UnstableApiUsage", "DEPRECATION")
package org.jetbrains.dokka.gradle
-import org.gradle.kotlin.dsl.*
+import org.gradle.kotlin.dsl.create
+import org.gradle.kotlin.dsl.withType
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.*
import java.io.File