Hi,
Recently decided to migrate to 5.x to take advantage of the new tasks options and in general a much appreciated addition. However there are some things which in my mind is still very poorly documented when working with Custom Task types + options + configuration thereof so this is my feedback on that.
Problem: Options cannot be marked mandatory
So this means where an option really is mandatory I need to add some code to check whether the user has provided the option. The documentation here is quite poor and I could not figure out how without experimentation: it cannot be done in the custom task constructor and I ended up having to do it in the TaskAction.
NOTE: If I could have configured an option to be mandatory then I would not have had to bother about this problem and the main Gradle stuff could have handled this for me without me coding anything further.
Problem: There is no documentation on how to write out “usage:…” when needed
Given that a user has omitted providing the necessary option, it would have been useful to print out the help, but there is no documentation provided on how to do this.
Problem: There seems to be no way to specify a method to be used for configuring a Custom task
Given that I have some kind of need to either configure or validate, then some kind of facility to provide this through Custom task methods via some Task annotation would have been a useful addition to Gradle. But there is nothing there.
Problem: If I have a configuration closure in the build.gradle file, it will always run even when I don’t want to
Let’s say these options are important because they impact the configuration of the task at hand, then in fact it becomes impossible to find out any information about the task.
Typically I look at gradle.startParameter.taskNames to find out if my task has been requested and if not then I don’t take any actions during the configuration stage of the Gradle run.
However, if “help --task mytask” has been asked for it appears in the list of taskNames requested and my configuration code runs and fails. How do I workaround this problem?
If anyone have any novel ideas on how to resolve these problems then please do share what you know.