Skip to content

Commit

Permalink
Update Kotlin to 1.9.0 (#3074)
Browse files Browse the repository at this point in the history
* Update Kotlin Gradle Plugin to 1.9.0

* Update Android Gradle Plugin to 4.2.2

* Introduce convention plugin for Gradle runner

gradle/gradle#8301

* Fix unit test `common, jvm and macos source sets with kotlin multiplatform`

* Update compiler to 1.9.0

* Update integration test

* Add empty target for WASM integration test to avoid single target project

See #3038

* Remove unused `plugins.shadow` from toml

(cherry picked from commit f5393dd)
  • Loading branch information
vmishenev authored and IgnatBeresnev committed Jul 21, 2023
1 parent 12f44d9 commit 6dd728f
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 79 deletions.
4 changes: 4 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion

plugins {
`kotlin-dsl`
}
Expand All @@ -12,6 +14,8 @@ dependencies {
implementation(libs.gradlePlugin.dokka)
implementation(libs.gradlePlugin.kotlin)
implementation(libs.gradlePlugin.shadow)
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion")
implementation(libs.gradlePlugin.gradlePublish)

// workaround for accessing version-catalog in convention plugins
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.jetbrains.conventions

plugins {
id("org.gradle.kotlin.kotlin-dsl")
id("org.jetbrains.conventions.maven-publish")
id("com.gradle.plugin-publish")
id("org.jetbrains.conventions.base-java")
kotlin("jvm")
}
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
id("org.jetbrains.conventions.dokka")

alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
alias(libs.plugins.gradlePublish) apply false // see #3031 for "apply false" reasoning
alias(libs.plugins.nexusPublish)
}

Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[versions]

gradlePlugin-kotlin = "1.8.20"
gradlePlugin-android = "4.1.3"
gradlePlugin-kotlin = "1.9.0"
# See: https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin
gradlePlugin-android = "4.2.2"
gradlePlugin-dokka = "1.8.20"

kotlinx-coroutines = "1.6.3"
kotlinx-bcv = "0.12.1"

## Analysis
kotlin-compiler = "1.8.20"
kotlin-compiler = "1.9.0"

# 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
# on the classpath and will fail with hard to debug problems in runtime.
# See: https://github.com/JetBrains/kotlin/blob/e6633d3d9214402fcf3585ae8c24213a4761cc8b/gradle/versions.properties#L1
intellij-platform = "203.8084.24"
intellij-platform = "213.7172.25"

## HTML
jsoup = "1.15.3"
Expand Down Expand Up @@ -62,6 +63,7 @@ gradlePlugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", ve
gradlePlugin-android = { module = "com.android.tools.build:gradle", version.ref = "gradlePlugin-android" }
gradlePlugin-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "gradlePlugin-dokka" }
gradlePlugin-shadow = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "gradlePlugin-shadow" }
gradlePlugin-gradlePublish= { module = "com.gradle.publish:plugin-publish-plugin", version.ref = "gradlePlugin-gradlePluginPublish" }

#### Kotlin analysis ####
kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler", version.ref = "kotlin-compiler" }
Expand Down Expand Up @@ -109,7 +111,5 @@ junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
# and define the Maven coordinates above to be used in build-logic/build.gradle.kts)

kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinx-bcv" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "gradlePlugin-shadow" }
gradlePublish = { id = "com.gradle.plugin-publish", version.ref = "gradlePlugin-gradlePluginPublish" }
nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradlePlugin-nexusPublish" }
gradleNode = { id = "com.github.node-gradle.node", version.ref = "gradlePlugin-gradleNode" }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dokka_it_kotlin_version=1.8.20
dokka_it_android_gradle_plugin_version=4.1.3
dokka_it_kotlin_version=1.9.0
dokka_it_android_gradle_plugin_version=4.2.2
android.useAndroidX=true
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repositories {
}

