Skip to content

Commit

Permalink
[K2] Run unit tests against the latest Analysis API
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed Mar 28, 2024
1 parent 31ec638 commit aba29f5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ abstract class DokkaBuildProperties @Inject constructor(
private val layout: ProjectLayout,
) {

/**
* The latest version of Analysis API should be used to build the Dokka
*/
val useTheLatestAnalysisAPI: Provider<Boolean> =
dokkaProperty("build.useTheLatestAnalysisAPI", String::toBoolean)
.orElse(false)

private val buildingOnTeamCity: Provider<Boolean> =
providers.environmentVariable("TEAMCITY_VERSION").map(String::isNotBlank)

Expand Down
5 changes: 5 additions & 0 deletions dokka-subprojects/analysis-kotlin-symbols/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
13 changes: 13 additions & 0 deletions dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
}
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aba29f5

Please sign in to comment.