Avoid rebuilds after changes of layouts xml-files
This commit makes IC react more granularly on these changes Precisely, it marks dirty only kt-files that having lookups into synthetic package built upon a changed layout-file #KT-21622 Fixed
This commit is contained in:
+27
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.getFilesByNames
|
||||
import org.jetbrains.kotlin.gradle.util.isLegacyAndroidGradleVersion
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
@@ -212,6 +213,32 @@ fun getSomething() = 10
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAndroidExtensionsIncremental() {
|
||||
val project = Project("AndroidExtensionsProject", gradleVersion)
|
||||
val options = defaultBuildOptions().copy(incremental = true)
|
||||
|
||||
project.build("assembleDebug", options = options) {
|
||||
assertSuccessful()
|
||||
val affectedSources = project.projectDir.getFilesByNames(
|
||||
"MyActivity.kt", "noLayoutUsages.kt"
|
||||
)
|
||||
val relativePaths = project.relativize(affectedSources)
|
||||
assertCompiledKotlinSources(relativePaths)
|
||||
}
|
||||
|
||||
val activityLayout = project.projectFile("activity_main.xml")
|
||||
activityLayout.modify { it.replace("textView", "newTextView") }
|
||||
|
||||
project.build("assembleDebug", options = options) {
|
||||
assertFailed()
|
||||
val affectedSources = project.projectDir.getFilesByNames("MyActivity.kt")
|
||||
val relativePaths = project.relativize(affectedSources)
|
||||
assertCompiledKotlinSources(relativePaths)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testAndroidExtensionsManyVariants() {
|
||||
val project = Project("AndroidExtensionsManyVariants", gradleVersion)
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ import kotlinx.android.synthetic.main.activity_main.textView
|
||||
|
||||
class HomeActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
myUtilFunction()
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.example.androidextensions
|
||||
|
||||
fun myUtilFunction() = "OK"
|
||||
Reference in New Issue
Block a user