成绩:如何自定义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中添加它?感谢。
答案 0 :(得分:0)
processResources
是Copy
类型的任务。因此你应该能够做到
processResources {
eachFile {details ->
// Top Level Modules
def targetPath = rawPathToModulesPath(details.path)
details.path = targetPath
}
}