This message was deleted.
# community-support
s
This message was deleted.
e
afaik - no, not publicly
well, if you already know the name ahead of time, you can check if a task has been registered by looking in
tasks.getNames()
without making it configured
but doing anything with the result seems likely racy to me
v
Check
tasks.names
and if it is not there use
tasks.whenTaskAdded
? But that will effectively disable task configuration avoidance. You can limit it down to just disabling task configuration avoidance for a specific task type if you know the type by using
tasks.withType<...>().whenTaskAdded
.
e
right, unfortunately there's nothing like
tasks.names.whenAdded
or
tasks.whenRegistered
, so at least publicly you can't watch for additions without forcing realization of added objects. but as a hack using non-public APIs,
Copy code
tasks.withGroovyBuilder {
    "whenElementKnown" {
        println(getProperty("name") to getProperty("type"))
    }
}
seems to work in Gradle 8.0.1
😂 1
v
You are artificially blowing up the example though, don't you? 😉
task.name
already is just the name.
task.path
is with the path.
👍 1