Skip to Content »

Tech Life of Recht » Ant task for Google Web Toolkit

 Ant task for Google Web Toolkit

  • July 18th, 2006
  • 4:36 pm

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.

Documentation

Update: I got a notice that the task doesn’t work under Windows – that should be fixed now.
Update 2: Version 1.1.0 of GWT requires an new compiler. Get it here.
Update 3: The project is now hosted at Google Code, and new releases can be downloaded there.

15 People had this to say...

Gravatar
  • Mark Williams
  • August 15th, 2006
  • 5:13 am

Looks cool! I especially like the idea of using XDoclet to build GWT apps. I want to try out your stuff, but it seems the link to http://braindump.dk/gwt-xdoclet-1.2.3.jar is broken…?

Cheers
-Mark

Gravatar
  • Gent Park
  • August 16th, 2006
  • 8:14 am

Hi,
Could you please change “parseBoolean” into “getBoolean” in your source code?
that will make it run under jdk1.4.x also.

I appreciate your brilliant job.

Cheers.

Gravatar
  • recht
  • August 16th, 2006
  • 8:48 am

Yes, I thought that I’d compiled the task against 1.3, but obviously I got something wrong. It should be fixed now, just download the file again.

Gravatar
  • Slava
  • August 16th, 2006
  • 10:59 am

your ant task fails to build modules without entrypoints(common module which is inherited by other modules). It tries to compile them, but there is no need to do this.

Gravatar
  • recht
  • August 17th, 2006
  • 12:16 am

I’ve fixed so that modules without entry-point tags are ignored. Just download the jar again to get it.

Gravatar
  • Vinod
  • November 8th, 2007
  • 5:20 pm

Hi,

Thanks for this ant task. It works really well for smaller project but with bigger projects I am having issues using this.

Following is the current normal ant task that we using:

With out the “” attribute our project fails. Can you please let me know how do I set this parameter in gwtcompile task?

Thank you,
VinodRamu

Gravatar
  • Vinod
  • November 8th, 2007
  • 5:21 pm

Sorry, the code got stripped. Here is the code

Gravatar
  • Vinod
  • November 8th, 2007
  • 5:24 pm

I am having hard time to stick the code here. Let me cut short the question. Can you please let me know who to set the “jvmarg value=’-Xmx1024m’” argument using gwtcompile task?

Thanks

Gravatar
  • recht
  • November 8th, 2007
  • 6:45 pm

You need to pass the arguments to ant itself, as the compilation is done without spawning a new process.
This is done by setting ANT_OPTS=”-Xmx500m” in the shell before launching ant.

Gravatar

Your ant task is very usefull for us, because we’re using a generic build and it’s the only tool I’ve found where I don’t have to hardcode the module name.

But I’ve made two upgrades in the code for better optimization :
The optimize process now compare files with module.nocache.js instead of module.nocache.html(GWT 1.4)
The optimize process now copy static files from public to destdir even if there are no changed java files.

I can send you the modified java class if you want to publish a newer version.

Regards,
Bernard

Gravatar
  • recht
  • December 19th, 2007
  • 11:01 pm

Bernard: Yes, please do send any patches you have.

Gravatar

I’ve tried to send you my patch, but all my mails are returning, your mail address seems to be out of order…

Gravatar

The ant-gwt-1.1.0.jar compiles ok with defailt generated gwt-1.5 RC1 applicationCreator, but failed in the compile of gxt-1.0.1 sample resources. (Env: jdk6(U3). ant-1.7.0 running int CentOS (RedHat open source). Please let me know if there is a fix.
Thanks.
——————
compile:
[javac] Compiling 6 source files to /data/ui/build
[gwtcompile] Compiling com.dbgroups.gwt.UI
[gwtcompile] java.lang.reflect.InvocationTargetException
[gwtcompile] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[gwtcompile] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[gwtcompile] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[gwtcompile] at java.lang.reflect.Method.invoke(Method.java:597)
[gwtcompile] at dk.contix.ant.gwt.GWTCompileTask.execute(GWTCompileTask.java:196)
[gwtcompile] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[gwtcompile] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[gwtcompile] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[gwtcompile] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[gwtcompile] at java.lang.reflect.Method.invoke(Method.java:597)
[gwtcompile] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[gwtcompile] at org.apache.tools.ant.Task.perform(Task.java:348)
[gwtcompile] at org.apache.tools.ant.Target.execute(Target.java:357)
[gwtcompile] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[gwtcompile] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[gwtcompile] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)[gwtcompile] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[gwtcompile] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[gwtcompile] at org.apache.tools.ant.Main.runBuild(Main.java:698)
[gwtcompile] at org.apache.tools.ant.Main.startAnt(Main.java:199)
[gwtcompile] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[gwtcompile] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
[gwtcompile] Caused by: java.lang.OutOfMemoryError: Java heap space
[gwtcompile] at java.util.Arrays.copyOf(Arrays.java:2882)
[gwtcompile] at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
[gwtcompile] at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
[gwtcompile] at java.lang.StringBuffer.append(StringBuffer.java:224)
[gwtcompile] at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:467)
[gwtcompile] at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:411)
[gwtcompile] at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:275)
[gwtcompile] at com.google.gwt.dev.javac.JdtCompiler.compile(JdtCompiler.java:194)
[gwtcompile] at com.google.gwt.dev.javac.CompilationState.compile(CompilationState.java:72)
[gwtcompile] at com.google.gwt.dev.GWTCompiler.distill(GWTCompiler.java:327)
[gwtcompile] … 22 more

Gravatar
  • recht
  • July 26th, 2008
  • 12:41 am

You need to increase the memory allocated to ant/java. Do this with
export ANT_OPTS=”-Xmx512m”
or the equivalent on your os/shell of choice.

Gravatar

Thanks. It compiles the UI module to www directory. In the ant built.xml i copy both the src and www directories to the build directory and make a jar file GWT-UI-1.5.jar for the module com.dbgroups.gwt.UI

I then have it <inherits name-’com.dbgroups.gwt.UI’ with generated GWT-UI-1.5.jar in the module root. I get the Resource not found com.dbgroups.gwt.UI.nocache.js yet the file is in the generated jar file. I also try to copy www/com.dbgroups.ui.gwt.UI so the resource file is in the root of the generated file. I still get the Resource not found. What did i do wrong.

Thanks for the millions.
BaTien

Want your say?

* Required fields. Your e-mail address will not be published on this site

You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>