Hi Gradle folks!
Was playing a bit with parallel task execution recently. When I look at documentation it reads like when having two different custom tasks in two different projects and following certain rules (no doLast, no doFirst, etc.) that Gradle shall realize that these are parallelizable. In my case with Gradle 4.5.1 they are clearly not parallelized, using gradle clean build --parallel; they are executed one after another on one executor.
This is my simple test code:
class GreetingTask extends DefaultTask {
private File greets_input;
private File greets_output;
@InputFiles
public File getGreetsInput() {
return this.greets_input;
}
@InputFiles
public setGreetsInput(File input) {
this.greets_input=input;
}
@OutputDirectory
public File getGreetsOutput() {
return this.greets_output;
}
@OutputDirectory
public File setGreetsOutput(File output) {
this.greets_output=output;
}
@TaskAction
def greet() {
int count=0;
1.upto(10000000, {
count++;
})
}
}
project(":postProcessorProject3") {
task postProcessor3 (type : GreetingTask) {
setGreetsInput(file("$rootDir/emptyInput/test.txt"))
setGreetsOutput(file("$rootDir/emptyOutput3"))
}
}
project(":postProcessorProject2") {
task postProcessor2 (type : GreetingTask) {
setGreetsInput(file("$rootDir/emptyInput/test.txt"))
setGreetsOutput(file("$rootDir/emptyOutput2"))
}
}
task postProcessor1 () {
dependsOn tasks.getByPath(’:postProcessorProject2:postProcessor2’)
dependsOn tasks.getByPath(’:postProcessorProject3:postProcessor3’)
doLast{
1.upto(10, {
println "Number ${it}"
})
}
}
So, my question is eventually:
Is the Worker API the only way now to make Custom Tasks being parallelized? If yes, how does this work for your own plug-ins? All Worker-API-ized already :-)? In your docu it seemed as if using different projects could be sufficient for Custom Tasks already (the example in docu is generic).
Thanks a lot in advance!
BR,
Franz Krainer