Clean-up outputs on non-incremental run
Always clean all outputs on non-incremental run of the Kotlin compile task. #KT-38692 Fixed
This commit is contained in:
committed by
Andrey Uskov
parent
2fd7d64db0
commit
2c5c15f503
+27
@@ -1053,4 +1053,31 @@ class KotlinGradleIT : BaseGradleIT() {
|
||||
assertTasksExecuted(":lib1:compileDebugKotlin")
|
||||
}
|
||||
}
|
||||
|
||||
/** Regression test for KT-38692. */
|
||||
@Test
|
||||
fun testIncrementalWhenNoKotlinSources() = with(
|
||||
Project("kotlinProject")
|
||||
) {
|
||||
setupWorkingDir()
|
||||
assertTrue(this.allKotlinFiles.toList().isNotEmpty())
|
||||
build(":compileKotlin") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
}
|
||||
|
||||
// Remove all Kotlin sources and force non-incremental run
|
||||
allKotlinFiles.forEach { assertTrue(it.delete()) }
|
||||
projectDir.resolve("src/main/java/Sample.java").also {
|
||||
it.parentFile.mkdirs()
|
||||
it.writeText("public class Sample {}")
|
||||
}
|
||||
build("compileKotlin", "--rerun-tasks") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
val compiledKotlinClasses = fileInWorkingDir(classesDir()).allFilesWithExtension("class").toList()
|
||||
|
||||
assertTrue(compiledKotlinClasses.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -334,6 +334,8 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
||||
|
||||
if (!isIncrementalCompilationEnabled()) {
|
||||
clearLocalState("IC is disabled")
|
||||
} else if (!inputs.isIncremental) {
|
||||
clearLocalState("Task cannot run incrementally")
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user