# How to set a system property before calling task in Gradle?

**URL:** <https://discuss.gradle.org/t/how-to-set-a-system-property-before-calling-task-in-gradle/6060>\
**Category:** Old Forum Archive\
**Created:** [November 9, 2012, 11:23am UTC](https://discuss.gradle.org/t/how-to-set-a-system-property-before-calling-task-in-gradle/6060 "2012-11-09T11:23:00Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 9, 2012, 5:21pm UTC](https://discuss.gradle.org/t/how-to-set-a-system-property-before-calling-task-in-gradle/6060/4 "2012-11-09T17:21:00Z")

</div>

I didn’t know that ‘launch’ is once again delegating the work. In that case, you can add the system property depending on which task is going to get executed:

```gradle
gradle.taskGraph.whenReady { graph ->
   if (graph.hasTask("launchOnDiskDb") {
    System.setProperty(...)
  }
}

```

---

_[View the full topic](https://discuss.gradle.org/t/how-to-set-a-system-property-before-calling-task-in-gradle/6060)._
