Don't create the Kapt generate stubs output dir in lazy initializer
Creating a directory in the property getter interferes with Gradle cache outputs snapshotting, resulting in build cache being disabled for the task with the following info message: Caching disabled for task ':app:kaptGenerateStubsKotlin': Gradle does not know how file 'build/tmp/kapt3/incrementalData/main' was created (output property 'destinationDir'). Task output caching requires exclusive access to output paths to guarantee correctness. As Gradle automatically creates any @OutputDirectory, we don't need to create it at the task initialization phase.
This commit is contained in:
+7
-5
@@ -162,15 +162,17 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
|
|
||||||
override fun isApplicable(project: Project, task: AbstractCompile) = task is KotlinCompile && Kapt3GradleSubplugin.isEnabled(project)
|
override fun isApplicable(project: Project, task: AbstractCompile) = task is KotlinCompile && Kapt3GradleSubplugin.isEnabled(project)
|
||||||
|
|
||||||
private fun Kapt3SubpluginContext.getKaptStubsDir() = createAndReturnTemporaryKaptDirectory("stubs")
|
private fun Kapt3SubpluginContext.getKaptStubsDir() = temporaryKaptDirectory("stubs")
|
||||||
|
|
||||||
private fun Kapt3SubpluginContext.getKaptIncrementalDataDir() = createAndReturnTemporaryKaptDirectory("incrementalData")
|
private fun Kapt3SubpluginContext.getKaptIncrementalDataDir() = temporaryKaptDirectory("incrementalData", doMkDirs = false)
|
||||||
|
|
||||||
private fun Kapt3SubpluginContext.getKaptIncrementalAnnotationProcessingCache() = createAndReturnTemporaryKaptDirectory("incApCache")
|
private fun Kapt3SubpluginContext.getKaptIncrementalAnnotationProcessingCache() = temporaryKaptDirectory("incApCache")
|
||||||
|
|
||||||
private fun Kapt3SubpluginContext.createAndReturnTemporaryKaptDirectory(name: String): File {
|
private fun Kapt3SubpluginContext.temporaryKaptDirectory(name: String, doMkDirs: Boolean = true): File {
|
||||||
val dir = File(project.buildDir, "tmp/kapt3/$name/$sourceSetName")
|
val dir = File(project.buildDir, "tmp/kapt3/$name/$sourceSetName")
|
||||||
dir.mkdirs()
|
if (doMkDirs) {
|
||||||
|
dir.mkdirs()
|
||||||
|
}
|
||||||
return dir
|
return dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user