我正在使用 Gradle 创建构建脚本。我想保护脚本免受错误属性的影响,脚本中的任务之一是简单的复制任务,我注意到当我将不存在的目录作为from参数时,任务继续Skipping task ':copySpecificPlatform' as it has no source files.
在这种情况下,有没有办法导致复制任务失败?
你可以试试:
task cp(type: Copy) {
from 'empty'
into 'target'
inputs.sourceFiles.stopExecutionIfEmpty()
}
Run Code Online (Sandbox Code Playgroud)
每个任务都有其TaskInputs,其源文件是一个FileCollection ,它具有配置所需行为的特殊方法。
| 归档时间: |
|
| 查看次数: |
4017 次 |
| 最近记录: |