How to set the build.xml for the Groovy Antbuilder?
- by Jan
I want to execute a build.xml (Ant buildfile) from using GMaven (Maven Plugin for inline executing of Groovy in a POM). Since I have to execute the buildfile several times using the maven-antrun-plugin is not an option at the moment.
I take a list of properties (environment and machine names) from an xml file and want to execute ant builds for each of those machines. I found the executeTarget method in the javadocs but not how to set the location of the buildfile. How can I do that - and is this enough?
What I have looks as follows:
<plugin>
    <groupId>org.codehaus.groovy.maven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <executions>
      <execution>
        <id>some ant builds</id>
        <phase>process-sources</phase>
        <goals>
          <goal>execute</goal>
        </goals>
        <configuration>
          <source>
            def ant = new AntBuilder()
            def machines = new XmlParser().parse(new File(project.build.outputDirectory + '/MachineList.xml'));
            machines.children().each { 
             log.info('Creating machine description for ' + it.Id.text() + ' / ' + it.Environment.text());
                ant.project.setProperty('Environment',it.Environment.text());
                ant.project.setProperty('Machine',it.Id.text());
                // What's missing?                    
                ant.project.executeTarget('Tailoring');
            }
            log.info('Ant has finished.')
          </source>
        </configuration>
      </execution>
    </executions>
  </plugin>