It there any way to avoid duplication in configuration between two similar tasks of the same type?
For example, I\'d like to create a debugSomething
task, w
This can be solved using plain Groovy:
task runSomething(dependsOn: jar, type: JavaExec, group: "Run") {
}
task debugSomething(dependsOn: jar, type: JavaExec, group: "Run") {
jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y"
}
[runSomething, debugSomething].each { task ->
task.main = "com.some.Main"
task.classpath = sourceSets.main.runtimeClasspath
task.jvmArgs "-Xmx1024m", "-XX:MaxPermSize=128m"
}
Even though debugSomething.jvmArgs
is invoked twice, all three arguments are supplied to the JVM.
Single arguments can be set using Groovy's Spread operator:
[runSomething, debugSomething]*.main = "com.some.Main"