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:
committed by
Yan Zhulanow
parent
7bdda22cfa
commit
f4c6f57354
+8
-4
@@ -51,7 +51,8 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/B.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/baz/UtilKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/foo/A.java").canonicalPath
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/foo/A.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/error/NonExistentClass.java").canonicalPath
|
||||
), getProcessedSources(output)
|
||||
)
|
||||
}
|
||||
@@ -68,7 +69,8 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/B.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/baz/UtilKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/foo/A.java").canonicalPath
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/foo/A.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/error/NonExistentClass.java").canonicalPath
|
||||
),
|
||||
getProcessedSources(output)
|
||||
)
|
||||
@@ -95,7 +97,8 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/B.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/baz/UtilKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/foo/A.java").canonicalPath
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/foo/A.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/error/NonExistentClass.java").canonicalPath
|
||||
), getProcessedSources(output)
|
||||
)
|
||||
}
|
||||
@@ -150,7 +153,8 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
|
||||
fileInWorkingDir("app/build/tmp/kapt3/stubs/main/foo/FooUseAKt.java").canonicalPath,
|
||||
fileInWorkingDir("app/build/tmp/kapt3/stubs/main/foo/FooUseBKt.java").canonicalPath,
|
||||
fileInWorkingDir("app/build/tmp/kapt3/stubs/main/foo/FooUseAAKt.java").canonicalPath,
|
||||
fileInWorkingDir("app/build/tmp/kapt3/stubs/main/foo/FooUseBBKt.java").canonicalPath
|
||||
fileInWorkingDir("app/build/tmp/kapt3/stubs/main/foo/FooUseBBKt.java").canonicalPath,
|
||||
fileInWorkingDir("app/build/tmp/kapt3/stubs/main/error/NonExistentClass.java").canonicalPath
|
||||
|
||||
), getProcessedSources(output)
|
||||
)
|
||||
|
||||
+8
-2
@@ -48,7 +48,12 @@ class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
|
||||
assertEquals(setOf(fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath), getProcessedSources(output))
|
||||
assertEquals(
|
||||
setOf(
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/error/NonExistentClass.java").canonicalPath
|
||||
), getProcessedSources(output)
|
||||
)
|
||||
}
|
||||
|
||||
project.projectFile("B.kt").modify { current ->
|
||||
@@ -60,7 +65,8 @@ class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
|
||||
assertEquals(
|
||||
setOf(
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/B.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/bar/UseBKt.java").canonicalPath,
|
||||
fileInWorkingDir("build/tmp/kapt3/stubs/main/error/NonExistentClass.java").canonicalPath
|
||||
),
|
||||
getProcessedSources(output)
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user