I used to have this script to make other tasks dep...
# community-support
e
I used to have this script to make other tasks dependOn a variant/flavor task. But as my research show, the AGP changed that: "variant-specific tasks are no longer created during the configuration stage". How can I fix this?
Copy code
applicationVariants.configureEach { variant ->

    if (variant.buildType.name == "release") {
        tasks.named("lintVital${variant.name.capitalize()}") {
v
Probably depends on what they mean, because "variant-specific tasks are no longer created during the configuration stage" is impossible, except if they are not created at all. You cannot create any task after the configuration phase. But what you probably want is
tasks.named { it == "lintVital${variant.name.capitalize()}" }.configureEach {
e
it works. thanks a lot. could you tell me why? what's the difference between the methods?
v
named(...)
is an old eager method that requires that the task is already registered at the point in time where you call the method.
named { ... }
is a new lazy method that will match all tasks that fulfill the condition whether already registered or registered in the future with
.configureEach
called on it still behaving lazy and according to taks-configuration avoidance, only configuring the tasks that are configured anyway.
❤️ 1
e
thanks again
👌 1