This message was deleted.
# community-support
s
This message was deleted.
n
why would you add it conditionally? wouldn't it be easier to execute it conditionally instead?
p
This would be the workaround. But it would be cleaner not to create it at all (and it is less confusing in the task list in the ide)
n
How would the property be provided? Because you can simply read the property during the configuration phase and wrap the
tasks.register
call inside an if block:
Copy code
if (property) {
    tasks.register<MyTask>("myTask)
}
p
Yeah, but this requires evaluating the Property by calling get(). The user should set a value of type Property and based on this value I will create the tasks.
n
in that case you'll require an
afterEvaluate
I think
I would advise against doing that though, it potentially messes with all sorts of optimisation strategies employed by gradle.
p
n
e
Gradle needs to build a task dependency tree (after configuration stage) before it even begins executing tasks. How would a property, that you expect to be evaluated at execution time, influence the task tree which is built at configuration time? 🤔
p
Properties (or Providers) are evaluated during configuration time, otherwise you can't configure your build. You can also use
addLater
for dependencies though.
e
Yes you can evaluate providers whenever. But I’m taking
Yeah, but this requires evaluating the Property by calling get().
to mean that you don’t want to evaluate it at configuration time?
p
Yes, I don't want to call get() explicitly by myself. Instead, you should use
set
and let Gradle handle calling
get
to lazy configure your build.