KT-34194: Pass error/NonExistentClass for incremental KAPT run

When running KAPT incrementally, make sure to pass error/NonExistentClass.java
when there is at least one source file to process. This is to make sure
APs that must resolve all types are able to do so.

Test: updated KaptIncrementalWithAggregating/WithIsolating
This commit is contained in:
Ivan Gavrilovic
2019-10-16 11:48:51 +01:00
committed by Yan Zhulanow
parent 7bdda22cfa
commit f4c6f57354
3 changed files with 31 additions and 7 deletions
@@ -148,7 +148,21 @@ fun KaptOptions.collectJavaSourceFiles(sourcesToReprocess: SourcesToReprocess =
return when (sourcesToReprocess) {
is SourcesToReprocess.FullRebuild -> allSources()
is SourcesToReprocess.Incremental -> sourcesToReprocess.toReprocess.filter { it.exists() }
is SourcesToReprocess.Incremental -> {
val toReprocess = sourcesToReprocess.toReprocess.filter { it.exists() }
if (toReprocess.isNotEmpty()) {
// Make sure to add error/NonExistentClass.java when there are sources to re-process, as
// this class is never reported as changed. See https://youtrack.jetbrains.com/issue/KT-34194 for details.
val nonExistentClass = stubsOutputDir.resolve("error/NonExistentClass.java")
if (nonExistentClass.exists()) {
toReprocess + nonExistentClass
} else {
toReprocess
}
} else {
emptyList()
}
}
}
}