Reputation: 231
I have to include Groovy classes into existing Java apps, and include Groovy into Ant's build.xml
file.
What is the best way to configure Ant's build.xml
for it?
Update: Are there more specifics in combining Java and Groovy compilations? Sequence of tasks?
Upvotes: 5
Views: 4644
Reputation: 4643
You should define javac inside groovyc, like this.
<groovyc srcdir="${testSourceDirectory}" destdir="${testClassesDirectory}">
<classpath>
<pathelement path="${mainClassesDirectory}"/>
<pathelement path="${testClassesDirectory}"/>
<path refid="testPath"/>
</classpath>
<javac source="1.4" target="1.4" debug="on" />
</groovyc>
For more info have a look here: http://groovy.codehaus.org/The+groovyc+Ant+Task at section Joint Compilation.
Upvotes: 0
Reputation: 13357
@VonC is correct about including Groovy scripting in your Ant build.
To expand a bit:
To compile .groovy
and .java
sources together for use in the same application, use the <groovyc>
Ant task.
See Ant Integration with Groovy for the reference.
Upvotes: 2
Reputation: 1323115
To use Groovy in your ant script, you basically have to declare the Groovy ant task:
<project name="groovy-build" default="listSourceFiles">
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"/>
<groovy>
ant.... // some ant groovy directives
</groovy>
</target>
</project>
However, you have to be careful, in your ant.xml, to refer to fileset within your current target.
Upvotes: 1