Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add K2 analysis switcher #3152

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading