Fix changes in Android layout resources breaks incremental compilation

This only happens when project has 'kotlin-android-extensions' plugin
applied and 'experimental = true' flag is set. On changes in android
layout resources task was running full compilation instead running
incrementally.

^KT-51177 Fixed
This commit is contained in:
Yahor Berdnikau
2022-02-10 14:28:21 +01:00
committed by Space
parent ad72545647
commit 322b10f1bb
2 changed files with 36 additions and 0 deletions
@@ -996,6 +996,41 @@ fun getSomething() = 10
}
}
// KT-51177: when experimental flag is enabled
@Test
fun testIncrementalBuildAfterResourceChangeAndroidExtensions() {
val project = Project("AndroidExtensionsProject")
project.setupWorkingDir()
project.projectDir.resolve("app/build.gradle").appendText(
"""
|
|androidExtensions {
| experimental = true
|}
""".trimMargin()
)
project.build("assembleDebug") {
assertSuccessful()
assertTasksExecuted(":app:compileDebugKotlin")
}
project.projectDir
.resolve("app/src/main/res/layout/activity_main.xml")
.modify {
it.replace("android:layout_width=\"wrap_content\"", "android:layout_width=\"match_parent\"")
}
project.build("assembleDebug") {
assertSuccessful()
assertTasksExecuted(":app:compileDebugKotlin")
assertContainsRegex(
"compilerMode=INCREMENTAL_COMPILER.*areFileChangesKnown=true.*app/build/kotlin".toRegex()
)
}
}
@Test
fun testAndroidDaggerIC() {
val project = Project("AndroidDaggerProject")
@@ -204,6 +204,7 @@ class AndroidSubplugin :
it.inputs.files(getLayoutDirectories(project, resDirectories))
.withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("androidExtensionLayoutsFrom$name")
.skipWhenEmpty(true)
.run {
if (GradleVersion.current() >= GradleVersion.version("6.8")) {
ignoreEmptyDirectories()