I am looking for a way to figure out why a task is being ran. I know I can use the --dry-run flag to see what tasks would be executed, but I am trying to figure out why a certain task is executing.
The reason I am looking for this is because I use a 3rd party swagger generation plugin and for some reason it executes any time the build task runs. However, I don’t see anything in its source code where it adds itself as a finalizedBy task to build or make build depend on itself. I want to run the swagger generation task on demand, not anytime build executes.
I see it adding itself as a dependsOn classes. But the reason it runs before build continues to allude me:
Is there any way to figure out why this task runs after the build task?
I think because of a few lines down where it adds the tasks output under certain conditions to the artifacts of the archives configuration and thus is a dependency of assemble which is a dependency of build.
For some reason I never got notifications that I got responses on this. I appreciate the responses.
The “archives” configuration depending on build sounds very plausible and I am going to take a look at that. (I already have a fix in place just by being smarter about when I apply the swagger plugin…but still very curious about why it runs anytime build does, if it is applied, so going to explore this a bit).
Also, thanks for the pointer to the task tree plugin, I use Gradle 6.8 so can’t use it but will definitely keep an eye on it for my future needs.
Yes, by “curious about why it runs build” and “going to explore this a bit” I just meant I was going to experiment with it a bit based on your explanation (i.e. make changes to the swagger plugin to not add the artifact to the archives configuration)