Currently I call a main method in a class like this from my build.gradle file:
task(runSample, dependsOn: 'classes', type: JavaExec) {
afterEvaluate{
main = 'com.MyMain'
classpath=sourceSets.main.runtimeClasspath
classpath+=sourceSets.test.runtimeClasspath
args 'firstArg'
args 'secondArg'
}
}
I need to do the above but for multiple values of the second args in my custom task implemented in java. I have found an example in groovy that looks like this:
project.javaexec {
main = 'com.mrhaki.java.Simple'
classpath = sourceSets.main.runtimeClasspath
args 'mrhaki'
systemProperty 'simple.message', 'Hello '
}
But in java the project.javaexec takes a closure:
project.javaexec(Closure closure)
Any ideas on how to call the project.javaexec from a task written in Java?