我的复制任务复制多个源:
例如:
task initConfig(type: Copy) {
from('src/main/config') {
include '**/*.properties'
include '**/*.xml'
filter(ReplaceTokens, tokens: [version: '2.3.1'])
}
from('src/main/config') {
exclude '**/*.properties', '**/*.xml'
}
from('src/main/languages') {
rename 'EN_US_(.*)', '$1'
}
into 'build/target/config'
}
Run Code Online (Sandbox Code Playgroud)
当其中一个源不存在时,任务不会失败,也不会记录错误。
使用“inputs.sourceFiles.empty”作为解决方案仅适用于单个源:
对每个源使用断言...不是一个优雅的解决方案,因为我有很多源。
assert file("bla bla").exists()
当其中一个来源丢失时,我如何才能使任务失败?