I should be able to specify targets that independently configure tasks


(jon.rimmer) #1

If I am using a plugin that provides a workflow, like the Java Application plugin, I will often want to reuse its workflow in several different configurations.

For example, in my build.gradle, I might want a target that installs the application to a development environment, another that installs to staging ,etc. For each of these, I will need to tweak the configuration of its the workflow tasks, to change the install path, supply different JVM params, etc.

This is an extremely basic use-case for a build system, but it seems like Gradle does not support it in any easy, declarative fashion. I can only configure the tasks on a per-project basis, or in a construct like allprojects or subprojects that affects multiple-projects.

What is needed is a lower level construct, let’s call it “target”, that can configure multiple tasks:

target installDev(defaultTask: 'installApp') << {
  startScripts {
    defaultJvmOpts = ['-Dfoo=devOption']
  }
      installApp {
    destinationDir = '/myapp'
  }
}
  target installStaging(defaultTask: 'installApp') << {
  startScripts {
    defaultJvmOpts = ['-Dfoo=stagingOption']
  }
    installApp {
    destinationDir = '/networkpath/myApp'
  }
}