KT-33515: Remove Kotlin sources generated by KAPT

When KAPT is unable to run incrementally make sure to
clean directory that contains generated Kotlin sources.
This location is specified using '-Akapt.kotlin.generated'
option.
This commit is contained in:
Ivan Gavrilovic
2019-08-27 13:11:35 +02:00
committed by Yan Zhulanow
parent 434fb75eb7
commit 60fa632d02
3 changed files with 11 additions and 8 deletions
@@ -73,6 +73,9 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge
}
deleteAndCreate(options.sourcesOutputDir)
deleteAndCreate(options.classesOutputDir)
options.getKotlinGeneratedSourcesDirectory()?.let {
deleteAndCreate(it)
}
}
} else {
sourcesToReprocess = SourcesToReprocess.FullRebuild
@@ -9,6 +9,8 @@ import org.jetbrains.kotlin.kapt3.base.incremental.SourcesToReprocess
import java.io.File
import java.nio.file.Files
private const val KAPT_KOTLIN_GENERATED_OPTION_NAME = "kapt.kotlin.generated"
class KaptOptions(
val projectBaseDir: File?,
val compileClasspath: List<File>,
@@ -80,6 +82,11 @@ class KaptOptions(
)
}
}
fun getKotlinGeneratedSourcesDirectory(): File? {
val value = processingOptions[KAPT_KOTLIN_GENERATED_OPTION_NAME] ?: return null
return File(value).takeIf { it.exists() }
}
}
interface KaptFlags {