我想使用通配符复制目录,但fromGradle copy任务的方法不接受通配符.
// this doesn't work
task copyDirectory(type: Copy) {
from "/path/to/folder-*/"
into "/target"
}
// this does
task copyDirectory(type: Copy) {
from "/path/to/folder-1.0/"
into "/target"
}
Run Code Online (Sandbox Code Playgroud)
只需使用'include'任务属性来指定您需要复制的确切文件,如下所示:
task copyDirectory(type: Copy) {
from "/path/to/"
include 'test-*/'
into "/target"
}
Run Code Online (Sandbox Code Playgroud)
更新:如果您只想复制目录内容,那么您必须单独处理每个文件,如下所示:
task copyDirectory(type: Copy) {
from "/path/to/"
include 'test-*/'
into "/target"
eachFile {
def segments = it.getRelativePath().getSegments() as List
it.setPath(segments.tail().join("/"))
return it
}
includeEmptyDirs = false
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3536 次 |
| 最近记录: |