From 18e0baa13e713f78d8d22556f9fe273067907db9 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Mon, 30 Jan 2017 18:48:07 +0300 Subject: [PATCH] Kapt: Allow empty .kt files list in kapt in order to support kapt with Java-only source files. (KT-15675) --- .../src/org/jetbrains/kotlin/kapt3/Kapt3Extension.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/Kapt3Extension.kt b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/Kapt3Extension.kt index 57bb336cf1d..fcfd5f71913 100644 --- a/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/Kapt3Extension.kt +++ b/plugins/kapt3/src/org/jetbrains/kotlin/kapt3/Kapt3Extension.kt @@ -126,11 +126,6 @@ abstract class AbstractKapt3Extension( fun doNotGenerateCode() = AnalysisResult.Companion.success(BindingContext.EMPTY, module, shouldGenerateCode = false) - if (files.isEmpty()) { - logger.info("No Kotlin source files, aborting") - return if (aptOnly) doNotGenerateCode() else null - } - logger.info { "Initial analysis took ${System.currentTimeMillis() - pluginInitializedTime} ms" } logger.info { "Kotlin files to compile: " + files.map { it.virtualFile?.name ?: "" } } @@ -154,6 +149,12 @@ abstract class AbstractKapt3Extension( if (thr !is KaptError || thr.kind != KaptError.Kind.ERROR_RAISED) { logger.exception(thr) } + + // We don't have any Kotlin files, so there isn't anything we can report diagnostic on + if (files.isEmpty()) { + throw thr + } + bindingTrace.report(ErrorsKapt3.KAPT3_PROCESSING_ERROR.on(files.first())) return null // Compilation will be aborted anyway because of the error above } finally {