Skip to content

Commit

Permalink
Revert "UPDATE_KOTLIN_VERSION: 1.9.30-dev-2548"
Browse files Browse the repository at this point in the history
This reverts commit aa9b0ef.

(cherry picked from commit ac186ab)
(cherry picked from commit 44a949f)
  • Loading branch information
ting-yuan authored and neetopia committed Apr 5, 2024
1 parent a2b9298 commit ea7e9d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -186,7 +186,7 @@ interface KspTask : Task {
val commandLineArgumentProviders: ListProperty<CommandLineArgumentProvider>

@get:Internal
val incrementalChangesTransformers: ListProperty<(SourcesChanges) -> List<SubpluginOption>>
val incrementalChangesTransformers: ListProperty<(ChangedFiles) -> List<SubpluginOption>>
}

@CacheableTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
import org.gradle.util.GradleVersion
import org.gradle.work.ChangeType
import org.gradle.work.InputChanges
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
Expand All @@ -57,6 +56,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
Expand Down Expand Up @@ -664,16 +664,15 @@ 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<File>,
libs: List<File>,
processorCP: List<File>,
): 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 }
Expand Down Expand Up @@ -702,7 +701,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()
}
Expand All @@ -711,11 +710,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()
}
}
Expand All @@ -730,13 +729,13 @@ fun KaptClasspathChanges.toSubpluginOptions(): List<SubpluginOption> {
}
}

fun SourcesChanges.toSubpluginOptions(): List<SubpluginOption> {
return if (this is SourcesChanges.Known) {
fun ChangedFiles.toSubpluginOptions(): List<SubpluginOption> {
return if (this is ChangedFiles.Known) {
val options = mutableListOf<SubpluginOption>()
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
Expand All @@ -753,7 +752,7 @@ internal fun createIncrementalChangesTransformer(
classpathStructure: Provider<FileCollection>,
libraries: Provider<FileCollection>,
processorCP: Provider<FileCollection>,
): (SourcesChanges) -> List<SubpluginOption> = { changedFiles ->
): (ChangedFiles) -> List<SubpluginOption> = { changedFiles ->
val options = mutableListOf<SubpluginOption>()
val apClasspath = processorCP.get().files.toList()
if (isKspIncremental) {
Expand Down Expand Up @@ -794,7 +793,7 @@ internal fun getCPChanges(
): List<String> {
val apClasspath = processorCP.files.toList()
val changedFiles = if (!inputChanges.isIncremental) {
SourcesChanges.Unknown
ChangedFiles.Unknown()
} else {
incrementalProps.fold(mutableListOf<File>() to mutableListOf<File>()) { (modified, removed), prop ->
inputChanges.getFileChanges(prop).forEach {
Expand All @@ -806,7 +805,7 @@ internal fun getCPChanges(
}
modified to removed
}.run {
SourcesChanges.Known(first, second)
ChangedFiles.Known(first, second)
}
}
val classpathChanges = findClasspathChanges(
Expand Down

0 comments on commit ea7e9d2

Please sign in to comment.