gradle 可以在复制时改变树的结构吗?
原创
想要的
我不确定应该在哪里创建闭包并覆盖复制树逻辑
我想做与 ant 的 globmapper 功能等效的 gradle
<property name="from.dir" location=".."/>
<property name="to.dir" location="dbutil"/>
<copy>
<fileset dir="${from.dir}" ... />
<globmapper from="${from.dir}/*/db" to="${to.dir}"/>
</copy>
谢谢
彼得
最佳答案
更改文件名时,重命名似乎是一个不错的方法。更改路径时,您可以覆盖 eachFile 并修改目标路径。
这很好用。
copy {
from("${sourceDir}") {
include 'modules/**/**'
}
into(destDir)
eachFile {details ->
// Top Level Modules
def targetPath = rawPathToModulesPath(details.path)
details.path = targetPath
}
}
....
def rawPathToModulesPath(def path) {
// Standard case modules/name/src -> module-name/src
def modified=path.replaceAll('modules/([^/]+)/.*src/(java/)?(.*)', {"module-${it[1]}/src/${it[3]}"})
return modified
}
https://stackoverflow.com/questions/13296986/
相关文章:
android - Gradle DSL 方法未找到 : "classpath()"
deployment - 从不同的文件夹运行 ant exec 任务
visual-studio-2010 - VS2010 : Exclude a project fr
c++ - 在 Eclipse 中设置构建输出目录 - c++
gradle - 谷歌构建Android的Gradle插件源代码
android - 我已将 Android SDK 更新为 rev。昨天 22 日,工具中没有 ap