kotlin {
jvm() // artificial empty target to avoid single target project
wasm()
sourceSets {
val wasmMain by getting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.jetbrains.dokka.it.gradle

internal object TestedVersions {

val LATEST = BuildVersions("7.4.2", "1.8.20")
val LATEST = BuildVersions("7.6.2", "1.9.0")

/**
* All supported Gradle/Kotlin versions, including [LATEST]
Expand All @@ -12,10 +12,10 @@ internal object TestedVersions {
val ALL_SUPPORTED =
BuildVersions.permutations(
gradleVersions = listOf("6.9"),
kotlinVersions = listOf("1.7.20", "1.6.21", "1.5.31", "1.4.32"),
kotlinVersions = listOf("1.8.20", "1.7.20", "1.6.21", "1.5.31"),
) + BuildVersions.permutations(
gradleVersions = listOf(*ifExhaustive("7.0", "6.1.1")),
kotlinVersions = listOf(*ifExhaustive("1.7.0", "1.6.0", "1.5.0", "1.4.0"))
kotlinVersions = listOf(*ifExhaustive( "1.8.0", "1.7.0", "1.6.0", "1.5.0"))
) + LATEST

/**
Expand Down Expand Up @@ -46,6 +46,7 @@ internal object TestedVersions {
"1.7.20" to "18.2.0-pre.391",
"1.8.0" to "18.2.0-pre.467",
"1.8.10" to "18.2.0-pre.490",
"1.8.20" to "18.2.0-pre.546"
"1.8.20" to "18.2.0-pre.546",
"1.9.0" to "18.2.0-pre.597",
)
}
5 changes: 1 addition & 4 deletions runners/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import org.jetbrains.*

plugins {
`kotlin-dsl`
id("org.jetbrains.conventions.maven-publish")
id("org.jetbrains.conventions.base-java")
id("com.gradle.plugin-publish")
id("org.jetbrains.conventions.gradle-plugin")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ private fun KotlinCompilation.classpathOf(project: Project): FileCollection {

val shouldKeepBackwardsCompatibility = (kgpVersion != null && kgpVersion < KotlinGradlePluginVersion(1, 7, 0))
return if (shouldKeepBackwardsCompatibility) {
@Suppress("DEPRECATION_ERROR")
kotlinCompile.classpath // deprecated with error since 1.8.0, left for compatibility with < Kotlin 1.7
// removed since 1.9.0, left for compatibility with < Kotlin 1.7
val classpathGetter= kotlinCompile::class.members
.first { it.name == "getClasspath" }
classpathGetter.call(kotlinCompile) as FileCollection
} else {
kotlinCompile.libraries // introduced in 1.7.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jetbrains.dokka.gradle

import org.jetbrains.dokka.gradle.utils.withDependencies_
import org.gradle.api.artifacts.FileCollectionDependency
import org.gradle.api.internal.project.DefaultProject
import org.gradle.kotlin.dsl.get
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.gradle.kotlin.gistOf
Expand Down Expand Up @@ -163,6 +164,7 @@ class KotlinSourceSetGistTest {
kotlin.jvm()
kotlin.macosX64("macos")

(project as DefaultProject).evaluate()
val commonMainSourceSet = kotlin.sourceSets.getByName("commonMain")
val commonMainSourceSetGist = project.gistOf(commonMainSourceSet)

Expand Down Expand Up @@ -232,17 +234,11 @@ class KotlinSourceSetGistTest {
"Expected macosTest not being marked with 'isMain'"
)

// requires `project.evaluate()`
assertEquals(
setOf("commonMain"), jvmMainSourceSetGist.dependentSourceSetNames.get(),
"Expected jvmMain to depend on commonMain by default"
)

/* Why not? */
jvmMainSourceSet.dependsOn(macosMainSourceSet)
assertEquals(
setOf("commonMain", "macosMain"), jvmMainSourceSetGist.dependentSourceSetNames.get(),
"Expected dependent source set changes to be reflected in gist"
)
}

}
5 changes: 5 additions & 0 deletions subprojects/analysis-kotlin-descriptors/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ plugins {
}

dependencies {
// to override some interfaces (JvmAnnotationEnumFieldValue, JvmAnnotationConstantValue) from compiler since thet are empty there
// should be `api` since we already have it in :analysis-java-psi
api(libs.intellij.java.psi.api) {
isTransitive = false
}
implementation(projects.subprojects.analysisKotlinApi)
implementation(projects.subprojects.analysisKotlinDescriptors.compiler)
implementation(projects.subprojects.analysisKotlinDescriptors.ide)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,23 +343,24 @@ class AnalysisEnvironment(
moduleInfo: ModuleInfo
): ResolverForModule =
CommonResolverForModuleFactory(
CommonAnalysisParameters(
metadataPartProviderFactory = { content ->
environment.createPackagePartProvider(content.moduleContentScope)
}
),
CompilerEnvironment,
unspecifiedJvmPlatform,
true,
dependencyContainer
).createResolverForModule(
CommonAnalysisParameters(
metadataPartProviderFactory = { content ->
environment.createPackagePartProvider(content.moduleContentScope)
}
),
CompilerEnvironment,
unspecifiedJvmPlatform,
true,
dependencyContainer
).createResolverForModule(
moduleDescriptor = descriptor as ModuleDescriptorImpl,
moduleContext = projectContext.withModule(descriptor),
moduleContent = modulesContent(moduleInfo),
resolverForProject = this,
languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT,
sealedInheritorsProvider = CliSealedClassInheritorsProvider,
resolveOptimizingOptions = null
resolveOptimizingOptions = null,
absentDescriptorHandlerClass = null
)

override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null
Expand Down Expand Up @@ -387,7 +388,8 @@ class AnalysisEnvironment(
resolverForProject = this,
languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT,
sealedInheritorsProvider = CliSealedClassInheritorsProvider,
resolveOptimizingOptions = null
resolveOptimizingOptions = null,
absentDescriptorHandlerClass = null
)

override fun builtInsForModule(module: ModuleInfo): KotlinBuiltIns = DefaultBuiltIns.Instance
Expand Down Expand Up @@ -419,7 +421,8 @@ class AnalysisEnvironment(
resolverForProject = this,
languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT,
sealedInheritorsProvider = CliSealedClassInheritorsProvider,
resolveOptimizingOptions = null
resolveOptimizingOptions = null,
absentDescriptorHandlerClass = null
)
}

Expand Down Expand Up @@ -464,33 +467,34 @@ class AnalysisEnvironment(
descriptor: ModuleDescriptor,
moduleInfo: ModuleInfo
): ResolverForModule = JvmResolverForModuleFactory(
JvmPlatformParameters(packagePartProviderFactory = { content ->
JvmPackagePartProvider(
configuration.languageVersionSettings,
content.moduleContentScope
)
.apply {
addRoots(javaRoots, messageCollector)
}
}, moduleByJavaClass = {
val file =
(it as? BinaryJavaClass)?.virtualFile ?: (it as JavaClassImpl).psi.containingFile.virtualFile
if (file in sourcesScope)
module
else
library
}, resolverForReferencedModule = null,
useBuiltinsProviderForModule = { false }),
CompilerEnvironment,
unspecifiedJvmPlatform
).createResolverForModule(
JvmPlatformParameters(packagePartProviderFactory = { content ->
JvmPackagePartProvider(
configuration.languageVersionSettings,
content.moduleContentScope
)
.apply {
addRoots(javaRoots, messageCollector)
}
}, moduleByJavaClass = {
val file =
(it as? BinaryJavaClass)?.virtualFile ?: (it as JavaClassImpl).psi.containingFile.virtualFile
if (file in sourcesScope)
module
else
library
}, resolverForReferencedModule = null,
useBuiltinsProviderForModule = { false }),
CompilerEnvironment,
unspecifiedJvmPlatform
).createResolverForModule(
moduleDescriptor = descriptor as ModuleDescriptorImpl,
moduleContext = projectContext.withModule(descriptor),
moduleContent = modulesContent(moduleInfo),
resolverForProject = this,
languageVersionSettings = configuration.languageVersionSettings,
sealedInheritorsProvider = CliSealedClassInheritorsProvider,
resolveOptimizingOptions = null
resolveOptimizingOptions = null,
absentDescriptorHandlerClass = null
)

override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil
import org.jetbrains.kotlin.serialization.js.createKotlinJavascriptPackageFragmentProvider
import org.jetbrains.kotlin.library.metadata.impl.KlibMetadataModuleDescriptorFactoryImpl
import org.jetbrains.kotlin.resolve.lazy.AbsentDescriptorHandler
import org.jetbrains.kotlin.resolve.scopes.optimization.OptimizingOptions
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
import java.io.File
Expand Down Expand Up @@ -50,7 +51,8 @@ internal class DokkaJsResolverForModuleFactory(
resolverForProject: ResolverForProject<M>,
languageVersionSettings: LanguageVersionSettings,
sealedInheritorsProvider: SealedClassInheritorsProvider,
resolveOptimizingOptions: OptimizingOptions?
resolveOptimizingOptions: OptimizingOptions?,
absentDescriptorHandlerClass: Class<out AbsentDescriptorHandler>?
): ResolverForModule {
val declarationProviderFactory = DeclarationProviderFactoryService.createDeclarationProviderFactory(
moduleContext.project,
Expand All @@ -61,13 +63,14 @@ internal class DokkaJsResolverForModuleFactory(
)

val container = createContainerForLazyResolve(
moduleContext,
declarationProviderFactory,
CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(), // BindingTraceContext(/* allowSliceRewrite = */ true),
moduleDescriptor.platform!!,
JsPlatformAnalyzerServices,
targetEnvironment,
languageVersionSettings
moduleContext = moduleContext,
declarationProviderFactory = declarationProviderFactory,
bindingTrace = CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(), // BindingTraceContext(/* allowSliceRewrite = */ true),
platform = moduleDescriptor.platform!!,
analyzerServices = JsPlatformAnalyzerServices,
targetEnvironment = targetEnvironment,
languageVersionSettings = languageVersionSettings,
absentDescriptorHandlerClass = absentDescriptorHandlerClass
)

var packageFragmentProvider = container.get<ResolveSession>().packageFragmentProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.SealedClassInheritorsProvider
import org.jetbrains.kotlin.resolve.TargetEnvironment
import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices
import org.jetbrains.kotlin.resolve.lazy.AbsentDescriptorHandler
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService
import org.jetbrains.kotlin.resolve.scopes.optimization.OptimizingOptions
Expand All @@ -36,7 +37,8 @@ internal class DokkaNativeResolverForModuleFactory(
resolverForProject: ResolverForProject<M>,
languageVersionSettings: LanguageVersionSettings,
sealedInheritorsProvider: SealedClassInheritorsProvider,
resolveOptimizingOptions: OptimizingOptions?
resolveOptimizingOptions: OptimizingOptions?,
absentDescriptorHandlerClass: Class<out AbsentDescriptorHandler>?
): ResolverForModule {

val declarationProviderFactory = DeclarationProviderFactoryService.createDeclarationProviderFactory(
Expand All @@ -48,13 +50,14 @@ internal class DokkaNativeResolverForModuleFactory(
)

val container = createContainerForLazyResolve(
moduleContext,
declarationProviderFactory,
CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(),
moduleDescriptor.platform!!,
NativePlatformAnalyzerServices,
targetEnvironment,
languageVersionSettings
moduleContext = moduleContext,
declarationProviderFactory = declarationProviderFactory,
bindingTrace = CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(),
platform = moduleDescriptor.platform!!,
analyzerServices = NativePlatformAnalyzerServices,
targetEnvironment = targetEnvironment,
languageVersionSettings = languageVersionSettings,
absentDescriptorHandlerClass = absentDescriptorHandlerClass
)

var packageFragmentProvider = container.get<ResolveSession>().packageFragmentProvider
Expand Down
Loading

0 comments on commit 6dd728f

Please sign in to comment.