# Use @Option together with task closure

**URL:** <https://discuss.gradle.org/t/use-option-together-with-task-closure/27432>\
**Category:** Help/Discuss\
**Created:** [June 20, 2018, 9:55pm UTC](https://discuss.gradle.org/t/use-option-together-with-task-closure/27432 "2018-06-20T21:55:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grdoozy](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@grdoozy](https://discuss.gradle.org/u/grdoozy)\
**Post date:** [June 20, 2018, 9:55pm UTC](https://discuss.gradle.org/t/use-option-together-with-task-closure/27432/1 "2018-06-20T21:55:39Z")

</div>

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?
