1
votes

This code executes each run task one at a the time

...
task run1 (type: JavaExec, dependsOn: classes) {
    main="com.package.Main1"
    classpath sourceSets.main.output.classesDir
    classpath configurations.compile
}
...

task runAll(){
    dependsOn run1
    dependsOn run2
    dependsOn run3
        ...

}
...

How can I run multiple Main classes from one jar file at once (parallel)

1
Kick off multiple processes? - David says Reinstate Monica
sounds good the question is how - sherif
Take a look at stackoverflow.com/questions/3774432/starting-a-process-in-java . Or just Google starting a process in Java. - David says Reinstate Monica

1 Answers

1
votes

As of Gradle 1.9, Gradle can only run task from different projects in parallel. You can implement your own task and execute the main methods in parallel within that task, possibly using the Project.javaexec() method. However, you'll have to implement this yourself, for example with the GPars library.