如果源目录不存在,则失败Gradle Copy任务
我正在使用Gradle创建一个构建脚本。我想保护脚本不受错误属性的影响,脚本中的任务之一是简单的复制任务,我注意到当我从参数中将不存在的目录放置为参数时,任务继续
跳过任务':copySpecificPlatform',因为它没有源文件。
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 from
parameter the task continue with Skipping task ':copySpecificPlatform' as it has no source files.
有没有办法导致复制任务在这种情况下失败?
Is there a way to cause the copy task to fail in this case?
您可以尝试:
You can try:
task cp(type: Copy) {
from 'empty'
into 'target'
inputs.sourceFiles.stopExecutionIfEmpty()
}
每个任务的 TaskInputs 哪些源文件是 FileCollection = http://www.gradle.org/docs/current/javadoc/org/gradle/api/file/FileCollection.html#stopExecutionIfEmpty() 相对=nofollow >方法,它配置所需的行为。
Every Task has its TaskInputs which source files are a FileCollection that has special method which configures the desired behavior.