More of a gradle question, but when using tasks.fi...
# gradle
a
More of a gradle question, but when using tasks.findbyname, how are we supposed to deal with tasks that are seemingly lazily created? Android
assembleRelease
is null on evaluation, and a bunch of previous posts here simply check for null before actually handling it
t
You could do something like this:
Copy code
tasks.whenTaskAdded {
    if (name == "assembleRelease") {
        logger.warn("Task found: $this")
    }
}
a
That seems better, but it still won’t help me guarantee that it runs. I also saw uses of
afterEvaluate
, but that hasn’t worked. For now, I made my own task that depends on the segment I want, and then I ordered my own tasks since they exist
t
you could wrap it inside
plugins.withId("com.android.application") { .. }
to ensure that this will be called only when android plugin is available
a
I can try that. It’s in a gradle build file that applies the plugin already, so I assumed the task would be added
t
yep, in this case you could assume task is added