Gradle copySpec包括关闭不起作用:
def fileList = ["hello/world.xml"]
task foo(type: Copy) {
from (zipTree("/path/a.zip")) {
include { elem ->
fileList.contains(elem.path)
}
}
}
a.zip包含" hello / world.xml"。
消息:
Skipping task 'foo' as it has no source files and no previous output files.
答案 0 :(得分:0)
copySpec
闭包需要与复制任务一起使用。
您的代码只是复制任务,需要将目标复制到其中。
您的代码应该更像这样:
def fileList = ["hello/world.xml"]
def filesToCopy = copySpec {
from (zipTree("/path/a.zip")) {
include { elem ->
fileList.contains(elem.path)
}
}
}
task foo(type: Copy) {
into 'build/target/docs'
with filesToCopy
}
有关详细信息,请参阅API:https://docs.gradle.org/3.3/dsl/org.gradle.api.tasks.Copy.html