@@ -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
@@ -664,15 +664,16 @@ internal fun getClassStructureFiles(
664
664
// Reuse Kapt's infrastructure to compute affected names in classpath.
665
665
// This is adapted from KaptTask.findClasspathChanges.
666
666
internal fun findClasspathChanges (
667
- changes : ChangedFiles ,
667
+ changes : SourcesChanges ,
668
668
cacheDir : File ,
669
669
allDataFiles : Set <File >,
670
670
libs : List <File >,
671
671
processorCP : List <File >,
672
672
): KaptClasspathChanges {
673
673
cacheDir.mkdirs()
674
674
675
- val changedFiles = (changes as ? ChangedFiles .Known )?.let { it.modified + it.removed }?.toSet() ? : allDataFiles
675
+ val changedFiles =
676
+ (changes as ? SourcesChanges .Known )?.let { it.modifiedFiles + it.removedFiles }?.toSet() ? : allDataFiles
676
677
677
678
val loadedPrevious = ClasspathSnapshot .ClasspathSnapshotFactory .loadFrom(cacheDir)
678
679
val previousAndCurrentDataFiles = lazy { loadedPrevious.getAllDataFiles() + allDataFiles }
@@ -701,7 +702,7 @@ internal fun findClasspathChanges(
701
702
)
702
703
703
704
val classpathChanges = currentSnapshot.diff(previousSnapshot, changedFiles)
704
- if (classpathChanges is KaptClasspathChanges .Unknown || changes is ChangedFiles .Unknown ) {
705
+ if (classpathChanges is KaptClasspathChanges .Unknown || changes is SourcesChanges .Unknown ) {
705
706
cacheDir.deleteRecursively()
706
707
cacheDir.mkdirs()
707
708
}
@@ -710,11 +711,11 @@ internal fun findClasspathChanges(
710
711
return classpathChanges
711
712
}
712
713
713
- internal fun ChangedFiles .hasNonSourceChange (): Boolean {
714
- if (this !is ChangedFiles .Known )
714
+ internal fun SourcesChanges .hasNonSourceChange (): Boolean {
715
+ if (this !is SourcesChanges .Known )
715
716
return true
716
717
717
- return ! (this .modified + this .removed ).all {
718
+ return ! (this .modifiedFiles + this .removedFiles ).all {
718
719
it.isKotlinFile(listOf (" kt" )) || it.isJavaFile()
719
720
}
720
721
}
@@ -729,13 +730,13 @@ fun KaptClasspathChanges.toSubpluginOptions(): List<SubpluginOption> {
729
730
}
730
731
}
731
732
732
- fun ChangedFiles .toSubpluginOptions (): List <SubpluginOption > {
733
- return if (this is ChangedFiles .Known ) {
733
+ fun SourcesChanges .toSubpluginOptions (): List <SubpluginOption > {
734
+ return if (this is SourcesChanges .Known ) {
734
735
val options = mutableListOf<SubpluginOption >()
735
- this .modified .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
736
+ this .modifiedFiles .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
736
737
options + = SubpluginOption (" knownModified" , map { it.path }.joinToString(File .pathSeparator))
737
738
}
738
- this .removed .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
739
+ this .removedFiles .filter { it.isKotlinFile(listOf (" kt" )) || it.isJavaFile() }.ifNotEmpty {
739
740
options + = SubpluginOption (" knownRemoved" , map { it.path }.joinToString(File .pathSeparator))
740
741
}
741
742
options
@@ -752,7 +753,7 @@ internal fun createIncrementalChangesTransformer(
752
753
classpathStructure : Provider <FileCollection >,
753
754
libraries : Provider <FileCollection >,
754
755
processorCP : Provider <FileCollection >,
755
- ): (ChangedFiles ) -> List <SubpluginOption > = { changedFiles ->
756
+ ): (SourcesChanges ) -> List <SubpluginOption > = { changedFiles ->
756
757
val options = mutableListOf<SubpluginOption >()
757
758
val apClasspath = processorCP.get().files.toList()
758
759
if (isKspIncremental) {
@@ -793,7 +794,7 @@ internal fun getCPChanges(
793
794
): List <String > {
794
795
val apClasspath = processorCP.files.toList()
795
796
val changedFiles = if (! inputChanges.isIncremental) {
796
- ChangedFiles .Unknown ()
797
+ SourcesChanges .Unknown
797
798
} else {
798
799
incrementalProps.fold(mutableListOf<File >() to mutableListOf<File >()) { (modified, removed), prop ->
799
800
inputChanges.getFileChanges(prop).forEach {
@@ -805,7 +806,7 @@ internal fun getCPChanges(
805
806
}
806
807
modified to removed
807
808
}.run {
808
- ChangedFiles .Known (first, second)
809
+ SourcesChanges .Known (first, second)
809
810
}
810
811
}
811
812
val classpathChanges = findClasspathChanges(
0 commit comments