@@ -36,6 +36,7 @@ import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
36
36
import org.gradle.util.GradleVersion
37
37
import org.gradle.work.ChangeType
38
38
import org.gradle.work.InputChanges
39
+ import org.jetbrains.kotlin.buildtools.api.SourcesChanges
39
40
import org.jetbrains.kotlin.config.ApiVersion
40
41
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
41
42
import org.jetbrains.kotlin.gradle.internal.kapt.incremental.CLASS_STRUCTURE_ARTIFACT_TYPE
@@ -56,7 +57,6 @@ import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
56
57
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
57
58
import org.jetbrains.kotlin.gradle.plugin.mpp.*
58
59
import org.jetbrains.kotlin.gradle.tasks.*
59
- import org.jetbrains.kotlin.incremental.ChangedFiles
60
60
import org.jetbrains.kotlin.incremental.isJavaFile
61
61
import org.jetbrains.kotlin.incremental.isKotlinFile
62
62
import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
@@ -661,15 +661,16 @@ internal fun getClassStructureFiles(
661
661
// Reuse Kapt's infrastructure to compute affected names in classpath.
662
662
// This is adapted from KaptTask.findClasspathChanges.
663
663
internal fun findClasspathChanges (
664
- changes : ChangedFiles ,
664
+ changes : SourcesChanges ,
665
665
cacheDir : File ,
666
666
allDataFiles : Set <File >,
667
667
libs : List <File >,
668
668
processorCP : List <File >,
669
669
): KaptClasspathChanges {
670
670
cacheDir.mkdirs()
671
671
672
- val changedFiles = (changes as ? ChangedFiles .Known )?.let { it.modified + it.removed }?.toSet() ? : allDataFiles
672
+ val changedFiles =
673
+ (changes as ? SourcesChanges .Known )?.let { it.modifiedFiles + it.removedFiles }?.toSet() ? : allDataFiles
673
674
674
675
val loadedPrevious = ClasspathSnapshot .ClasspathSnapshotFactory .loadFrom(cacheDir)
675
676
val previousAndCurrentDataFiles = lazy { loadedPrevious.getAllDataFiles() + allDataFiles }
@@ -698,7 +699,7 @@ internal fun findClasspathChanges(
698
699
)
699
700
700
701
val classpathChanges = currentSnapshot.diff(previousSnapshot, changedFiles)
701
- if (classpathChanges is KaptClasspathChanges .Unknown || changes is ChangedFiles .Unknown ) {
702
+ if (classpathChanges is KaptClasspathChanges .Unknown || changes is SourcesChanges .Unknown ) {
702
703
cacheDir.deleteRecursively()
703
704
cacheDir.mkdirs()
704
705
}
@@ -707,11 +708,11 @@ internal fun findClasspathChanges(
707
708
return classpathChanges
708
709
}
709
710
710
- internal fun ChangedFiles .hasNonSourceChange (): Boolean {
711
- if (this !is ChangedFiles .Known )
711
+ internal fun SourcesChanges .hasNonSourceChange (): Boolean {
712
+ if (this !is SourcesChanges .Known )
712
713
return true
713
714
714
- return ! (this .modified + this .removed ).all {
715
+ return ! (this .modifiedFiles + this .removedFiles ).all {
715
716
it.isKotlinFile(listOf (" kt" )) || it.isJavaFile()
716
717
}
717
718
}
@@ -726,13 +727,13 @@ fun KaptClasspathChanges.toSubpluginOptions(): List<SubpluginOption> {
726
727
}
727
728
}
728
729
729
- fun ChangedFiles .toSubpluginOptions (): List <SubpluginOption > {
730
- return if (this is ChangedFiles .Known ) {
730
+ fun SourcesChanges .toSubpluginOptions (): List <SubpluginOption > {
731
+ return if (this is SourcesChanges .Known ) {
731
732
val options = mutableListOf<SubpluginOption >()
732
- this .modified .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
733
+ this .modifiedFiles .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
733
734
options + = SubpluginOption (" knownModified" , map { it.path }.joinToString(File .pathSeparator))
734
735
}
735
- this .removed .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
736
+ this .removedFiles .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
736
737
options + = SubpluginOption (" knownRemoved" , map { it.path }.joinToString(File .pathSeparator))
737
738
}
738
739
options
@@ -749,7 +750,7 @@ internal fun createIncrementalChangesTransformer(
749
750
classpathStructure : Provider <FileCollection >,
750
751
libraries : Provider <FileCollection >,
751
752
processorCP : Provider <FileCollection >,
752
- ): (ChangedFiles ) -> List <SubpluginOption > = { changedFiles ->
753
+ ): (SourcesChanges ) -> List <SubpluginOption > = { changedFiles ->
753
754
val options = mutableListOf<SubpluginOption >()
754
755
val apClasspath = processorCP.get().files.toList()
755
756
if (isKspIncremental) {
@@ -790,7 +791,7 @@ internal fun getCPChanges(
790
791
): List <String > {
791
792
val apClasspath = processorCP.files.toList()
792
793
val changedFiles = if (! inputChanges.isIncremental) {
793
- ChangedFiles .Unknown ()
794
+ SourcesChanges .Unknown
794
795
} else {
795
796
incrementalProps.fold(mutableListOf<File >() to mutableListOf<File >()) { (modified, removed), prop ->
796
797
inputChanges.getFileChanges(prop).forEach {
@@ -802,7 +803,7 @@ internal fun getCPChanges(
802
803
}
803
804
modified to removed
804
805
}.run {
805
- ChangedFiles .Known (first, second)
806
+ SourcesChanges .Known (first, second)
806
807
}
807
808
}
808
809
val classpathChanges = findClasspathChanges(
0 commit comments