2017-06-20 10 views
0

グレード:processResourcesをカスタマイズしてjarファイル内のリソースファイルパスを変更する方法は?例えばgradle processResources:ファイルパス変換

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

processResourcesは、Copyのタスクです。あなたはできるはずです

processResources { 
    eachFile {details -> 
     // Top Level Modules 
     def targetPath = rawPathToModulesPath(details.path) 
     details.path = targetPath 
    } 
} 
関連する問題