blob: f85c7edbf7978f066e4fa7d1bdaee8cce8cea5a0 [file] [log] [blame]
gwt.team.scottbfeecde52007-11-30 19:12:03 +00001Eclipse 3.3.X instructions
2
3These instructions are intended for contributors to the GWT source
4code repository that want to run the Eclipse IDE. It describes how to
5configure Eclipse for the correct coding styles and how to setup a GWT
6project for debugging the core GWT code.
7
8
9== Configure Eclipse Environment==
10
11 All relative paths are relative to the GWT source repository's
12 'trunk/eclipse' folder. For best results, launch Eclipse from the
13 trunk/eclipse folder from the command line.
gwt.team.jat950681a2006-12-21 00:13:44 +000014
15---------- Required GWT variables ---------
16
17Window->Preferences->General->Workspace->Linked Resources
gwt.team.jate24e8272007-01-09 17:02:18 +000018Create a variable named "GWT_ROOT" pointing to your "trunk" folder.
gwt.team.jat950681a2006-12-21 00:13:44 +000019
20Window->Preferences->Java->Build Path->Classpath Variables
gwt.team.jate24e8272007-01-09 17:02:18 +000021Create a variable named "GWT_TOOLS" pointing to your "tools" folder.
22Create a variable named "JDK_HOME" pointing to the root of your JDK install
23 (for example, C:\Program Files\jdk1.5.0_05 or /usr/lib/j2sdk1.5-sun)
gwt.team.jat950681a2006-12-21 00:13:44 +000024
25---------------- Spelling -----------------
26
gwt.team.jat276a80f2007-01-04 15:50:01 +000027Window->Preferences->General->Editors->Text Editors->Spelling
gwt.team.scottbfeecde52007-11-30 19:12:03 +000028Enable spell checking
29Use "settings/english.dictionary".
gwt.team.jat950681a2006-12-21 00:13:44 +000030
31------------ Output Filtering -------------
32
33Window->Preferences->Java->Compiler->Building
34Make sure "Filtered Resources" includes ".svn/"
35
36---------- Code style/formatting ----------
37
38Window->Preferences->Java->Code Style->Formatter->Import...
gwt.team.scottbfeecde52007-11-30 19:12:03 +000039 settings/code-style/gwt-format.xml
gwt.team.jat950681a2006-12-21 00:13:44 +000040
41----------- Import organization -----------
42
43Window->Preferences->Java->Code Style->Organize Imports->Import...
gwt.team.scottbfeecde52007-11-30 19:12:03 +000044 settings/code-style/gwt.importorder
gwt.team.jat950681a2006-12-21 00:13:44 +000045
46------------ Member sort order ------------
47
48Window->Preferences->Java->Appearance->Members Sort Order
gwt.team.bruce6e05b042007-03-13 17:39:06 +000049There is no import here, so make your settings match:
gwt.team.scottbfeecde52007-11-30 19:12:03 +000050 settings/code-style/gwt-sort-order.png
gwt.team.bruce6e05b042007-03-13 17:39:06 +000051
52First, members should be sorted by category.
531) Types
542) Static Fields
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000553) Static Initializers
gwt.team.bruce6e05b042007-03-13 17:39:06 +0000564) Static Methods
575) Fields
586) Initializers
597) Constructors
608) Methods
61
62Second, members in the same category should be sorted by visibility.
631) Public
642) Protected
653) Default
664) Private
67
gwt.team.scottbfeecde52007-11-30 19:12:03 +000068Third, within a category/visibility combination, members should be sorted
gwt.team.bruce6e05b042007-03-13 17:39:06 +000069alphabetically.
jat@google.come7f61a72008-12-24 00:45:21 +000070
71
72------------ Compiler settings ------------
73Window->Preferences->Java->Compiler
74Set the compiler compliance level to 1.5.
gwt.team.jat950681a2006-12-21 00:13:44 +000075
gwt.team.scottbfeecde52007-11-30 19:12:03 +000076== Checkstyle ==
77
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +000078Checkstyle is used to enforce good programming style.
gwt.team.jat950681a2006-12-21 00:13:44 +000079
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000801. Install Checkstyle
81
82The Eclipse Checkstyle plugin can be found at:
gwt.team.scottbfeecde52007-11-30 19:12:03 +000083 http://eclipse-cs.sourceforge.net/
gwt.team.jat950681a2006-12-21 00:13:44 +000084
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000852. Enable Custom GWT Checkstyle checks:
86
87Copy "settings/code-style/gwt-customchecks.jar" into:
gwt.team.scottbfeecde52007-11-30 19:12:03 +000088 <eclipse>/plugins/com.atlassw.tools.eclipse.checkstyle_x.x.x/extension-libraries
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +000089
90Restart Eclipse.
gwt.team.scottbfeecde52007-11-30 19:12:03 +000091("gwt-customchecks.jar" is also built from source into build/lib during a full
92 build)
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +000093
943. Import GWT Checks:
gwt.team.jat950681a2006-12-21 00:13:44 +000095
96Window->Preferences->Checkstyle->New...
97Set the Type to "External Configuration File"
98Set the Name to "GWT Checks" (important)
99Set the location to "settings/code-style/gwt-checkstyle.xml".
100Suggested: Check "Protect Checkstyle configuration file".
101Click "Ok".
102
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +00001034. Import GWT Checks for Tests
104
105Repeat step 2, except:
gwt.team.bruce6e05b042007-03-13 17:39:06 +0000106Set the Name to "GWT Checks for Tests" (important)
107Set the location to "settings/code-style/gwt-checkstyle-tests.xml".
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000108
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000109------------ GWT dev-jar path ------------
110To run applications against the Eclipse projects for GWT rather than an
111extracted jar file, you need to tell GWT where to find its native libraries
112since they won't be in the jar file. Using this approach requires building
113GWT from the command line with ant once to get the files in the proper
114location, but it doesn't need to be redone unless you change any of the native
115libraries.
116
117Window->Preferences->Run/Debug->String Substitution->New...
118Set the Name to "gwt_devjar".
119Set the Value to the approprate path for your install -- for example:
120 <path-to-trunk>\trunk\build\staging\gwt-windows-0.0.0\gwt-dev-windows.jar
121 <path-to-trunk>/trunk/build/staging/gwt-linux-0.0.0/gwt-dev-linux.jar
122 <path-to-trunk>/trunk/build/staging/gwt-mac-0.0.0/gwt-dev-mac.jar
123Description can be left blank.
124
125
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000126== Importing the GWT core projects ==
127
1281) Import the 'gwt-dev-<platform>' and 'gwt-user' projects
129
130 File->Import->General->Existing Projects into Workspace->Next
131 Browse to the 'trunk/eclipse' folder and select it
132 Deselect All
133
134 Inside this folder are a number of .projects files, only a few of
135 which you will need to get started. You may import others later.
136
137 Select 'gwt-dev-<platform>' appropriate to your OS
138 Select 'gwt-user'
139 Select any of the GWT samples as you want. The most useful ones are:
140 - Hello: very simple project useful as a little playground
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000141 - Showcase: complex UI application
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000142 - DynaTable: uses RPC
143 Then press the Finish button.
144
145 Non-windows users: By default, gwt-user depends on gwt-dev-windows, which you
146 will not have imported. You must update the gwt-user project configuration
147 to depend on gwt-dev-linux or gwt-dev-mac (whichever one you imported). This
148 can be done by editing gwt-user's .classpath file directly, or through the IDE
149 under Project->Properties->Java Build Path->Projects.
150
1512) Dismiss the welcome tab if you are setting up an Eclipse workspace
152 for the first time.
153
scottb@google.com5ea03ef2008-08-12 21:42:04 +0000154 You should now have several new projects in your Eclipse workspace.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000155 If you are lucky, they will compile too!
156
157 If they did not compile, recheck the setting of
158
159 - GWT_ROOT
160 - GWT_TOOLS
161 - JDK_HOME
162
163 Then refresh each project.
164
1653) Finally, drop to the command line and build the project
166 using 'ant'. You may need to first download ant from the web:
167
168 http://ant.apache.org/
169
170 Run the ant installation procedure.
171
172 Before you continue, make sure that the 'ant' binary is on your path.
173
174 $ cd <gwt>/trunk/
175 $ ant
176
177 This only has to be done once to create the 'trunk/build/staging/...'
178 directories. After you build from the command line once, you can
179 use Eclipse's built in compiler.
180
181
182== Launching 'Hello' ==
183
jat@google.come7f61a72008-12-24 00:45:21 +0000184While the 'applicationCreator' script is useful for setting up projects and
185launch configurations that target a GWT installation, it is not intended for
186GWT developers working against the source code. You will want to run not
187against .jar files, but against the class files built by Eclipse. The
188following instructions help you do just that.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000189
1901) Import the 'Hello' project if you haven't already.
191
192 File->Import->General->Existing Projects into Workspace->Next
193 Browse to the 'trunk/eclipse' folder and select it
194 Deselect All
195 Select 'Hello'
196
1972) Non-windows users: Replace the gwt-dev-windows project dependency and paths.
198
199 Run->Open Run Dialog...->Java Application->Hello
200 Select the 'Classpath' tab
201 Remove gwt-dev-windows paths
202 Select 'User Entries'
203 Advanced->Add Folder-> Add gwt-dev-<platform>/core/super
204 Select the (default classpath) item and use the 'Down' button
205 to make it the last item in the list.
206 You could also just edit Hello.launch and search/replace "windows" with
207 "linux" or "mac".
208
rjrjr@google.com7ad09d42009-01-22 16:32:30 +00002093) Repeat step 2 for the 'Hello compile' project.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000210
rjrjr@google.com7ad09d42009-01-22 16:32:30 +00002114) Now you should be able to run the 'Hello' project from the
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000212 Run dialog!
213
214
215== Creating a Launch config for a new project ==
216
217The simplest way to create a new launch config is to use the Run dialog to
218duplicate the 'Hello.launch' and 'Hello compile.launch' configurations and
219then edit the arguments and classpath settings to match your new project.
220
221
222== Recreating a Launch configuration from scratch ==
223
224This section captures the process used to create the original 'Hello.launch'
225
2261) Create or Import a new project
227
jat@google.come7f61a72008-12-24 00:45:21 +0000228 Using the 'applicationCreator' script is an easy way to do this, but you
229 cannot use the created launch scripts to develop the GWT core source because
230 they are configured to run with .jar files from a GWT installation.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000231
2322) Add a project reference to the gwt-user project:
233
234 Project->Preferences...->Projects Tab->Add...
235 Add 'gwt-user' as a project dependency.
236
2372) Create a new launch configuration
238
239 Select the project in the tree on the left of the Main Window
240 Open the Run... dialog
241
242 Create a new Java Application.
243
244 Main Tab:
245 Name: Debug Launch Config
246 Project: <your project>
247 Select the checkbox "Include inherited mains when searching for a main class"
248 Main class: com.google.gwt.dev.GWTShell
249 (Note: the 'Search' button may not work, just type it in without a search.)
250
251Arguments Tab:
252 In the 'Program arguments' text area, add the name of the module
253 host web page and any other hosted mode arguments:
254
255 -out www
256 <your module package>.<module name>/<module name>.html
257
258 e.g.
259 -out
260 www com.google.gwt.sample.hello.Hello/Hello.html
261
262 In the 'VM arguments' text area, add the following:
263
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000264 -Dgwt.devjar=${gwt_devjar}
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000265
266 This is a very obscure way of telling GWT where to find the C++ libraries
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000267 located in that directory, and the gwt_devjar variable should be set as
268 described above. If you do not have this set, or if you have not build GWT
269 at least once using ant, you will see an exception like this at startup:
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000270
271 Exception in thread "main" java.lang.ExceptionInInitializerError
272 Caused by: java.lang.RuntimeException: Installation problem detected,
273 please reinstall GWT
274
275
276 Other VM arguments you might want to add:
277 -ea (enable assertions)
278 -server (enable java server VM)
279 -Xcheck:jni (adds extra checks before passing args to a JNI method)
280
281Classpath:
282 Click on 'User Entries' and use the 'Advanced' button to add the following folders:
283 <project>/src
284 gwt-user/core/src
285 gwt-user/core/super
286 gwt-dev-<platform>/core/super
287
288 Now, select the default classpath (Hello) and move it all the way
289 to the bottom of the list using the 'Down' button.
290
291 You should now be able to run the application
292 using the Eclipse launcher.