Support fileAccessHistoryReportFile in KAPT
This change expanded KAPT to support a new param 'fileAccessHistoryReportFile', which reports all the classes used during annotation processing into a file, in the form of a list of URIs. This is useful for build speed improvements described in https://engineering.fb.com/2017/11/09/android/rethinking-android-app-compilation-with-buck/. Essentially, using the list of used classes, we can compile only the dependencies that are really affected by the developer's code changes and improve Kotlin build speed. ^KT-52853
This commit is contained in:
@@ -58,7 +58,12 @@ class JavaKaptContextTest {
|
||||
)
|
||||
}
|
||||
|
||||
private fun doAnnotationProcessing(javaSourceFile: File, processor: IncrementalProcessor, outputDir: File) {
|
||||
private fun doAnnotationProcessing(
|
||||
javaSourceFile: File,
|
||||
processor: IncrementalProcessor,
|
||||
outputDir: File,
|
||||
fileReadOutput: File? = null
|
||||
) {
|
||||
val options = KaptOptions.Builder().apply {
|
||||
projectBaseDir = javaSourceFile.parentFile
|
||||
|
||||
@@ -67,6 +72,8 @@ class JavaKaptContextTest {
|
||||
stubsOutputDir = outputDir
|
||||
incrementalDataOutputDir = outputDir
|
||||
|
||||
fileReadHistoryReportFile = fileReadOutput
|
||||
|
||||
flags.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS)
|
||||
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
|
||||
}.build()
|
||||
@@ -86,6 +93,26 @@ class JavaKaptContextTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDumpFileReadHistory() {
|
||||
val sourceOutputDir = Files.createTempDirectory("kaptRunner").toFile()
|
||||
val fileReadOutputFile = File.createTempFile("kapt_read_history", ".txt")
|
||||
try {
|
||||
doAnnotationProcessing(
|
||||
File(TEST_DATA_DIR, "Simple.java"),
|
||||
simpleProcessor(),
|
||||
sourceOutputDir,
|
||||
fileReadOutput = fileReadOutputFile
|
||||
)
|
||||
assertTrue(fileReadOutputFile.exists())
|
||||
assertTrue(fileReadOutputFile.readText().contains("generated/MyMethodMyAnnotation.java"))
|
||||
assertTrue(fileReadOutputFile.readText().contains("java/lang/Enum.class"))
|
||||
} finally {
|
||||
sourceOutputDir.deleteRecursively()
|
||||
fileReadOutputFile.delete()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testException() {
|
||||
val exceptionMessage = "Here we are!"
|
||||
|
||||
Reference in New Issue
Block a user