我正在用groovy markupbuilder構建一個ant腳本。不幸的是MarkupBuilder的不允許我創建名爲「目標」(與targetee沒問題)節點, becauase它拋出我如何用groovy markupbuilder創建帶特殊節點名稱的xml文檔
Caught: groovy.lang.MissingMethodException: No signature of method: java.lang.String.call() is applicable for argument types: (java.util.LinkedHashMap, BuildGen$_main_closure1_closure5) values: [[name:clean], [email protected]]
Possible solutions: wait(), any(), trim(), split(), dump(), next()
所以我的MarkupBuilder裏面這個片段的工作:
targete(name: 'clean') {
delete(dir: rootProj.compilerOutput)
}
但我想達到同樣與「目標」節點..
我設法創建一個空的「目標」節點是這樣的:
builder.invokeMethod('target', [name: 'clean'])
但我該如何繼續並在此「目標」節點內放置更多節點?
的工作代碼示例:
def writer = new StringWriter()
def builder = new groovy.xml.MarkupBuilder(writer)
builder.project(name: projectName, basedir:'.') {
// works with 'target2' but not with 'target'
'target2'(name: 'build-subprojects') {
rootProj.getAllDependentProjects().each { p->
echo(message: "Compiling project: ${p.projectName}")
// some real stuff
}
}
您可以發佈是不是爲你工作的一些示例代碼?我不確定我明白你的問題是什麼? – 2010-11-04 12:15:52
我在問題中加入了這個問題。希望它使我的問題清楚:-) – jabal 2010-11-04 13:05:25