This message was deleted.
# community-support
s
This message was deleted.
v
Ensure you fully leverage task configuration avoidance especially for the "if run task", then configure the other task from its configuration phase. But clean is different. :-D Maybe better just have some project property with which a dev can decide whether to show the warnings or not.
j
That was my original gut reaction. But my understanding is I can't do something like
tasks.withType<KotlinCompile>().configureEach
while configuring another task. Or would I have to realize those tasks to configure them
v
You might not be able to register another task. Configuring it should work I think. But I might remember wrongly. TIAS
j
Yeah when I tried it yesterday it gave me an exception about not being able to call configureEach in that context.
v
Well, I said clean is different. :-D You might need to break task configuration avoidance then and use
.all
our do some other hack-around
j
Yeah, I appreciate the help. Just as an FYI for any interested parties
Copy code
def conditionalDependency = tasks.register("conditionalDependency")
def other = tasks.register("other")

tasks.register("original") {
    other.configure {
        dependsOn(conditionalDependency)
    }
}
Throws
Copy code
> DefaultTaskContainer#NamedDomainObjectProvider.configure(Action) on task set cannot be executed in the current context.
But if you use
other.get().configure
that works.