Hello,
I need help with the following script, please. I have Copy tasks which are supposed to save log files created by dynamic tasks. The execution of the dynamic tasks are evaluated during execution (in the ME substituted by false
). If the dynamic task is skipped I want to skip the related copy task as well.
Current behaviour is that all copy tasks are executed always - no matter what.
Background: I need to rerun a compilation of the same source code because auxillary files are changing during compilation (LaTeX).
project.ext {
inputFile = 'source.src'
outputFile = 'binary.bin'
commandlineCommand = 'pdflatex'
}
def compileTasks = []
5.times { counter ->
task "task$counter"(type: Exec) {
inputs.source project.inputFile
outputs.file project.outputFile
doFirst {
commandLine project.commandlineCommand, project.inputFile
}
onlyIf {
false // <-- For claryfication substituted with 'False'
}
}
task "saveLog$counter"(type: Copy) {
from('.') {
include '*.log'
}
into "logSave/run_$counter"
dependsOn "task$counter"
}
compileTasks.add tasks["task$counter"]
}
saveLog4.dependsOn saveLog0, saveLog1, saveLog2, saveLog3
How can I skip the saveLogX
tasks?
I would like to have a solution which has a ‘programmatic style’: Maybe adding in the Copy tasks something in the style of
onlyIf "task$counter".state.executed.true
Thank you!
Thomas
Edit: changed Typo in code.