复制树与gradle和更改结构?

编程入门 行业动态 更新时间:2024-10-28 19:24:13
本文介绍了复制树与gradle和更改结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

原始

可以在复制时改变树的结构吗? ul>
  • mod / a / src
  • mod / b / src
  • $ b
    • dest / mod-a / source
    • > dest / mod-b / source
    • dest / mod-c / source

    I 'm不确定我应该在哪里创建一个闭包并覆盖复制树逻辑

    我想要做与ant的globmapper功能等价的gradle。

    < property name =from.dirlocation =../> < property name =to.dirlocation =dbutil/> < copy> < fileset dir =$ {from.dir}... /> 谢谢

    彼得

    解决方案

    更改文件名时,重命名似乎是一种好方法。更改路径时,您可以覆盖 eachFile 并修改目标路径。

    这很好。

    copy { from($ {sourceDir}){ include'modules / ** / **'} 转换为(destDir) eachFile {details - > //顶级模块 def targetPath = rawPathToModulesPath(details.path) details.path = targetPath } } 。 ... def rawPathToModulesPath(def path){ //标准大小写模块/名称/ src - > module-name / src def modified = path.replaceAll('modules /([^/]+)/.* src /(java /)?(.*)',{module - $ {it [ 1]} / src / $ {it [3]}}) return modified }

    Can gradle alter the structure of the tree while copying?

    original

    • mod/a/src
    • mod/b/src

    desired

    • dest/mod-a/source
    • dest/mod-b/source
    • dest/mod-c/source

    I'm not sure where I should create a closure and override the copy tree logic

    I'd like to do the gradle equivalent of ant's globmapper functionality

    <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>

    Thanks

    Peter

    解决方案

    When changing file name, rename seems a good approach. When changing path you can override eachFile and modify the destination path.

    This works pretty well.

    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 }

    更多推荐

    复制树与gradle和更改结构?

    本文发布于:2023-10-15 12:22:25,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:结构   gradle

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!