From 053e5ce80e2d9096a291c4fbb320eb3bb989a344 Mon Sep 17 00:00:00 2001 From: Jiaxiang Chen Date: Wed, 13 Dec 2023 21:52:43 -0800 Subject: [PATCH] Revert "UPDATE_KOTLIN_VERSION: 1.9.30-dev-2548" This reverts commit 9d87cff77f06bdc86089a9b88e9d21c7f1780bfd. --- .../devtools/ksp/gradle/KotlinFactories.kt | 4 +-- .../devtools/ksp/gradle/KspSubplugin.kt | 25 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) 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 518ab1af63..291dc7f3a6 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 @@ -39,7 +39,6 @@ import org.gradle.process.CommandLineArgumentProvider import org.gradle.process.ExecOperations import org.gradle.work.InputChanges import org.gradle.workers.WorkerExecutor -import org.jetbrains.kotlin.buildtools.api.SourcesChanges import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments @@ -68,6 +67,7 @@ import org.jetbrains.kotlin.gradle.tasks.TaskOutputsBackup import org.jetbrains.kotlin.gradle.tasks.configuration.BaseKotlin2JsCompileConfig import org.jetbrains.kotlin.gradle.tasks.configuration.KotlinCompileCommonConfig import org.jetbrains.kotlin.gradle.tasks.configuration.KotlinCompileConfig +import org.jetbrains.kotlin.incremental.ChangedFiles import org.jetbrains.kotlin.konan.target.HostManager import java.io.File import java.nio.file.Paths @@ -186,7 +186,7 @@ interface KspTask : Task { val commandLineArgumentProviders: ListProperty @get:Internal - val incrementalChangesTransformers: ListProperty<(SourcesChanges) -> List> + val incrementalChangesTransformers: ListProperty<(ChangedFiles) -> List> } @CacheableTask diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt index 6d30c5088c..7e755cbed6 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt @@ -34,7 +34,6 @@ import org.gradle.language.jvm.tasks.ProcessResources import org.gradle.process.CommandLineArgumentProvider import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry import org.gradle.util.GradleVersion -import org.jetbrains.kotlin.buildtools.api.SourcesChanges import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import org.jetbrains.kotlin.gradle.internal.kapt.incremental.CLASS_STRUCTURE_ARTIFACT_TYPE @@ -55,6 +54,7 @@ import org.jetbrains.kotlin.gradle.plugin.SubpluginOption import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion import org.jetbrains.kotlin.gradle.plugin.mpp.* import org.jetbrains.kotlin.gradle.tasks.* +import org.jetbrains.kotlin.incremental.ChangedFiles import org.jetbrains.kotlin.incremental.isJavaFile import org.jetbrains.kotlin.incremental.isKotlinFile import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty @@ -659,7 +659,7 @@ internal fun getClassStructureFiles( // Reuse Kapt's infrastructure to compute affected names in classpath. // This is adapted from KaptTask.findClasspathChanges. internal fun findClasspathChanges( - changes: SourcesChanges, + changes: ChangedFiles, cacheDir: File, allDataFiles: Set, libs: List, @@ -667,8 +667,7 @@ internal fun findClasspathChanges( ): KaptClasspathChanges { cacheDir.mkdirs() - val changedFiles = - (changes as? SourcesChanges.Known)?.let { it.modifiedFiles + it.removedFiles }?.toSet() ?: allDataFiles + val changedFiles = (changes as? ChangedFiles.Known)?.let { it.modified + it.removed }?.toSet() ?: allDataFiles val loadedPrevious = ClasspathSnapshot.ClasspathSnapshotFactory.loadFrom(cacheDir) val previousAndCurrentDataFiles = lazy { loadedPrevious.getAllDataFiles() + allDataFiles } @@ -697,7 +696,7 @@ internal fun findClasspathChanges( ) val classpathChanges = currentSnapshot.diff(previousSnapshot, changedFiles) - if (classpathChanges is KaptClasspathChanges.Unknown || changes is SourcesChanges.Unknown) { + if (classpathChanges is KaptClasspathChanges.Unknown || changes is ChangedFiles.Unknown) { cacheDir.deleteRecursively() cacheDir.mkdirs() } @@ -706,11 +705,11 @@ internal fun findClasspathChanges( return classpathChanges } -internal fun SourcesChanges.hasNonSourceChange(): Boolean { - if (this !is SourcesChanges.Known) +internal fun ChangedFiles.hasNonSourceChange(): Boolean { + if (this !is ChangedFiles.Known) return true - return !(this.modifiedFiles + this.removedFiles).all { + return !(this.modified + this.removed).all { it.isKotlinFile(listOf("kt")) || it.isJavaFile() } } @@ -725,13 +724,13 @@ fun KaptClasspathChanges.toSubpluginOptions(): List { } } -fun SourcesChanges.toSubpluginOptions(): List { - return if (this is SourcesChanges.Known) { +fun ChangedFiles.toSubpluginOptions(): List { + return if (this is ChangedFiles.Known) { val options = mutableListOf() - this.modifiedFiles.filter { it.isKotlinFile(listOf("kt")) || it.isJavaFile() }.ifNotEmpty { + this.modified.filter { it.isKotlinFile(listOf("kt")) || it.isJavaFile() }.ifNotEmpty { options += SubpluginOption("knownModified", map { it.path }.joinToString(File.pathSeparator)) } - this.removedFiles.filter { it.isKotlinFile(listOf("kt")) || it.isJavaFile() }.ifNotEmpty { + this.removed.filter { it.isKotlinFile(listOf("kt")) || it.isJavaFile() }.ifNotEmpty { options += SubpluginOption("knownRemoved", map { it.path }.joinToString(File.pathSeparator)) } options @@ -748,7 +747,7 @@ internal fun createIncrementalChangesTransformer( classpathStructure: Provider, libraries: Provider, processorCP: Provider, -): (SourcesChanges) -> List = { changedFiles -> +): (ChangedFiles) -> List = { changedFiles -> val options = mutableListOf() val apClasspath = processorCP.get().files.toList() if (isKspIncremental) {