ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Working with the Google Web Toolkit
Pages: 1, 2, 3, 4, 5

The Maven Module

The GWT Maven module provided with this article gives you a few options for working with the Google Web Toolkit in a Maven project. You will notice in the sample code provided the following set in the project.properties:

google.webtoolkit.home=/home/cooper/local/gwt-linux-1.0.21
google.webtoolkit.runtarget=com.totsp.gwt.Table/Table.html
google.webtoolkit.compiletarget=com.totsp.gwt.Table
google.webtoolkit.logLevel=DEBUG

The first line is the path to your GWT installation. The second is the target you want the GWTShell to start with when you call the gwt goal. This will run the shell and open the test browser. compiletarget is the module declaration you want to use when you call gwt:compile. Finally, logLevel is the log level to show in the GWTShell when you are testing. You can look at the Mevenide properties panel in your project properties to see the rest of the settings. They pretty much map one-to-one with the command-line arguments for GWT.

The final target is gwt:debug. This will start the GWTShell in debug mode allowing you to step trough your Java code. Once you call this target, the debugger will come up and wait for a connection before anything is rendered. In NetBeans, you can click on "Attach To Debugger," select your local machine, and port 8888 to connect. You can then set breakpoints in your code and move through the web app in the debug browser! This is by far the greatest feature of the GWT. Debugging JavaScript -- even with Venkman -- always felt a little lacking. GWT lets you keep using the same tools you're used to with no changes.

Lastly, you want to make sure you have a gwt:compile executed before your war:war Maven goal. You can accomplish this by adding in the project maven.xml:

<preGoal name="war:war">
 <attainGoal name="gwt:compile"/>
</preGoal>

License Concerns

How much would you pay for all this? Well, it is free. However, it is not under any OSI license you might be familiar with. Google has terms available -- basically you are free to use it, but not redistribute it outside your organization. Now, I am no lawyer, but I am seriously troubled by this clause, however:

you may not distribute Google Web Toolkit Development Tools or any services or software associated with or derived from them, or modify, copy, license, or create derivative works from Google Web Toolkit Development Tools, unless you obtain Google's written permission in advance.

One thing that GWT seems built to do is allow people to build new and interesting components. Indeed, when I first saw it, it screamed "whole new community" of GWT-based widgets. It would seem to me, however, that this is forbidden as a derivative work. It is also worth noting an interesting part of the privacy notice on the download page:

Privacy notice: When you use the Google Web Toolkit's hosted web browser, the application sends a request back to Google's servers to check to see if you are using the most recent version of the product. As a part of this request, Google will log usage data including a timestamp of the date and time you downloaded the Google Web Toolkit and the IP address for your computer.

Resources

Robert Cooper is an independent Java developer in the Atlanta area, working with J2EE technologies and web/web service projects.


Return to ONJava.com.