Skip to content

Commit

Permalink
Add K2 analysis switcher (#3152)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev authored Nov 9, 2023
1 parent 64cce58 commit 58dfa93
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion subprojects/analysis-kotlin-symbols/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ dependencies {

// TODO [beresnev] get rid of it
compileOnly(libs.kotlinx.coroutines.core)

}

tasks {
Expand Down

0 comments on commit 58dfa93

Please sign in to comment.