How to set the build.xml for the Groovy Antbuilder?
Posted
by Jan
on Stack Overflow
See other posts from Stack Overflow
or by Jan
Published on 2010-05-05T15:09:22Z
Indexed on
2010/05/06
6:58 UTC
Read the original article
Hit count: 363
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>
© Stack Overflow or respective owner