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

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.taskGraph.whenReady { graph ->
   if (graph.hasTask("launchOnDiskDb") {
    System.setProperty(...)
  }
}