val componentTest by tasks.named<Test>("componentTest")
dockerCompose {
isRequiredBy(componentTest)
...
}
This worked without problems with the test-sets plugin but now the gradle build fails with
FAILURE: Build failed with an exception.
* Where:
Build file '.../build.gradle.kts' line: 226
* What went wrong:
Task with name 'componentTest' not found in root project 'foobar'.
Commenting out those lines and running gradle tasks clearly states that the task exists.
Verification tasks
------------------
check - Runs all checks.
componentTest - Runs the component test suite.
...
To see all tasks and more detail, run gradle tasks --all
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
Can you share an MCVE?
Because this works fine here:
testing {
suites {
register<JvmTestSuite>("componentTest")
}
}
println("FOO")
val componentTest by tasks.named<Test>("componentTest")
println(componentTest)
println("BAR")
Btw. the idiomatic construct would be val componentTest by tasks.getting(Test::class).
But either way it prevents task configuration avoidance for the task though as you eagerly realize it, so if isRequiredBy also accepts a task provider you should change to give it a task provider instead using = instead of by.
Both these statements are done at configuration time and tests.named fails if the task is not present already.
So yes, order matters in this case, it would be like using a variable before declaring it, which also does not work in most programming languages.