Incremental KAPT - pass changed classpath entries
Pass computed list of changed classpath names to KAPT instead of relying on the history files to be computed by stub generation. Also, stop generating classpath history changes during the stub generation. This commit does not compute the actual changed classpath entries, and that will be done in the following commits. #KT-23880
This commit is contained in:
committed by
Alexey Tsvetkov
parent
0c09f56118
commit
c85e21d43b
@@ -57,11 +57,16 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge
|
||||
KaptJavaCompiler.preRegister(context)
|
||||
|
||||
cacheManager = options.incrementalCache?.let {
|
||||
JavaClassCacheManager(it, options.classpathFqNamesHistory!!)
|
||||
JavaClassCacheManager(it)
|
||||
}
|
||||
if (options.processIncrementally) {
|
||||
sourcesToReprocess =
|
||||
cacheManager?.invalidateAndGetDirtyFiles(
|
||||
options.changedFiles, options.classpathChanges
|
||||
) ?: SourcesToReprocess.FullRebuild
|
||||
} else {
|
||||
sourcesToReprocess = SourcesToReprocess.FullRebuild
|
||||
}
|
||||
sourcesToReprocess = cacheManager?.invalidateAndGetDirtyFiles(
|
||||
options.changedFiles.filter { it.extension == "java" }
|
||||
) ?: SourcesToReprocess.FullRebuild
|
||||
|
||||
javacOptions = Options.instance(context).apply {
|
||||
for ((key, value) in options.processingOptions) {
|
||||
@@ -88,7 +93,7 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge
|
||||
put("accessInternalAPI", "true")
|
||||
}
|
||||
|
||||
val compileClasspath = if (sourcesToReprocess is SourcesToReprocess.FullRebuild || options.changedFiles.isEmpty()) {
|
||||
val compileClasspath = if (sourcesToReprocess is SourcesToReprocess.FullRebuild) {
|
||||
options.compileClasspath
|
||||
} else {
|
||||
options.compileClasspath + options.compiledSources
|
||||
|
||||
@@ -17,7 +17,8 @@ class KaptOptions(
|
||||
val changedFiles: List<File>,
|
||||
val compiledSources: List<File>,
|
||||
val incrementalCache: File?,
|
||||
val classpathFqNamesHistory: File?,
|
||||
val classpathChanges: List<String>,
|
||||
val processIncrementally: Boolean,
|
||||
|
||||
val sourcesOutputDir: File,
|
||||
val classesOutputDir: File,
|
||||
@@ -45,12 +46,13 @@ class KaptOptions(
|
||||
val changedFiles: MutableList<File> = mutableListOf()
|
||||
val compiledSources: MutableList<File> = mutableListOf()
|
||||
var incrementalCache: File? = null
|
||||
var classpathFqNamesHistory: File? = null
|
||||
val classpathChanges: MutableList<String> = mutableListOf()
|
||||
|
||||
var sourcesOutputDir: File? = null
|
||||
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()
|
||||
@@ -73,7 +75,7 @@ class KaptOptions(
|
||||
|
||||
return KaptOptions(
|
||||
projectBaseDir, compileClasspath, javaSourceRoots,
|
||||
changedFiles, compiledSources, incrementalCache, classpathFqNamesHistory,
|
||||
changedFiles, compiledSources, incrementalCache, classpathChanges, processIncrementally,
|
||||
sourcesOutputDir, classesOutputDir, stubsOutputDir, incrementalDataOutputDir,
|
||||
processingClasspath, processors, processingOptions, javacOptions, KaptFlags.fromSet(flags),
|
||||
mode, detectMemoryLeaks
|
||||
@@ -169,5 +171,6 @@ fun KaptOptions.logString(additionalInfo: String = "") = buildString {
|
||||
appendln("[incremental apt] Changed files: $changedFiles")
|
||||
appendln("[incremental apt] Compiled sources directories: ${compiledSources.joinToString()}")
|
||||
appendln("[incremental apt] Cache directory for incremental compilation: $incrementalCache")
|
||||
appendln("[incremental apt] Classpath fq names history dir: $classpathFqNamesHistory")
|
||||
appendln("[incremental apt] Changes classpath names: ${classpathChanges.joinToString()}")
|
||||
appendln("[incremental apt] If processing incrementally: $processIncrementally")
|
||||
}
|
||||
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.kapt3.base.incremental
|
||||
import java.io.*
|
||||
|
||||
// TODO(gavra): switch away from Java serialization
|
||||
class JavaClassCacheManager(val file: File, private val classpathFqNamesHistory: File) : Closeable {
|
||||
class JavaClassCacheManager(val file: File) : Closeable {
|
||||
|
||||
private val javaCacheFile = file.resolve("java-cache.bin")
|
||||
internal val javaCache = maybeGetJavaCacheFromFile()
|
||||
@@ -16,38 +16,8 @@ class JavaClassCacheManager(val file: File, private val classpathFqNamesHistory:
|
||||
private val aptCacheFile = file.resolve("apt-cache.bin")
|
||||
private val aptCache = maybeGetAptCacheFromFile()
|
||||
|
||||
private val lastBuildTimestamp = file.resolve("last-build-ts.bin")
|
||||
|
||||
private var closed = false
|
||||
|
||||
private fun getDirtyFqNamesFromClasspath(): ClasspathChanged {
|
||||
if (!lastBuildTimestamp.exists()) return ClasspathChanged.FullRebuild
|
||||
|
||||
val lastTimestamp = lastBuildTimestamp.readText()
|
||||
|
||||
val (before, after) = classpathFqNamesHistory.listFiles().partition { it.name < lastTimestamp }
|
||||
|
||||
if (before.isEmpty()) {
|
||||
return ClasspathChanged.FullRebuild
|
||||
}
|
||||
|
||||
val dirtyFqNames = mutableSetOf<String>()
|
||||
after.forEach { file ->
|
||||
ObjectInputStream(file.inputStream().buffered()).use {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
dirtyFqNames.addAll(it.readObject() as Collection<String>)
|
||||
}
|
||||
}
|
||||
|
||||
return if (dirtyFqNames.isNotEmpty()) {
|
||||
// TODO(gavra): We need to handle constants from classpath that might change between runs being incremental. One solution
|
||||
// would be to fetch the changed symbols alongside changed fqNames, and to check if the symbol is a constant using ASM.
|
||||
ClasspathChanged.FullRebuild
|
||||
} else {
|
||||
ClasspathChanged.Incremental(dirtyFqNames)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateCache(processors: List<IncrementalProcessor>) {
|
||||
if (!aptCache.updateCache(processors)) {
|
||||
javaCache.invalidateAll()
|
||||
@@ -58,39 +28,38 @@ class JavaClassCacheManager(val file: File, private val classpathFqNamesHistory:
|
||||
* From set of changed sources, get list of files to recompile using structural information and dependency information from
|
||||
* annotation processing.
|
||||
*/
|
||||
fun invalidateAndGetDirtyFiles(changedSources: Collection<File>): SourcesToReprocess {
|
||||
fun invalidateAndGetDirtyFiles(changedSources: Collection<File>, dirtyClasspathJvmNames: Collection<String>): SourcesToReprocess {
|
||||
if (!aptCache.isIncremental) {
|
||||
return SourcesToReprocess.FullRebuild
|
||||
}
|
||||
|
||||
val dirtyFqNamesFromClasspath = getDirtyFqNamesFromClasspath()
|
||||
return when (dirtyFqNamesFromClasspath) {
|
||||
is ClasspathChanged.FullRebuild -> SourcesToReprocess.FullRebuild
|
||||
is ClasspathChanged.Incremental -> {
|
||||
val changes = Changes(changedSources, dirtyFqNamesFromClasspath.dirtyFqNames)
|
||||
val filesToReprocess = javaCache.invalidateEntriesForChangedFiles(changes)
|
||||
val dirtyClasspathFqNames = HashSet<String>(dirtyClasspathJvmNames.size)
|
||||
dirtyClasspathJvmNames.forEach {
|
||||
dirtyClasspathFqNames.add(it.replace("$", ".").replace("/", "."))
|
||||
}
|
||||
|
||||
when (filesToReprocess) {
|
||||
is SourcesToReprocess.FullRebuild -> SourcesToReprocess.FullRebuild
|
||||
is SourcesToReprocess.Incremental -> {
|
||||
val toReprocess = filesToReprocess.toReprocess.toMutableSet()
|
||||
val changes = Changes(changedSources, dirtyClasspathFqNames.toSet())
|
||||
val filesToReprocess = javaCache.invalidateEntriesForChangedFiles(changes)
|
||||
|
||||
val isolatingGenerated = aptCache.invalidateIsolatingGenerated(toReprocess)
|
||||
val generatedDirtyTypes = javaCache.invalidateGeneratedTypes(isolatingGenerated).toMutableSet()
|
||||
return when (filesToReprocess) {
|
||||
is SourcesToReprocess.FullRebuild -> SourcesToReprocess.FullRebuild
|
||||
is SourcesToReprocess.Incremental -> {
|
||||
val toReprocess = filesToReprocess.toReprocess.toMutableSet()
|
||||
|
||||
if (!toReprocess.isEmpty()) {
|
||||
// only if there are some files to reprocess we should invalidate the aggregating ones
|
||||
val aggregatingGenerated = aptCache.invalidateAggregating()
|
||||
generatedDirtyTypes.addAll(javaCache.invalidateGeneratedTypes(aggregatingGenerated))
|
||||
val isolatingGenerated = aptCache.invalidateIsolatingGenerated(toReprocess)
|
||||
val generatedDirtyTypes = javaCache.invalidateGeneratedTypes(isolatingGenerated).toMutableSet()
|
||||
|
||||
toReprocess.addAll(
|
||||
javaCache.invalidateEntriesAnnotatedWith(aptCache.getAggregatingClaimedAnnotations())
|
||||
)
|
||||
}
|
||||
if (!toReprocess.isEmpty()) {
|
||||
// only if there are some files to reprocess we should invalidate the aggregating ones
|
||||
val aggregatingGenerated = aptCache.invalidateAggregating()
|
||||
generatedDirtyTypes.addAll(javaCache.invalidateGeneratedTypes(aggregatingGenerated))
|
||||
|
||||
SourcesToReprocess.Incremental(toReprocess.toList(), generatedDirtyTypes)
|
||||
}
|
||||
toReprocess.addAll(
|
||||
javaCache.invalidateEntriesAnnotatedWith(aptCache.getAggregatingClaimedAnnotations())
|
||||
)
|
||||
}
|
||||
|
||||
SourcesToReprocess.Incremental(toReprocess.toList(), generatedDirtyTypes)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,9 +113,6 @@ class JavaClassCacheManager(val file: File, private val classpathFqNamesHistory:
|
||||
}
|
||||
}
|
||||
|
||||
with(lastBuildTimestamp) {
|
||||
writeText(System.currentTimeMillis().toString())
|
||||
}
|
||||
closed = true
|
||||
}
|
||||
}
|
||||
@@ -154,9 +120,4 @@ class JavaClassCacheManager(val file: File, private val classpathFqNamesHistory:
|
||||
sealed class SourcesToReprocess {
|
||||
class Incremental(val toReprocess: List<File>, val dirtyTypes: Set<String>) : SourcesToReprocess()
|
||||
object FullRebuild : SourcesToReprocess()
|
||||
}
|
||||
|
||||
sealed class ClasspathChanged {
|
||||
class Incremental(val dirtyFqNames: Set<String>) : ClasspathChanged()
|
||||
object FullRebuild : ClasspathChanged()
|
||||
}
|
||||
+8
-17
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.base.kapt3.KaptOptions
|
||||
import org.jetbrains.kotlin.base.kapt3.collectJavaSourceFiles
|
||||
import org.jetbrains.kotlin.kapt3.base.KaptContext
|
||||
import org.jetbrains.kotlin.kapt3.base.doAnnotationProcessing
|
||||
import org.jetbrains.kotlin.kapt3.base.incremental.SourcesToReprocess
|
||||
import org.jetbrains.kotlin.kapt3.base.util.WriterBackedKaptLogger
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
@@ -32,9 +33,6 @@ class IncrementalKaptTest {
|
||||
|
||||
val outputDir = tmp.newFolder()
|
||||
val incrementalCacheDir = tmp.newFolder()
|
||||
val classpathHistory = tmp.newFolder().also {
|
||||
it.resolve("0").createNewFile()
|
||||
}
|
||||
val options = KaptOptions.Builder().apply {
|
||||
projectBaseDir = tmp.newFolder()
|
||||
javaSourceRoots.add(sourcesDir)
|
||||
@@ -45,14 +43,12 @@ class IncrementalKaptTest {
|
||||
incrementalDataOutputDir = outputDir
|
||||
|
||||
incrementalCache = incrementalCacheDir
|
||||
classpathFqNamesHistory = classpathHistory
|
||||
}.build()
|
||||
|
||||
val logger = WriterBackedKaptLogger(isVerbose = true)
|
||||
KaptContext(options, true, logger).use {
|
||||
val toReprocess = it.cacheManager!!.invalidateAndGetDirtyFiles(options.changedFiles)
|
||||
it.doAnnotationProcessing(
|
||||
options.collectJavaSourceFiles(toReprocess), listOf(SimpleProcessor().toIsolating())
|
||||
options.collectJavaSourceFiles(SourcesToReprocess.FullRebuild), listOf(SimpleProcessor().toIsolating())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -72,14 +68,14 @@ class IncrementalKaptTest {
|
||||
incrementalDataOutputDir = outputDir
|
||||
|
||||
incrementalCache = incrementalCacheDir
|
||||
classpathFqNamesHistory = classpathHistory
|
||||
compiledSources.add(classesOutput)
|
||||
changedFiles.add(sourcesDir.resolve("User.java"))
|
||||
processIncrementally = true
|
||||
}.build()
|
||||
|
||||
KaptContext(optionsForSecondRun, true, logger).use {
|
||||
val sourcesToReprocess =
|
||||
it.cacheManager!!.invalidateAndGetDirtyFiles(optionsForSecondRun.changedFiles)
|
||||
it.cacheManager!!.invalidateAndGetDirtyFiles(optionsForSecondRun.changedFiles, emptyList())
|
||||
assertFalse(outputDir.resolve("test/UserGenerated.java").exists())
|
||||
|
||||
it.doAnnotationProcessing(
|
||||
@@ -92,7 +88,7 @@ class IncrementalKaptTest {
|
||||
|
||||
sourcesDir.resolve("User.java").delete()
|
||||
KaptContext(optionsForSecondRun, true, logger).use {
|
||||
val sourcesToReprocess = it.cacheManager!!.invalidateAndGetDirtyFiles(optionsForSecondRun.changedFiles)
|
||||
val sourcesToReprocess = it.cacheManager!!.invalidateAndGetDirtyFiles(optionsForSecondRun.changedFiles, emptyList())
|
||||
|
||||
it.doAnnotationProcessing(
|
||||
optionsForSecondRun.collectJavaSourceFiles(sourcesToReprocess), listOf(SimpleProcessor().toIsolating())
|
||||
@@ -114,9 +110,6 @@ class IncrementalKaptTest {
|
||||
|
||||
val outputDir = tmp.newFolder()
|
||||
val incrementalCacheDir = tmp.newFolder()
|
||||
val classpathHistory = tmp.newFolder().also {
|
||||
it.resolve("0").createNewFile()
|
||||
}
|
||||
val options = KaptOptions.Builder().apply {
|
||||
projectBaseDir = tmp.newFolder()
|
||||
javaSourceRoots.add(sourcesDir)
|
||||
@@ -127,14 +120,12 @@ class IncrementalKaptTest {
|
||||
incrementalDataOutputDir = outputDir
|
||||
|
||||
incrementalCache = incrementalCacheDir
|
||||
classpathFqNamesHistory = classpathHistory
|
||||
}.build()
|
||||
|
||||
val logger = WriterBackedKaptLogger(isVerbose = true)
|
||||
KaptContext(options, true, logger).use {
|
||||
val toReprocess = it.cacheManager!!.invalidateAndGetDirtyFiles(options.changedFiles)
|
||||
it.doAnnotationProcessing(
|
||||
options.collectJavaSourceFiles(toReprocess), listOf(SimpleGeneratingIfTypeDoesNotExist().toIsolating())
|
||||
options.collectJavaSourceFiles(SourcesToReprocess.FullRebuild), listOf(SimpleGeneratingIfTypeDoesNotExist().toIsolating())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -151,14 +142,14 @@ class IncrementalKaptTest {
|
||||
incrementalDataOutputDir = outputDir
|
||||
|
||||
incrementalCache = incrementalCacheDir
|
||||
classpathFqNamesHistory = classpathHistory
|
||||
compiledSources.add(classesOutput)
|
||||
changedFiles.add(sourcesDir.resolve("User.java"))
|
||||
processIncrementally = true
|
||||
}.build()
|
||||
|
||||
KaptContext(optionsForSecondRun, true, logger).use {
|
||||
val sourcesToReprocess =
|
||||
it.cacheManager!!.invalidateAndGetDirtyFiles(optionsForSecondRun.changedFiles)
|
||||
it.cacheManager!!.invalidateAndGetDirtyFiles(optionsForSecondRun.changedFiles, emptyList())
|
||||
assertFalse(outputDir.resolve("test/UserGenerated.java").exists())
|
||||
|
||||
it.doAnnotationProcessing(
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class TestInheritedAnnotation {
|
||||
@BeforeClass
|
||||
fun setUp() {
|
||||
val classpathHistory = tmp.newFolder()
|
||||
cache = JavaClassCacheManager(tmp.newFolder(), classpathHistory)
|
||||
cache = JavaClassCacheManager(tmp.newFolder())
|
||||
generatedSources = tmp.newFolder()
|
||||
cache.close()
|
||||
classpathHistory.resolve("0").createNewFile()
|
||||
|
||||
+9
-45
@@ -22,13 +22,11 @@ class JavaClassCacheManagerTest {
|
||||
|
||||
private lateinit var cache: JavaClassCacheManager
|
||||
private lateinit var cacheDir: File
|
||||
private lateinit var classpathHistory: File
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
cacheDir = tmp.newFolder()
|
||||
classpathHistory = tmp.newFolder()
|
||||
cache = JavaClassCacheManager(cacheDir, classpathHistory)
|
||||
cache = JavaClassCacheManager(cacheDir)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +36,6 @@ class JavaClassCacheManagerTest {
|
||||
|
||||
assertTrue(cacheDir.resolve("java-cache.bin").exists())
|
||||
assertTrue(cacheDir.resolve("apt-cache.bin").exists())
|
||||
assertTrue(cacheDir.resolve("last-build-ts.bin").exists())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,7 +56,7 @@ class JavaClassCacheManagerTest {
|
||||
}
|
||||
prepareForIncremental()
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("Mentioned.java"))) as SourcesToReprocess.Incremental
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("Mentioned.java")), emptyList()) as SourcesToReprocess.Incremental
|
||||
assertEquals(
|
||||
listOf(
|
||||
File("Mentioned.java").absoluteFile,
|
||||
@@ -87,7 +84,7 @@ class JavaClassCacheManagerTest {
|
||||
}
|
||||
prepareForIncremental()
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("Mentioned.java"))) as SourcesToReprocess.Incremental
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("Mentioned.java")), emptyList()) as SourcesToReprocess.Incremental
|
||||
assertEquals(
|
||||
listOf(
|
||||
File("Mentioned.java").absoluteFile,
|
||||
@@ -115,7 +112,7 @@ class JavaClassCacheManagerTest {
|
||||
}
|
||||
prepareForIncremental()
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("TwoTypes.java"))) as SourcesToReprocess.Incremental
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("TwoTypes.java")), emptyList()) as SourcesToReprocess.Incremental
|
||||
assertEquals(
|
||||
listOf(
|
||||
File("TwoTypes.java").absoluteFile,
|
||||
@@ -126,48 +123,16 @@ class JavaClassCacheManagerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoClasspathHistory() {
|
||||
SourceFileStructure(File("Src.java").toURI()).also {
|
||||
it.addDeclaredType("test.Src")
|
||||
cache.javaCache.addSourceStructure(it)
|
||||
}
|
||||
cache.close()
|
||||
classpathHistory.resolve(Long.MAX_VALUE.toString()).createNewFile()
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf())
|
||||
assertEquals(SourcesToReprocess.FullRebuild, dirtyFiles)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWithClasspathHistoryButNoNewChanges() {
|
||||
fun testWithClasspathChanges() {
|
||||
SourceFileStructure(File("Src.java").toURI()).also {
|
||||
it.addDeclaredType("test.Src")
|
||||
it.addMentionedType("test.Mentioned")
|
||||
cache.javaCache.addSourceStructure(it)
|
||||
}
|
||||
prepareForIncremental()
|
||||
ObjectOutputStream(classpathHistory.resolve("0").outputStream()).use {
|
||||
it.writeObject(listOf("test.Mentioned"))
|
||||
}
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf()) as SourcesToReprocess.Incremental
|
||||
assertEquals(emptyList<File>(), dirtyFiles.toReprocess)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWithClasspathHistoryWithChanges() {
|
||||
SourceFileStructure(File("Src.java").toURI()).also {
|
||||
it.addDeclaredType("test.Src")
|
||||
it.addMentionedType("test.Mentioned")
|
||||
cache.javaCache.addSourceStructure(it)
|
||||
}
|
||||
prepareForIncremental()
|
||||
ObjectOutputStream(classpathHistory.resolve(Long.MAX_VALUE.toString()).outputStream()).use {
|
||||
it.writeObject(listOf("test.Mentioned"))
|
||||
}
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf())
|
||||
assertEquals(SourcesToReprocess.FullRebuild, dirtyFiles)
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(), listOf("test/Mentioned")) as SourcesToReprocess.Incremental
|
||||
assertEquals(listOf(File("Src.java").absoluteFile), dirtyFiles.toReprocess)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -187,7 +152,7 @@ class JavaClassCacheManagerTest {
|
||||
}
|
||||
prepareForIncremental()
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("Constants.java")))
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(File("Constants.java")), emptyList())
|
||||
assertEquals(SourcesToReprocess.FullRebuild, dirtyFiles)
|
||||
}
|
||||
|
||||
@@ -217,7 +182,6 @@ class JavaClassCacheManagerTest {
|
||||
|
||||
private fun prepareForIncremental() {
|
||||
cache.close()
|
||||
classpathHistory.resolve("0").createNewFile()
|
||||
cache = JavaClassCacheManager(cacheDir, classpathHistory)
|
||||
cache = JavaClassCacheManager(cacheDir)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -32,11 +32,9 @@ class ReferencedConstantsTest {
|
||||
val compiledClasses = tmp.newFolder()
|
||||
compileSources(listOf(MY_TEST_DIR.resolve("CKlass.java")), compiledClasses)
|
||||
|
||||
val classpathHistory = tmp.newFolder()
|
||||
cache = JavaClassCacheManager(tmp.newFolder(), classpathHistory)
|
||||
cache = JavaClassCacheManager(tmp.newFolder())
|
||||
generatedSources = tmp.newFolder()
|
||||
cache.close()
|
||||
classpathHistory.resolve("0").createNewFile()
|
||||
val processor = SimpleProcessor().toAggregating()
|
||||
val srcFiles = listOf(
|
||||
"A.java",
|
||||
|
||||
+1
-3
@@ -29,11 +29,9 @@ class TestComplexIncrementalAptCache {
|
||||
@JvmStatic
|
||||
@BeforeClass
|
||||
fun setUp() {
|
||||
val classpathHistory = tmp.newFolder()
|
||||
cache = JavaClassCacheManager(tmp.newFolder(), classpathHistory)
|
||||
cache = JavaClassCacheManager(tmp.newFolder())
|
||||
generatedSources = tmp.newFolder()
|
||||
cache.close()
|
||||
classpathHistory.resolve("0").createNewFile()
|
||||
val processor = SimpleProcessor().toAggregating()
|
||||
val srcFiles = listOf(
|
||||
"MyEnum.java",
|
||||
|
||||
+4
-6
@@ -27,18 +27,16 @@ class TestSimpleIncrementalAptCache {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val classpathHistory = tmp.newFolder()
|
||||
cache = JavaClassCacheManager(tmp.newFolder(), classpathHistory)
|
||||
cache = JavaClassCacheManager(tmp.newFolder())
|
||||
generatedSources = tmp.newFolder()
|
||||
cache.close()
|
||||
classpathHistory.resolve("0").createNewFile()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAggregatingAnnotations() {
|
||||
runProcessor(SimpleProcessor().toAggregating())
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(TEST_DATA_DIR.resolve("User.java"))) as SourcesToReprocess.Incremental
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(TEST_DATA_DIR.resolve("User.java")), emptyList()) as SourcesToReprocess.Incremental
|
||||
assertEquals(
|
||||
listOf(TEST_DATA_DIR.resolve("User.java").absoluteFile, TEST_DATA_DIR.resolve("Address.java").absoluteFile),
|
||||
dirtyFiles.toReprocess
|
||||
@@ -51,7 +49,7 @@ class TestSimpleIncrementalAptCache {
|
||||
fun testIsolatingAnnotations() {
|
||||
runProcessor(SimpleProcessor().toIsolating())
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(TEST_DATA_DIR.resolve("User.java"))) as SourcesToReprocess.Incremental
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(TEST_DATA_DIR.resolve("User.java")), emptyList()) as SourcesToReprocess.Incremental
|
||||
assertFalse(generatedSources.resolve("test/UserGenerated.java").exists())
|
||||
assertEquals(
|
||||
listOf(TEST_DATA_DIR.resolve("User.java").absoluteFile),
|
||||
@@ -63,7 +61,7 @@ class TestSimpleIncrementalAptCache {
|
||||
fun testNonIncremental() {
|
||||
runProcessor(SimpleProcessor().toNonIncremental())
|
||||
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(TEST_DATA_DIR.resolve("User.java")))
|
||||
val dirtyFiles = cache.invalidateAndGetDirtyFiles(listOf(TEST_DATA_DIR.resolve("User.java")), emptyList())
|
||||
assertTrue(dirtyFiles is SourcesToReprocess.FullRebuild)
|
||||
}
|
||||
|
||||
|
||||
@@ -90,10 +90,16 @@ enum class KaptCliOption(
|
||||
"Use only in apt mode. Output directory for cache necessary to support incremental annotation processing."
|
||||
),
|
||||
|
||||
CLASSPATH_FQ_NAMES_HISTORY(
|
||||
"classpathFqNamesHistory",
|
||||
"<path>",
|
||||
"Use only in apt mode. Directory containing history of classpath fq name changes."
|
||||
CLASSPATH_CHANGES(
|
||||
"classpathChange",
|
||||
"<jvmInternalName,[jvmInternalName,...]>",
|
||||
"Use only in apt mode. Classpath jvm internal names that changed."
|
||||
),
|
||||
|
||||
PROCESS_INCREMENTALLY(
|
||||
"processIncrementally",
|
||||
"boolean",
|
||||
"Use only in apt mode. Enables incremental apt processing"
|
||||
),
|
||||
|
||||
ANNOTATION_PROCESSOR_CLASSPATH_OPTION(
|
||||
|
||||
@@ -100,7 +100,8 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
|
||||
CHANGED_FILES -> changedFiles.addAll(value.split(File.pathSeparator).map { File(it) })
|
||||
COMPILED_SOURCES_DIR -> compiledSources.addAll(value.split(File.pathSeparator).map { File(it) })
|
||||
INCREMENTAL_CACHE -> incrementalCache = File(value)
|
||||
CLASSPATH_FQ_NAMES_HISTORY -> classpathFqNamesHistory = File(value)
|
||||
CLASSPATH_CHANGES -> classpathChanges.addAll(value.split(File.pathSeparator).map { it })
|
||||
PROCESS_INCREMENTALLY -> processIncrementally = value.toBoolean()
|
||||
|
||||
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