I’m writing a custom gradle plugin for gradle 4.5 via java and I having some troubles with command line parameters.
I having two tasks, where one depends from the other.
Both task should react for the same commandline option (–myparam) for that I created a parent class which extends from the DefaultTask.
@Option(option = "myparam", description = "Option to disable", order = 1)
Boolean myparam = false;
With setter and getter.
The command-line option is only attached to the task that’s on the command-line. It’s not propagated to anything else.
If you have multiple tasks that all need to behave differently with the same parameter, you might consider using a project property instead. What does the option represent?
I managed to handle it via ExtraPropertiesExtension
all my Tasks extend from a CommonTask and this set the command line parameters to the extension.
The dependant tasks get the parameter either from the extension or from the parameter.