如果源目录不存在,则 Gradle Copy 任务失败 [英] Fail Gradle Copy task if source directory not exist
问题描述
我正在使用 Gradle 创建构建脚本.我想保护脚本免受错误属性的影响,脚本中的任务之一是简单的复制任务,我注意到当我将不存在的目录作为 from
参数时,任务继续使用 Skipping任务 ':copySpecificPlatform' 因为它没有源文件.
有没有办法在这种情况下导致复制任务失败?
你可以试试:
task cp(type: Copy) {从空"进入目标"输入.sourceFiles.stopExecutionIfEmpty()}
每个任务都有它的 I'm using Gradle to create a build script. I want to protect the script from wrong properties, one of the tasks in the script is simple Copy task and I notice that when I put non-exist directory as Is there a way to cause the copy task to fail in this case? You can try: Every Task has its TaskInputs which source files are a FileCollection that has special method which configures the desired behavior. 这篇关于如果源目录不存在,则 Gradle Copy 任务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!from
parameter the task continue with Skipping task ':copySpecificPlatform' as it has no source files.
task cp(type: Copy) {
from 'empty'
into 'target'
inputs.sourceFiles.stopExecutionIfEmpty()
}