diff options
author | Ting-Yuan Huang <laszio@google.com> | 2023-01-04 09:59:38 -0800 |
---|---|---|
committer | laszio <ting-yuan@users.noreply.github.com> | 2023-01-04 14:00:41 -0800 |
commit | 1dd7cc2263e662b42ae5322c670ae96dc4a0583c (patch) | |
tree | 880e8e32ee531b14af3a2a2a88f82cd7a632314b | |
parent | b7280295bc830a15020c6fdf87347c087dc7fcdf (diff) | |
download | ksp-1dd7cc2263e662b42ae5322c670ae96dc4a0583c.tar.gz |
Workaround for kotlin.incremental.useClasspathSnapshot
-rw-r--r-- | gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinFactories.kt | 19 |
1 files changed, 19 insertions, 0 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 be831411..458b38df 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 @@ -80,6 +80,16 @@ class KotlinFactories { return project.tasks.register(taskName, KspTaskJvm::class.java).also { kspTaskProvider -> KotlinCompileConfig(KotlinCompilationInfo(kotlinCompilation)) .execute(kspTaskProvider as TaskProvider<KotlinCompile>) + + // useClasspathSnapshot isn't configurable per task. + // Workaround: enable the other path and ignore irrelevant changes + // See [KotlinCompileConfig] in for details. + // FIXME: make it configurable in upstream or support useClasspathSnapshot == true, if possible. + kspTaskProvider.configure { + if (it.classpathSnapshotProperties.useClasspathSnapshot.get()) { + it.classpathSnapshotProperties.classpath.from(project.provider { it.libraries }) + } + } } } @@ -148,6 +158,15 @@ abstract class KspTaskJvm @Inject constructor( @get:OutputDirectory abstract val destination: Property<File> + // Override incrementalProps to exclude irrelevant changes + override val incrementalProps: List<FileCollection> + get() = listOf( + sources, + javaSources, + commonSourceSet, + classpathSnapshotProperties.classpath, + ) + // Overrding an internal function is hacky. // TODO: Ask upstream to open it. @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE") |