I’m trying to specify some input/output locations in order to only run a script when a file has been modified since the last build. Following the docs I’ve come up with.
task generateLocalizedStrings(type:Exec) {
ext.srcFile = file(’…/…/…/localization/language-files/en_US/wdmobilestringres.properties’)
ext.destDir = new File(“src/main/res”)
inputs.file srcFile
outputs.dir destDir
doLast {
workingDir ‘…/…/…/localization/’
commandLine ‘python’, ‘localizationScript.py’
}
}
However, my build fails with:
execCommand == null!
Is there a way to specify that the do last block is the piece that will be executing said script?
I’ve found a solution but it feels more like a workaround that a real fix.
task generateLocalizedStrings(type:Exec) {
ext.srcFile = file('../../../localization/language-files/en_US/wdmobilestringres.properties')
ext.destDir = new File("src/main/res")
inputs.file srcFile
outputs.dir destDir
workingDir '../../../localization/'
commandLine 'python', 'dummyScript.py'
doLast {
println "Executing localization script"
workingDir '../../../localization/'
commandLine 'python', 'localizationScript.py'
}
}
Well apparently the doLast block isn’t needed for gradle to prevent the script from running. So the solution is to just remove the doLast block.
doLast is for adding commands to the execution phase of the task. It does not change the point at which the task is executed. When using builtin tasks, you normally would not need a doLast block. The task execution order is controlled by the graph of task dependencies (i.e. dependsOn).