title: How to reuse code block which describe similiar ant build logic in groovy?
body: <p>How to reuse code block which describe similiar ant build logic in groovy? <br /></p>
  
  <p>If we have build logic which was implemented by Groovy AntBuilder, just like code below: <br /></p>
  
  <pre><code>ant.someTask(attr1:value1, attr2:value2) {
      configuration1(param1:args1, param2:args2){
          similiarStructure(additionalArgs:aaa){
              setting1(param5:value5) {
                  //...blah blah blah
              }
              //further more settings, may be or may be not the same with similiarStructure below
          }
      }
  
      configuration2(param3:args3, param4:args4){
          similiarStructure(additionalArgs:aaa){
              setting1(param5:value5) {
                  //...blah blah blah
              }
              //further more settings, may be or may be not the same with similiarStructure below
          }
      }
  }
  </code></pre>
  
  <p>Are there any ways to reuse Groovy AntBuilder code block, which could brief the statment in configuration2 ? <br />
  I've try to predefine closures and inject them in both configuration, <br />
  but it fails with property not found exception while initializing closure. <br /></p>