Parallel task execution breaks the order when parallel ,normal tasks mixed together


(Radha Krishnan) #1

apply plugin: ‘java’

task taskA <<{
println ‘task A’
}

task taskB (type:P){
namee=‘B’
}
task taskC (type:P){
namee=‘C’
}
@ParallelizableTask
class P extends DefaultTask {
String namee

@TaskAction
def broccoliBuild() {
    println "Task "+namee
}

}

task taskBC (dependsOn:[‘taskB’,‘taskC’])<<{
println ‘BC’
}
taskBC.mustRunAfter taskA

task taskD <<{

println'task D'

}
taskD.mustRunAfter taskBC

task taskE (type:Qtask){
nname=‘E’
}
task taskF (type:Qtask){
nname=‘F’
}
@ParallelizableTask
class Qtask extends DefaultTask {
String nname

@TaskAction
def broccoliBuild() {
    println "Task "+nname
}

}

task taskEF (dependsOn:[‘taskE’,‘taskF’])<<{
println ‘task EF’
}
taskEF.mustRunAfter taskD

task main(dependsOn: [‘taskA’,‘taskBC’,‘taskD’,‘taskEF’])<<{
println ‘Build Completed’
}

When we execute the main task in parallel mode (gradle main --parallel -Dorg.gradle.parallel.intra=true) taskEF executes along with taskBC (Both of them is parallel tasks) which violates the flow i have mentioned. taskD must be executed before taskEF (I have used mustRunAfter ) . Please can any one help me out of this. (Used Gradle 2.12)


Can we run tasks in parallel in single build project