Do not load annotation processors when generating stubs

#KT-25131 fixed
This commit is contained in:
Alexey Tsvetkov
2018-06-23 01:27:35 +03:00
parent f438b7501c
commit 5bf5632886
@@ -145,10 +145,20 @@ abstract class AbstractKapt3Extension(
logger.info { "Initial analysis took ${System.currentTimeMillis() - pluginInitializedTime} ms" }
val bindingContext = bindingTrace.bindingContext
if (aptMode.generateStubs) {
logger.info { "Kotlin files to compile: " + files.map { it.virtualFile?.name ?: "<in memory ${it.hashCode()}>" } }
val kaptContext = compileStubs(project, module, bindingContext, files.toList())
generateKotlinSourceStubs(kaptContext)
}
if (!aptMode.runAnnotationProcessing) return doNotGenerateCode()
val processors = loadProcessors()
if (processors.isEmpty()) return if (aptMode != WITH_COMPILATION) doNotGenerateCode() else null
val kaptContext = generateStubs(project, module, bindingTrace.bindingContext, files)
val kaptContext = KaptContext(paths, false, logger, mapDiagnosticLocations, options, javacOptions)
fun handleKaptError(error: KaptError): AnalysisResult {
val cause = error.cause
@@ -189,23 +199,6 @@ abstract class AbstractKapt3Extension(
}
}
private fun generateStubs(
project: Project,
module: ModuleDescriptor,
context: BindingContext,
files: Collection<KtFile>
): KaptContext {
if (!aptMode.generateStubs) {
return KaptContext(paths, false, logger, mapDiagnosticLocations, options, javacOptions)
}
logger.info { "Kotlin files to compile: " + files.map { it.virtualFile?.name ?: "<in memory ${it.hashCode()}>" } }
return compileStubs(project, module, context, files.toList()).apply {
generateKotlinSourceStubs(this)
}
}
private fun runAnnotationProcessing(kaptContext: KaptContext, processors: List<Processor>) {
if (!aptMode.runAnnotationProcessing) return