Fixes to KAPT classpath change detection
1) Fix tests to use canonical path for comparison because Mac was failing 2) Update current classpath snapshot only with the missing entries from the previous one 3) Clean-up code and style
This commit is contained in:
committed by
Alexey Tsvetkov
parent
7c78644eb9
commit
929fca03fd
@@ -59,7 +59,7 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge
|
||||
cacheManager = options.incrementalCache?.let {
|
||||
JavaClassCacheManager(it)
|
||||
}
|
||||
if (options.processIncrementally) {
|
||||
if (options.flags[KaptFlag.INCREMENTAL_APT]) {
|
||||
sourcesToReprocess =
|
||||
cacheManager?.invalidateAndGetDirtyFiles(
|
||||
options.changedFiles, options.classpathChanges
|
||||
|
||||
@@ -18,7 +18,6 @@ class KaptOptions(
|
||||
val compiledSources: List<File>,
|
||||
val incrementalCache: File?,
|
||||
val classpathChanges: List<String>,
|
||||
val processIncrementally: Boolean,
|
||||
|
||||
val sourcesOutputDir: File,
|
||||
val classesOutputDir: File,
|
||||
@@ -52,7 +51,6 @@ class KaptOptions(
|
||||
var classesOutputDir: File? = null
|
||||
var stubsOutputDir: File? = null
|
||||
var incrementalDataOutputDir: File? = null
|
||||
var processIncrementally: Boolean = false
|
||||
|
||||
val processingClasspath: MutableList<File> = mutableListOf()
|
||||
val processors: MutableList<String> = mutableListOf()
|
||||
@@ -75,7 +73,7 @@ class KaptOptions(
|
||||
|
||||
return KaptOptions(
|
||||
projectBaseDir, compileClasspath, javaSourceRoots,
|
||||
changedFiles, compiledSources, incrementalCache, classpathChanges, processIncrementally,
|
||||
changedFiles, compiledSources, incrementalCache, classpathChanges,
|
||||
sourcesOutputDir, classesOutputDir, stubsOutputDir, incrementalDataOutputDir,
|
||||
processingClasspath, processors, processingOptions, javacOptions, KaptFlags.fromSet(flags),
|
||||
mode, detectMemoryLeaks
|
||||
@@ -106,7 +104,9 @@ enum class KaptFlag(val description: String) {
|
||||
CORRECT_ERROR_TYPES("Correct error types"),
|
||||
MAP_DIAGNOSTIC_LOCATIONS("Map diagnostic locations"),
|
||||
STRICT("Strict mode"),
|
||||
INCLUDE_COMPILE_CLASSPATH("Detect annotation processors in compile classpath");
|
||||
INCLUDE_COMPILE_CLASSPATH("Detect annotation processors in compile classpath"),
|
||||
INCREMENTAL_APT("Incremental annotation processing (apt mode)"),
|
||||
;
|
||||
}
|
||||
|
||||
interface KaptSelector {
|
||||
@@ -172,5 +172,4 @@ fun KaptOptions.logString(additionalInfo: String = "") = buildString {
|
||||
appendln("[incremental apt] Compiled sources directories: ${compiledSources.joinToString()}")
|
||||
appendln("[incremental apt] Cache directory for incremental compilation: $incrementalCache")
|
||||
appendln("[incremental apt] Changed classpath names: ${classpathChanges.joinToString()}")
|
||||
appendln("[incremental apt] If processing incrementally: $processIncrementally")
|
||||
}
|
||||
+1
-3
@@ -211,9 +211,7 @@ class SourceFileStructure(
|
||||
|
||||
fun addMentionedConstant(containingClass: String, name: String) {
|
||||
if (!declaredTypes.contains(containingClass)) {
|
||||
val names = mentionedConstants[containingClass] ?: HashSet()
|
||||
names.add(name)
|
||||
mentionedConstants[containingClass] = names
|
||||
mentionedConstants.getOrPut(containingClass) { HashSet() }.add(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.kapt.base.test.org.jetbrains.kotlin.kapt3.base.incremental
|
||||
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptFlag
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptOptions
|
||||
import org.jetbrains.kotlin.base.kapt3.collectJavaSourceFiles
|
||||
import org.jetbrains.kotlin.kapt3.base.KaptContext
|
||||
@@ -70,7 +71,7 @@ class IncrementalKaptTest {
|
||||
incrementalCache = incrementalCacheDir
|
||||
compiledSources.add(classesOutput)
|
||||
changedFiles.add(sourcesDir.resolve("User.java"))
|
||||
processIncrementally = true
|
||||
flags.add(KaptFlag.INCREMENTAL_APT)
|
||||
}.build()
|
||||
|
||||
KaptContext(optionsForSecondRun, true, logger).use {
|
||||
@@ -144,7 +145,7 @@ class IncrementalKaptTest {
|
||||
incrementalCache = incrementalCacheDir
|
||||
compiledSources.add(classesOutput)
|
||||
changedFiles.add(sourcesDir.resolve("User.java"))
|
||||
processIncrementally = true
|
||||
flags.add(KaptFlag.INCREMENTAL_APT)
|
||||
}.build()
|
||||
|
||||
KaptContext(optionsForSecondRun, true, logger).use {
|
||||
|
||||
@@ -101,7 +101,7 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
|
||||
COMPILED_SOURCES_DIR -> compiledSources.addAll(value.split(File.pathSeparator).map { File(it) })
|
||||
INCREMENTAL_CACHE -> incrementalCache = File(value)
|
||||
CLASSPATH_CHANGES -> classpathChanges.addAll(value.split(File.pathSeparator).map { it })
|
||||
PROCESS_INCREMENTALLY -> processIncrementally = value.toBoolean()
|
||||
PROCESS_INCREMENTALLY -> setFlag(KaptFlag.INCREMENTAL_APT, value)
|
||||
|
||||
ANNOTATION_PROCESSOR_CLASSPATH_OPTION -> processingClasspath += File(value)
|
||||
ANNOTATION_PROCESSORS_OPTION -> processors.addAll(value.split(',').map { it.trim() }.filter { it.isNotEmpty() })
|
||||
|
||||
Reference in New Issue
Block a user