GWTTestSuite makes builds faster, but requires JUnit 4.1
Earlier this week, I spent some time implementing GWTTestSuite to speed up my project's build process. In Hudson, the project was taking around 15 minutes to build, locally it was only taking 5 minutes for mvn test. In IDEA, I could run all the tests in under a minute. While 15 minutes isn't a long time for a build to execute, a co-worker expressed some concern:
Does Maven have to run GWT test and individual Java processes? (See target/gwtTest/*.sh) This arrangement and the overhead of JVM launches is another reason why builds take so long. As we add more GWT tests we are going to test that LinkedIn record for the slowest build ever.
After this comment, I started looking into GWTTestSuite using Olivier Modica's blog entry as a guide. It was very easy to get things working in IDEA. However, when I'd run mvn test, I'd get the following error:
Error: java.lang.ClassCastException
No line numbers. No class information. Zilch. After comparing my project's pom.xml with the one from the default gwt-maven archetype, I noticed the default used JUnit 4.1, while I had the latest-and-supposedly-greatest JUnit 4.4. Reverting to JUnit 4.1 fixed the problem. Now Hudson takes 3:15 to execute the build instead of 15 minutes.
The reason for this blog post is this doesn't seem to be documented anywhere. Hopefully other developers will find this entry when googling for this issue.
Related to making GWT faster, I also added the following line to my Application.gwt.xml file:
<set-property name="user.agent" value="safari" />
This dropped the gwt:compile
time from 1 minute to 25 seconds. As explained in the documentation, you can use the "user.agent" setting to only generate one JS file for your app instead of 4. The strange thing about adding this setting was I pretty much forgot about it since everything seemed to work fine on both Safari and Firefox. When I started testing things in IE6, I started seeing a lot of JavaScript errors. After debugging for an hour or so, I realized this setting was there, removed it, and everything started working great in all browsers.
Now if I could just figure out how to use safari-only for development, but remove the line when building the WAR. Suggestions welcome.
Posted by Peter Thomas on February 27, 2009 at 11:02 PM MST #
> You mean reverting to JUnit 4.1 right?
Yep! Thanks for the (very important) correction Peter.
Posted by Matt Raible on February 27, 2009 at 11:12 PM MST #
Posted by Jeff Genender on February 28, 2009 at 05:09 AM MST #
Jeff - I tried something similar, but I believe the value is read from the raw Application.gwt.xml before it's processed, so it doesn't work. In Application.gwt.xml, I added:
In my pom.xml, I added filtering for this file:
And I added a <user.agent> property:
The $[user.agent} token gets replaced correctly during resources:resources, but four MD5.cache.html get generated. Also, the user.agent property uses escaped XML for < and >, but I can't get it to show up properly in this comment.
Posted by Matt Raible on February 28, 2009 at 05:16 PM MST #
Matt,
You could always duplicate the Application.gwt.xml, i.e. have a ApplicationSafari.gwt.xml version, and then use parameter replacement in the compile section of the maven compile plugin, e.g.:
and then specify
as a default, and
when you just want Safari output.
I suppose you could change this slightly and have just the Safari bit parameterised then it would work cross-project, and you could set it in your maven settings.xml file
Not as elegant as what you really want, but it should work ;-)
Posted by RoyPorter on March 02, 2009 at 02:26 PM MST #
Posted by Dean Povey on March 19, 2009 at 01:16 AM MDT #