diff --git a/build.gradle.kts b/build.gradle.kts index 0b162f118f..fa1de411b0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import com.google.devtools.ksp.configureKtlint import com.google.devtools.ksp.configureKtlintApplyToIdea +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion val sonatypeUserName: String? by project val sonatypePassword: String? by project @@ -124,5 +125,9 @@ subprojects { tasks.withType().configureEach { compilerOptions.freeCompilerArgs.add("-Xskip-prerelease-check") + + // For access to internal classes. + // FIXME: get rid of internal accesses + compilerOptions.languageVersion.set(KotlinVersion.KOTLIN_1_9) } } diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/KotlinSymbolProcessingExtension.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/KotlinSymbolProcessingExtension.kt index 266c9aa720..41fc2a334d 100644 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/KotlinSymbolProcessingExtension.kt +++ b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/KotlinSymbolProcessingExtension.kt @@ -50,8 +50,10 @@ import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiManager +import com.intellij.psi.impl.file.impl.JavaFileManager import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl import org.jetbrains.kotlin.config.JvmAnalysisFlags import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.ComponentProvider @@ -157,6 +159,8 @@ abstract class AbstractKotlinSymbolProcessingExtension( val psiManager = PsiManager.getInstance(project) if (initialized) { psiManager.dropPsiCaches() + psiManager.dropResolveCaches() + invalidateKotlinCliJavaFileManagerCache(project) } else { // In case of broken builds. if (javaShadowBase.exists()) { @@ -503,3 +507,13 @@ fun findTargetInfos(languageVersionSettings: LanguageVersionSettings, module: Mo else -> UnknownPlatformInfoImpl(platform.toString()) } } ?: emptyList() + +// FIXME: remove as soon as possible. +private fun invalidateKotlinCliJavaFileManagerCache(project: Project): Boolean { + val javaFileManager = (JavaFileManager.getInstance(project) as? KotlinCliJavaFileManagerImpl) ?: return false + val privateCacheField = KotlinCliJavaFileManagerImpl::class.java.getDeclaredField("topLevelClassesCache") + if (!privateCacheField.trySetAccessible()) + return false + (privateCacheField.get(javaFileManager) as? MutableMap<*, *>)?.clear() ?: return false + return true +} diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinFactories.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinFactories.kt index d5bf52edcc..c9b4275ab9 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinFactories.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinFactories.kt @@ -163,7 +163,7 @@ class KotlinFactories { from = compilerOptions, into = kspTask.compilerOptions ) - kspTask.produceUnpackedKlib.set(false) + kspTask.produceUnpackagedKlib.set(false) kspTask.onlyIf { // KonanTarget is not properly serializable, hence we should check by name // see https://youtrack.jetbrains.com/issue/KT-61657. diff --git a/gradle-plugin/src/test/kotlin/com/google/devtools/ksp/gradle/SourceSetConfigurationsTest.kt b/gradle-plugin/src/test/kotlin/com/google/devtools/ksp/gradle/SourceSetConfigurationsTest.kt index d0e45a47b3..9683eaf60d 100644 --- a/gradle-plugin/src/test/kotlin/com/google/devtools/ksp/gradle/SourceSetConfigurationsTest.kt +++ b/gradle-plugin/src/test/kotlin/com/google/devtools/ksp/gradle/SourceSetConfigurationsTest.kt @@ -81,7 +81,7 @@ class SourceSetConfigurationsTest { """ kotlin { jvm { } - android(name = "foo") { } + androidTarget(name = "foo") { } js(IR) { browser() } androidNativeX86 { } androidNativeX64(name = "bar") { } diff --git a/gradle.properties b/gradle.properties index 1cfc06d511..e1b224b590 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Copied from kotlinc org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx4096m -Dfile.encoding=UTF-8 -kotlinBaseVersion=2.1.0-Beta1 +kotlinBaseVersion=2.1.0-Beta2 agpBaseVersion=7.3.1 intellijVersion=233.13135.103 junitVersion=4.13.1 @@ -23,5 +23,5 @@ compilerTestEnabled=false kotlin.jvm.target.validation.mode=warning # Build or runtime dependencies of this project -buildKotlinVersion=1.9.23 -buildKspVersion=1.9.23-1.0.20 +buildKotlinVersion=2.0.21 +buildKspVersion=2.0.21-1.0.25 diff --git a/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt b/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt index 4514d17d2d..9e055f1e3f 100644 --- a/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt +++ b/integration-tests/src/test/kotlin/com/google/devtools/ksp/test/PlaygroundIT.kt @@ -271,15 +271,15 @@ class PlaygroundIT(val useKSP2: Boolean) { val kotlinCompile = "org.jetbrains.kotlin.gradle.tasks.KotlinCompile" val buildFile = File(project.root, "workload/build.gradle.kts") buildFile.appendText("\ntasks.withType<$kotlinCompile> {") - buildFile.appendText("\n kotlinOptions.apiVersion = \"1.5\"") - buildFile.appendText("\n kotlinOptions.languageVersion = \"1.5\"") + buildFile.appendText("\n kotlinOptions.apiVersion = \"1.6\"") + buildFile.appendText("\n kotlinOptions.languageVersion = \"1.6\"") buildFile.appendText("\n}") val kotlinVersion = System.getProperty("kotlinVersion").split('-').first() val gradleRunner = GradleRunner.create().withProjectDir(project.root) gradleRunner.buildAndCheck("clean", "build") { result -> - Assert.assertTrue(result.output.contains("language version: 1.5")) - Assert.assertTrue(result.output.contains("api version: 1.5")) + Assert.assertTrue(result.output.contains("language version: 1.6")) + Assert.assertTrue(result.output.contains("api version: 1.6")) if (!useKSP2) { // In case KSP 1 and KSP 2 uses different compiler versions, ignore this test for KSP 2 for now. Assert.assertTrue(result.output.contains("compiler version: $kotlinVersion")) diff --git a/integration-tests/src/test/resources/kmp/test-processor/src/main/kotlin/TestProcessor.kt b/integration-tests/src/test/resources/kmp/test-processor/src/main/kotlin/TestProcessor.kt index 95c3cf3e9a..85c1a1f076 100644 --- a/integration-tests/src/test/resources/kmp/test-processor/src/main/kotlin/TestProcessor.kt +++ b/integration-tests/src/test/resources/kmp/test-processor/src/main/kotlin/TestProcessor.kt @@ -67,7 +67,7 @@ class ClassVisitor : KSTopDownVisitor() { data: OutputStreamWriter ) { super.visitClassDeclaration(classDeclaration, data) - val symbolName = classDeclaration.simpleName.asString().toLowerCase() + val symbolName = classDeclaration.simpleName.asString().lowercase() data.write(" val $symbolName = true\n") } }