Skip to content

Commit

Permalink
Revert "Reapply "UPDATE_KOTLIN_VERSION: 1.9.30-dev-2548""
Browse files Browse the repository at this point in the history
This reverts commit e145cba.
  • Loading branch information
neetopia committed Dec 25, 2023
1 parent bba762b commit 3c95fb1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 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 @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -659,16 +659,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 @@ -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()
}
Expand All @@ -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()
}
}
Expand All @@ -725,13 +724,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 @@ -748,7 +747,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

0 comments on commit 3c95fb1

Please sign in to comment.