diff options
author | Vadim Mishenev <vad-mishenev@yandex.ru> | 2023-11-09 17:34:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-09 17:34:20 +0200 |
commit | 58dfa934d91f5ab96e1af1ef7689c70b58382a20 (patch) | |
tree | b23bf0433e35a2176a4039762214dd180e16ce29 | |
parent | 64cce58f73f908909ba60da6005d7abb2572b2f0 (diff) | |
download | dokka-58dfa934d91f5ab96e1af1ef7689c70b58382a20.tar.gz dokka-58dfa934d91f5ab96e1af1ef7689c70b58382a20.tar.bz2 dokka-58dfa934d91f5ab96e1af1ef7689c70b58382a20.zip |
Add K2 analysis switcher (#3152)
4 files changed, 15 insertions, 2 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaArtifacts.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaArtifacts.kt index 773d93ab..241c0449 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaArtifacts.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaArtifacts.kt @@ -16,6 +16,7 @@ internal class DokkaArtifacts(private val project: Project) { // TODO [beresnev] analysis switcher val analysisKotlinDescriptors get() = fromModuleName("analysis-kotlin-descriptors") + val analysisKotlinSymbols get() = fromModuleName("analysis-kotlin-symbols") val allModulesPage get() = fromModuleName("all-modules-page-plugin") val dokkaCore get() = fromModuleName("dokka-core") 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 be2a6603..77fba8f2 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 @@ -18,6 +18,13 @@ open class DokkaPlugin : Plugin<Project> { if (GradleVersion.version(project.gradle.gradleVersion) < GradleVersion.version("5.6")) { project.logger.warn("Dokka: Build is using unsupported gradle version, expected at least 5.6 but got ${project.gradle.gradleVersion}. This may result in strange errors") } + if (project.shouldUseK2()) + project.logger.warn( + "Dokka's K2 Analysis is being used. " + + "It is still under active development and is thus experimental. " + + "It can be the cause of failed builds or incorrectly generated documentation. " + + "If you encounter an issue, please consider reporting it: https://github.com/Kotlin/dokka/issues" + ) project.setupDokkaTasks("dokkaHtml") { description = "Generates documentation in 'html' format" diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/gradleConfigurations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/gradleConfigurations.kt index 69bb2263..63424e1e 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/gradleConfigurations.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/gradleConfigurations.kt @@ -10,6 +10,9 @@ import org.gradle.api.artifacts.Dependency import org.gradle.api.attributes.Usage import org.gradle.kotlin.dsl.named +internal fun Project.shouldUseK2() = + (findProperty("org.jetbrains.dokka.experimental.tryK2") as? String)?.toBoolean() ?: false + internal fun Project.maybeCreateDokkaDefaultPluginConfiguration(): Configuration { return configurations.maybeCreate("dokkaPlugin") { attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME)) @@ -29,7 +32,10 @@ internal fun Project.maybeCreateDokkaPluginConfiguration(dokkaTaskName: String, extendsFrom(maybeCreateDokkaDefaultPluginConfiguration()) attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME)) isCanBeConsumed = false - dependencies.add(project.dokkaArtifacts.analysisKotlinDescriptors) + dependencies.add( + if (shouldUseK2()) project.dokkaArtifacts.analysisKotlinSymbols + else project.dokkaArtifacts.analysisKotlinDescriptors + ) dependencies.add(project.dokkaArtifacts.dokkaBase) dependencies.addAll(additionalDependencies) } diff --git a/subprojects/analysis-kotlin-symbols/build.gradle.kts b/subprojects/analysis-kotlin-symbols/build.gradle.kts index b6626f92..610462a3 100644 --- a/subprojects/analysis-kotlin-symbols/build.gradle.kts +++ b/subprojects/analysis-kotlin-symbols/build.gradle.kts @@ -82,7 +82,6 @@ dependencies { // TODO [beresnev] get rid of it compileOnly(libs.kotlinx.coroutines.core) - } tasks { |