I am trying to use @Option
to expose a custom command line option for configuring a JavaExec task. I attempted to do it like this in my build.gradle file:
class MyJavaExec extends JavaExec {
@Input
@Option(description="Configure XYZ")
def String xyz;
}
task runXyz(type: MyJavaExec) {
systemProperties += ['custom.xyz': xyz]
main = 'com.MyMain'
}
I then execute the task with gradle runXyz --xyz=something
The problem is that this ends up setting my custom.xyz
system property to null
. How can I do this to get hold of the value set with the command line option?