Using GWT from source
Using GWT regularly, sometimes, there is the need to verify “what lies beneath” or even to change or expand certain classes.
Programmers contributing to the main gwt source trunk will find this quite trivial, but I usually install tools “as they are”, so this guide should be helpful for those who want to see how to use a complex tool like gwt directly from their favourite IDE (eclipse) in its source code version.
A good starting point is certainly the main developer website
http://code.google.com/p/google-web-toolkit/source/checkout
on this page one can navigate the project clicking on the “browse” button (this works for any project hosted on google code)
Inside the trunk, eclipse sub dir, there is this interesting guide, which I’ll follow step by step, creating my own development environment for GWT:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/eclipse/README.txt
To start, let’s create the directory c:\gwt and check out the trunk and the tools with subversion:
mkdir c:\gwtcd c:\gwt svn checkout http://google-web-toolkit.googlecode.com/svn/trunk/ svn checkout http://google-web-toolkit.googlecode.com/svn/tools/
As the guide says, all paths are relative to C:\gwt\trunk\eclipse so I will launch eclipse from the command line (later on we can create a batch file for this), also creating a new workspace to keep all of this separated from my other projects
cd c:\gwt\trunk\eclipsec:\eclipse\eclipse.exe –data c:\gwtworkspace
Inside Eclipse:
---------- Required GWT variables ---------
Window->Preferences->General->Workspace->Linked Resources
Create a variable named "GWT_ROOT" pointing to your "trunk" folder.
Window->Preferences->Java->Build Path->Classpath Variables
Create a variable named "GWT_TOOLS" pointing to your "tools" folder.
Create a variable named "JDK_HOME" pointing to the root of your JDK install
(for example, C:\Program Files\jdk1.5.0_05 or /usr/lib/j2sdk1.5-sun)
------------ Compiler settings ------------
Window->Preferences->Java->Compiler
Set the compiler compliance level to 1.5.
The following is needed only if you want to run gwt application against the gwt-dev eclipse projects rather than the jar file (in short, only if you want to edit and debug gwt-dev)
Window->Preferences->Run/Debug->String Substitution->New... Set the Name to "gwt_devjar". Set the Value to c:\gwt\trunk\build\staging\gwt-windows-0.0.0\gwt-dev-windows.jar Description can be left blank.
Import GWT in eclipse
File->Import->General->Existing Projects into Workspace->Next
Browse to the 'trunk/eclipse' folder and select it
Deselect All
Inside this folder are a number of .projects files, only a few of
which you will need to get started. You may import others later.
Select 'gwt-dev-windows' and 'gwt-user'
Select:
- Hello: very simple project useful as a little playground
- Showcase: complex UI application
- DynaTable: uses RPC
Build GWT with ant (install ant if you don’t have it) to create the “build/staging/…” directories:
cd c:\gwt\trunk\ ant
Back in eclipse Run –> Run Configurations you should find the Hello launcher as a Java application (that invokes directly com.google.gwt.dev.HostedMode) were you can start playing around with gwt source code.
This guide is based on the README file in the eclipse directory of the gwt trunk: it is not intended as a substitute for that document that is the main guide of creating a gwt source code – eclipse environment (especially if you intend contributing to the project).
Other minor eclipse settings that might be useful:
------------ Output Filtering ------------- Window->Preferences->Java->Compiler->Building Make sure "Filtered Resources" includes ".svn/" ---------- Code style/formatting ---------- Window->Preferences->Java->Code Style->Formatter->Import... settings/code-style/gwt-format.xml ----------- Import organization ----------- Window->Preferences->Java->Code Style->Organize Imports->Import... settings/code-style/gwt.importorder
