I want to execute a build.xml (Ant buildfile) from using GMaven (Maven Plugin for inline execution of Groovy in a POM). Since I have to execute the buildfile several times using the maven-antrun-plugin is not an option. The buildfile is evolving and taken from a partner project with little changes. That's why I don't want to put the logic in it into another environment (groovy code or Maven configuration).
I take a list of properties (environment and machine names that can differ widely in number and names, to my mind this cannot be put into modules) 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>