简体   繁体   中英

Gradle run multiple jars at once

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM