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
@@ -66,8 +66,6 @@ import java.io.Writer
import java.net.URLClassLoader
import javax.annotation.processing.Processor
private const val KAPT_KOTLIN_GENERATED_OPTION_NAME = "kapt.kotlin.generated"
class ClasspathBasedKapt3Extension(
options: KaptOptions,
logger: MessageCollectorBackedKaptLogger,
@@ -209,17 +207,12 @@ abstract class AbstractKapt3Extension(
bindingTrace.bindingContext,
module,
listOf(options.sourcesOutputDir),
listOfNotNull(options.sourcesOutputDir, getKotlinGeneratedSourcesDirectory()),
listOfNotNull(options.sourcesOutputDir, options.getKotlinGeneratedSourcesDirectory()),
addToEnvironment = true
)
}
}
private fun getKotlinGeneratedSourcesDirectory(): File? {
val value = options.processingOptions[KAPT_KOTLIN_GENERATED_OPTION_NAME] ?: return null
return File(value).takeIf { it.exists() }
}
private fun runAnnotationProcessing(kaptContext: KaptContext, processors: LoadedProcessors) {
if (!options.mode.runAnnotationProcessing) return