Alexander Ioffe
09/10/2024, 9:07 PMtasks.named("linkDebugTestLinuxX64") { stuff }
It blows up the build like so:
An exception occurred applying plugin request [id: 'nativebuild']
> Failed to apply plugin 'nativebuild'.
> Task with name 'linkDebugTestLinuxX64' not found in project ':terpal-sql-core'.
Yet when I do this:
tasks.all {
if (name.contains("linkDebugTestLinuxX64")) {
println("--------------- Found: linkDebugTestLinuxX64")
stuff
}
}
It works just fine and I see the printout.
What is going on here? Is Gradle mutating the build-tree between two different steps?Vampire
09/10/2024, 9:49 PMVampire
09/10/2024, 9:50 PMtasks.named("...")
only works if the task you want to get is already registered. If for example some plugin that is applied later registers the task or does it reactively the task is not yet present when you call that function.Vampire
09/10/2024, 9:51 PMtasks.all { ... }
on the other hand processes each and every registered task, no matter whether already registered or in the future, but you should never use it except for debugging, because it completely breaks task-configuration avoidance.Vampire
09/10/2024, 9:52 PMAlexander Ioffe
09/10/2024, 9:52 PMtasks.named("linkDebugTestMingwX64") { enabled = HostManager.hostIsMingw }
Vampire
09/10/2024, 9:52 PMVampire
09/10/2024, 9:53 PMtasks.named { it == "linkDebugTestMingwX64" }.configureEach { enabled = HostManager.hostIsMingw }
Alexander Ioffe
09/10/2024, 9:53 PMVampire
09/10/2024, 9:53 PMAlexander Ioffe
09/10/2024, 9:54 PMtasks.named("linkDebugTestMingwX64") { enabled = HostManager.hostIsMingw }
and from this:
tasks.all {
if (name.contains("linkDebugTestLinuxX64")) {
enabled = HostManager.hostIsMingw
}
}
Vampire
09/10/2024, 9:55 PMVampire
09/10/2024, 9:56 PMtasks.configureEach { ... }
and check the name therein, that would probably not make too much differenceAlexander Ioffe
09/10/2024, 9:56 PMAlexander Ioffe
09/10/2024, 9:56 PMVampire
09/10/2024, 9:56 PMVampire
09/10/2024, 9:56 PMAlexander Ioffe
09/10/2024, 9:57 PMVampire
09/10/2024, 9:58 PMVampire
09/10/2024, 9:58 PMAlexander Ioffe
09/10/2024, 10:00 PMtasks.named("linkDebugTestLinuxX64") { enabled = HostManager.hostIsLinux }
works just fine. Is the gradle-DSL "lazier" that the Kotlin one?Vampire
09/10/2024, 10:05 PMAlexander Ioffe
09/10/2024, 10:05 PMVampire
09/10/2024, 10:05 PMVampire
09/10/2024, 10:06 PMVampire
09/10/2024, 10:06 PMVampire
09/10/2024, 10:06 PMVampire
09/10/2024, 10:07 PMAlexander Ioffe
09/11/2024, 3:23 AM