我正在用 groovy markupbuilder 构建一个 ant 脚本。不幸的是,markupbuilder 不允许我创建名称为“target”的节点(targetee 没问题),因为它会抛出我
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], BuildGen$_main_closure1_closure5@18efaea]
Possible solutions: wait(), any(), trim(), split(), dump(), next()
所以在我的标记生成器中,这个片段有效:
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
}
}