コピー タイプのタスク中に zip アーカイブ内の特定の xml ファイルを更新する最良の方法は何ですか?
私がこれまでに持っているもの:
def unzip() {
copy {
def zipFile = configurations.tomcat.singleFile
from zipTree(zipFile)
into 'dir'
eachFile { fileCopyDetails ->
file = fileCopyDetails.file
if ( file.getAbsolutePath().endsWith('conf' + File.separator + 'context.xml') ) {
def contextXml = new XmlSlurper().parse(file)
String contextStr = groovy.xml.XmlUtil.serialize(contextXml)
println 'xml before:\n' + contextStr
contextXml.appendNode {
a('value')
}
contextStr = groovy.xml.XmlUtil.serialize(contextXml)
println 'xml after:\n' + contextStr
file.withWriter { outWriter ->
XmlUtil.serialize( new StreamingMarkupBuilder().bind{ mkp.yield contextXml }, outWriter )
}
}
}
}
}
このコードの問題は、'tmp' フォルダー内の xml ファイルのみを更新し、最終的な 'dir' フォルダー内の xml ファイルを更新しないことです。
前もってありがとう、PM