Fix changes in Android Java sources prevents incremental compilation
Such sources are attached to kapt generate stubs task to re-trigger it on Java sources change, but they are not participate in actual stubs generation. ^KT-50664 Fixed
This commit is contained in:
+51
@@ -376,6 +376,57 @@ abstract class Kapt3AndroidIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun generateStubsTaskShouldRunIncrementallyOnChangesInAndroidVariantJavaSources() {
|
||||
with(Project("android-dagger", directoryPrefix = "kapt2")) {
|
||||
setupWorkingDir()
|
||||
|
||||
val javaFile = projectDir.resolve("app/src/main/java/com/example/dagger/kotlin/Utils.java")
|
||||
javaFile.writeText(
|
||||
//language=Java
|
||||
"""
|
||||
package com.example.dagger.kotlin;
|
||||
|
||||
class Utils {
|
||||
public String oneMethod() {
|
||||
return "fake!";
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
build(":app:kaptDebugKotlin") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":app:kaptGenerateStubsDebugKotlin")
|
||||
}
|
||||
|
||||
javaFile.writeText(
|
||||
//language=Java
|
||||
"""
|
||||
package com.example.dagger.kotlin;
|
||||
|
||||
class Utils {
|
||||
public String oneMethod() {
|
||||
return "fake!";
|
||||
}
|
||||
|
||||
public void anotherMethod() {
|
||||
int one = 1;
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
build(":app:kaptDebugKotlin") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":app:kaptGenerateStubsDebugKotlin")
|
||||
assertNotContains(
|
||||
"The input changes require a full rebuild for incremental task ':app:kaptGenerateStubsDebugKotlin'."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupDataBinding(project: Project) {
|
||||
project.setupWorkingDir()
|
||||
|
||||
|
||||
+2
@@ -22,6 +22,7 @@ import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.work.Incremental
|
||||
import org.gradle.workers.WorkerExecutor
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl
|
||||
@@ -115,6 +116,7 @@ abstract class KaptGenerateStubsTask @Inject constructor(
|
||||
@get:InputFiles
|
||||
@get:IgnoreEmptyDirectories
|
||||
@get:PathSensitive(PathSensitivity.RELATIVE)
|
||||
@get:Incremental
|
||||
abstract val additionalSources: ConfigurableFileCollection
|
||||
|
||||
override fun source(vararg sources: Any): SourceTask {
|
||||
|
||||
Reference in New Issue
Block a user