From 8a71a6aae61f4ad0faf26d68f0b705cd93e41776 Mon Sep 17 00:00:00 2001 From: "Vadim.Mishenev" Date: Thu, 28 Mar 2024 17:20:22 +0200 Subject: [PATCH 1/2] [K2] Run unit tests against the latest Analysis API --- .../main/kotlin/dokkabuild/DokkaBuildProperties.kt | 7 +++++++ dokka-subprojects/analysis-kotlin-symbols/README.md | 5 +++++ .../analysis-kotlin-symbols/build.gradle.kts | 13 +++++++++++++ gradle/libs.versions.toml | 3 +++ 4 files changed, 28 insertions(+) diff --git a/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt b/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt index c145a285e9..775d56c0a1 100644 --- a/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt +++ b/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt @@ -25,6 +25,13 @@ abstract class DokkaBuildProperties @Inject constructor( private val layout: ProjectLayout, ) { + /** + * The latest version of Analysis API (`kotlin-compiler-latest` from the toml file) should be used to build the Dokka + */ + val useTheLatestAnalysisAPI: Provider = + dokkaProperty("build.useTheLatestAnalysisAPI", String::toBoolean) + .orElse(false) + private val buildingOnTeamCity: Provider = providers.environmentVariable("TEAMCITY_VERSION").map(String::isNotBlank) diff --git a/dokka-subprojects/analysis-kotlin-symbols/README.md b/dokka-subprojects/analysis-kotlin-symbols/README.md index 7c84ffc59d..2538297b0b 100644 --- a/dokka-subprojects/analysis-kotlin-symbols/README.md +++ b/dokka-subprojects/analysis-kotlin-symbols/README.md @@ -16,3 +16,8 @@ The `.jar` produced by this project shadows all dependencies. There are several 2. There are many intertwining transitive dependencies of different versions, as well as direct copy-paste, that can lead to runtime errors due to classpath conflicts, so it's best to let Gradle take care of dependency resolution, and then pack everything into a single jar in a single place that can be tuned. + +## Testing with the latest version of Analysis API + +To build it with the latest version of Analysis API, the property +`org.jetbrains.dokka.build.useTheLatestAnalysisAPI=true` should be added to the project. \ No newline at end of file diff --git a/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts b/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts index 3d71a92cd1..0f44176d38 100644 --- a/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts +++ b/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts @@ -140,3 +140,16 @@ tasks.shadowJar { configurations = emptyList() from(shadowOverride, shadowDependenciesJar) } + +// for testing with the latest version of Analysis API +if (dokkaBuild.useTheLatestAnalysisAPI.get()) { + project.logger.lifecycle("Using the latest version of Analysis API") + configurations.all { + resolutionStrategy.eachDependency { + if (requested.version == libs.versions.kotlin.compiler.k2.get()) { + useVersion(libs.versions.kotlin.compiler.latest.get()) + because("unit testing can use the latest version of Analysis API") + } + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 81baa14cbd..e28556c087 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,9 @@ kotlinx-bcv = "0.13.2" ## Analysis kotlin-compiler = "1.9.22" kotlin-compiler-k2 = "2.0.20-dev-7" +# to run testing against the latest dev build of Analysis API +# it is used in the build script of symbol analysis +kotlin-compiler-latest = "2.0.20-dev-+" # MUST match the version of the intellij platform used in the kotlin compiler, # otherwise this will lead to different versions of psi API and implementations From 98d33b2eb64933797d050945e36f83c9272c79be Mon Sep 17 00:00:00 2001 From: "Vadim.Mishenev" Date: Fri, 5 Apr 2024 18:24:49 +0300 Subject: [PATCH 2/2] Use a property with an override version and overwrite a version catalog --- .../kotlin/dokkabuild/DokkaBuildProperties.kt | 7 ------- .../analysis-kotlin-symbols/README.md | 7 ++++--- .../analysis-kotlin-symbols/build.gradle.kts | 13 ------------- gradle/libs.versions.toml | 3 --- settings.gradle.kts | 17 +++++++++++++++++ 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt b/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt index 775d56c0a1..c145a285e9 100644 --- a/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt +++ b/build-logic/src/main/kotlin/dokkabuild/DokkaBuildProperties.kt @@ -25,13 +25,6 @@ abstract class DokkaBuildProperties @Inject constructor( private val layout: ProjectLayout, ) { - /** - * The latest version of Analysis API (`kotlin-compiler-latest` from the toml file) should be used to build the Dokka - */ - val useTheLatestAnalysisAPI: Provider = - dokkaProperty("build.useTheLatestAnalysisAPI", String::toBoolean) - .orElse(false) - private val buildingOnTeamCity: Provider = providers.environmentVariable("TEAMCITY_VERSION").map(String::isNotBlank) diff --git a/dokka-subprojects/analysis-kotlin-symbols/README.md b/dokka-subprojects/analysis-kotlin-symbols/README.md index 2538297b0b..4ca53ee7ed 100644 --- a/dokka-subprojects/analysis-kotlin-symbols/README.md +++ b/dokka-subprojects/analysis-kotlin-symbols/README.md @@ -17,7 +17,8 @@ The `.jar` produced by this project shadows all dependencies. There are several that can lead to runtime errors due to classpath conflicts, so it's best to let Gradle take care of dependency resolution, and then pack everything into a single jar in a single place that can be tuned. -## Testing with the latest version of Analysis API +## Testing with an override version of Analysis API -To build it with the latest version of Analysis API, the property -`org.jetbrains.dokka.build.useTheLatestAnalysisAPI=true` should be added to the project. \ No newline at end of file +To build it with an override version of Analysis API, the property +`org.jetbrains.dokka.build.overrideAnalysisAPIVersion=2.2.0-dev-*` should be added to the project. Any version can be set in the property instead of `2.2.0-dev-*`. + \ No newline at end of file diff --git a/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts b/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts index 0f44176d38..3d71a92cd1 100644 --- a/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts +++ b/dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts @@ -140,16 +140,3 @@ tasks.shadowJar { configurations = emptyList() from(shadowOverride, shadowDependenciesJar) } - -// for testing with the latest version of Analysis API -if (dokkaBuild.useTheLatestAnalysisAPI.get()) { - project.logger.lifecycle("Using the latest version of Analysis API") - configurations.all { - resolutionStrategy.eachDependency { - if (requested.version == libs.versions.kotlin.compiler.k2.get()) { - useVersion(libs.versions.kotlin.compiler.latest.get()) - because("unit testing can use the latest version of Analysis API") - } - } - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e28556c087..81baa14cbd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,9 +16,6 @@ kotlinx-bcv = "0.13.2" ## Analysis kotlin-compiler = "1.9.22" kotlin-compiler-k2 = "2.0.20-dev-7" -# to run testing against the latest dev build of Analysis API -# it is used in the build script of symbol analysis -kotlin-compiler-latest = "2.0.20-dev-+" # MUST match the version of the intellij platform used in the kotlin compiler, # otherwise this will lead to different versions of psi API and implementations diff --git a/settings.gradle.kts b/settings.gradle.kts index a622a3ca53..9da9e287d3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -104,3 +104,20 @@ include( project(":dokka-subprojects:core").name = "dokka-core" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +// OVERWRITING CATALOG VERSIONS +// for testing against the latest dev version of Analysis API +// currently, Analysis API is used only in the analysis-kotlin-symbols project +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + val kotlinCompilerK2Version = providers.gradleProperty( + "org.jetbrains.dokka.build.overrideAnalysisAPIVersion" + ).orNull + if (kotlinCompilerK2Version != null) { + logger.lifecycle("Using the override version $kotlinCompilerK2Version of Analysis API") + version("kotlin-compiler-k2", kotlinCompilerK2Version) + } + } + } +} \ No newline at end of file