I've been working on a small project using Google Web Toolkit, which is a pretty nice framework. However, it's not exactly easy to integrate into a normal build environment with ant, as it's based on command line utilities.
After a while, I got tired of it and wrote an Ant task which can compile GWT modules into javascript. I know that others have attempted the same, but as far as I could tell, they all required you to hardcode module names in build.xml, which is not very nice.
So, using the task I wrote, it's possible to generate javascript for a set of modules using a single task. Plus, it's a little faster when compiling more modules, as it doesn't have to restart the compiler completely every time.
Try it out. It's released under a GPL license.
Download
Files are hosted at the Google Code project
Documentation
The task can be used to compile any number of modules. It's not necessary to specify the module names directly. Instead, the task accepts filesets specifying the modules.
Place the ant-gwt.jar file in your project's lib dir, make sure that the gwt-*.jar files are there too, and use like this:
-
<path id="classpath">
-
<pathelement location="${srcdir}"/>
-
<pathelement location="${builddir}"/>
-
<fileset dir="lib">
-
<include name="*.jar"/>
-
</fileset>
-
</path>
-
-
<target name="compile">
-
<javac ... />
-
-
<taskdef resource="dk/contix/ant/gwt/ant-gwt.xml" classpathref="classpath" />
-
<gwtcompile destdir="www" optimize="true">
-
<fileset dir="src">
-
<include name="**/*.gwt.xml"/>
-
</fileset>
-
</gwtcompile>
-
<target/>
Please note that the order of the classpath is important. If you get weird errors about files not being found, then ensure that the source directory is first, then the locally compiled classes, and then the jar files.
It's possible to enable some simple optimization by setting optimize="true" on gwtcompile. That will try to analyze the java files to see if any of the required files have been changed since last compile. Required files are all files which are included in the source tag in the .gwt.xml-files.




Thank you for sharing such useful task. I think it should be published on ant.apache.org in optional task list.
By the way, could you provide sources for this task? Hope you don’t mind since you’ve released it under gpl.