I have the following JavaExec task:
task(myMainTask, dependsOn: 'subtask', type: JavaExec) {
println "run myMainTask!"
main = 'com.Test'
classpath = sourceSets.main.runtimeClasspath
//....
}
The above task is ALWAYS run since it fails if I add the:
"(...) << {}"
The myMainTask depends on subtask which is given by:
task (subtask, type: Copy) <<
{
println "we use << to only run subtask when runnig myMainTaskrunning"
}
This task should only be run if myMainTask is run. Therefore I use:
<<
But it does not work. Only if I remove:
<<
from subtask is it executed. But then its always removed.
How is a dependent task (subtask) ONLY run if its calling task (myMainTask) is run?