Track inter-project IC changes for Java

This commit is contained in:
Alexey Tsvetkov
2018-05-16 16:13:55 +03:00
parent 6a45310830
commit 61e330fa57
3 changed files with 12 additions and 4 deletions
@@ -361,6 +361,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
for (task in project.tasks.withType(KotlinCompile::class.java)) {
val module = IncrementalModuleEntry(project.path, task.moduleName, project.buildDir, task.buildHistoryFile)
dirToModule[task.destinationDir] = module
task.javaOutputDir?.let { dirToModule[it] = module }
nameToModules.getOrPut(module.name) { HashSet() }.add(module)
}
}
@@ -632,6 +632,8 @@ abstract class AbstractAndroidProjectHandler<V>(private val kotlinConfigurationT
}
internal fun configureJavaTask(kotlinTask: KotlinCompile, javaTask: AbstractCompile, logger: Logger) {
kotlinTask.javaOutputDir = javaTask.destinationDir
// Gradle Java IC in older Gradle versions (before 2.14) cannot check .class directories updates.
// To make it work, reset the up-to-date status of compileJava with this flag.
kotlinTask.anyClassesCompiled = false
@@ -185,10 +185,15 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
@get:Internal // takes part in the compiler arguments
var friendPaths: Lazy<Array<String>?> = lazy {
friendTask?.let { friendTask ->
mutableListOf<String>().apply {
add((friendTask.javaOutputDir ?: friendTask.destinationDir).absolutePath)
addAll(friendTask.attachedClassesDirs.mapNotNull { it.value?.absolutePath })
}.toTypedArray()
val possibleFriendDirs = ArrayList<File?>().apply {
add(friendTask.javaOutputDir)
add(friendTask.destinationDir)
addAll(friendTask.attachedClassesDirs.map { it.value })
}
possibleFriendDirs.filterNotNullTo(HashSet())
.map { it.absolutePath }
.toTypedArray()
}
}