【问题标题】:gradle processResources: file path conversiongradle processResources:文件路径转换
【发布时间】:2017-11-22 10:58:48
【问题描述】:

等级:如何自定义processResources来改变jar中的资源文件路径?

例如:

foo/a.xml  --> foo/bar/a.xml

类似于:

copy tree with gradle and change structure?

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
}

如何在 processResources 中添加这个?谢谢。

【问题讨论】:

    标签: gradle process path resources


    【解决方案1】:

    processResourcesCopy 类型的任务。因此你应该能够做到

    processResources {
       eachFile {details ->
           // Top Level Modules
           def targetPath = rawPathToModulesPath(details.path)
           details.path = targetPath
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-19
      • 2015-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多