Fix unrelated tasks being configured at execution time, KT-31666

Replace iteration over all tasks with `.matching { ... }` with `
.configureEach { if (...) ... }`, so that the check iterates
just over those tasks which are triggered to configure from
somewhere else.

Issue #KT-31666 Fixed
This commit is contained in:
Sergey Igushkin
2019-08-05 14:23:30 +03:00
parent 9182fe887e
commit 88e5d2bc70
2 changed files with 53 additions and 7 deletions
@@ -0,0 +1,31 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle
import org.junit.Test
class ConfigurationAvoidanceIT : BaseGradleIT() {
@Test
fun testUnrelatedTaskNotConfigured() = with(Project("simpleProject", GradleVersionRequired.AtLeast("4.10.2"))) {
setupWorkingDir()
val expensivelyConfiguredTaskName = "expensivelyConfiguredTask"
val triggeredExpensiveConfigurationText = "Triggered expensive configuration!"
gradleBuildScript().appendText("\n" + """
tasks.register("$expensivelyConfiguredTaskName") {
println("$triggeredExpensiveConfigurationText")
}
""".trimIndent())
build("compileKotlin") {
assertSuccessful()
assertNotContains(triggeredExpensiveConfigurationText)
}
}
}