Reuben Firmin
06/06/2024, 9:41 AM./gradlew tasks --dry-run , but that just outputs :tasks SKIPPED.Vampire
06/06/2024, 10:06 AMReuben Firmin
06/06/2024, 10:23 AMVampire
06/06/2024, 10:29 AMVampire
06/06/2024, 10:29 AMVampire
06/06/2024, 10:30 AMdoLast { ... } or doFirst { ... } for the task actions that should be done at execution time and thus do the work already when the task is configured.Reuben Firmin
06/06/2024, 10:31 AMReuben Firmin
06/06/2024, 10:33 AMtasks.register("db-migrate", DatabaseSetup::class) {
println("Now migrating")
migrate()
jooqGenerate()
println("Generated beautiful source")
// don't run by default
enabled = false
}
This should be picked up by every configuration phase run?Thomas Broyer
06/06/2024, 10:50 AMdoFirst or doLast (depending on what DatabaseSetup already does)
See e.g. https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:defining_tasksReuben Firmin
06/06/2024, 10:58 AMVampire
06/06/2024, 11:08 AMwhat's impossible?That a task is executed at configuration time
what about enabled=false - is that a no-op?No, it makes the task skip the execution phase. But as I and Thomas already said, you are not doing your stuff at execution time, but at configuration time, so it is executed each time you configure that task.
Reuben Firmin
06/06/2024, 11:11 AMdoLast doesn't sound like "anything not in this block is going to be run in configuration"Vampire
06/06/2024, 11:21 AMWell we have different definitions of "impossible", since this is being executed at configuration timeNo, the task is not executed at configuration time as that is impossible. The configuration of that task is executed at configuration time. And the code you wonder executes is configuration code for the task, as you do not do it in execution-time action which you would register using
doLast or doFirst as Thomas and I said above already. ;-)Vampire
06/06/2024, 11:22 AMReuben Firmin
06/06/2024, 11:29 AM./gradlew tasks --all to actually do what it was supposed to instead of outputting :tasks SKIPPED. As I said above:
a) it's counter intuitive that code inside the task definition runs at configuration time.
b) it's counter intuitive that doLast is for stuff that shouldn't run at configuration time.
and to add to that
c) it really sucks that simple things like this require looking at your extremely verbose documentation.Vampire
06/06/2024, 11:33 AMenabled = false could work? Setting it at execution time, especially as last line, is way too late, because you can hardly disable the task when it is already running. 😉