blob: 36d97046c69aff07b637534ff40cc7ec2d0a8d25 [file] [log] [blame]
rjrjr@google.comf73c78e2009-07-10 16:14:42 +00001Eclipse 3.X instructions
gwt.team.scottbfeecde52007-11-30 19:12:03 +00002
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
scottb@google.comcd0c1ef2009-07-06 19:03:03 +000076------- Compiler errors & warnings --------
77Window->Preferences->Java->Compiler->Errors/Warnings
78
79The following warnings are suggested.
80
81Code Style:
82- Method with a constructor name
83
84Potential programming problems:
85- Assignment has no effect
86- Accidental boolean assignment
87- 'finally' does not complete normally
88- Using a char array in string concatentation
89- Hidden catch block
90- Inexact type match for vararg arguments
91
92Name shadowing and conflicts: all except "Local variable" hiding
93
94Deprecated and restricted API: all
95
96Unnecessary code: all except "Unnecessary 'else' statement"
97
98Generic types: all except "Generic type parameter declared with final type bound"
99
100Annotations:
101- Annotation is used as super interface
102- Enable @SuppressWarnings annotations
103
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000104== Checkstyle ==
105
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000106Checkstyle is used to enforce good programming style.
gwt.team.jat950681a2006-12-21 00:13:44 +0000107
rjrjr@google.comf73c78e2009-07-10 16:14:42 +00001081. Install Checkstyle version 4.4.2 (newer versions will not work)
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000109
110The Eclipse Checkstyle plugin can be found at:
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000111 http://eclipse-cs.sourceforge.net/
gwt.team.jat950681a2006-12-21 00:13:44 +0000112
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +00001132. Enable Custom GWT Checkstyle checks:
114
115Copy "settings/code-style/gwt-customchecks.jar" into:
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000116 <eclipse>/plugins/com.atlassw.tools.eclipse.checkstyle_x.x.x/extension-libraries
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000117
118Restart Eclipse.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000119("gwt-customchecks.jar" is also built from source into build/lib during a full
120 build)
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000121
1223. Import GWT Checks:
gwt.team.jat950681a2006-12-21 00:13:44 +0000123
124Window->Preferences->Checkstyle->New...
125Set the Type to "External Configuration File"
126Set the Name to "GWT Checks" (important)
127Set the location to "settings/code-style/gwt-checkstyle.xml".
128Suggested: Check "Protect Checkstyle configuration file".
129Click "Ok".
130
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +00001314. Import GWT Checks for Tests
132
133Repeat step 2, except:
gwt.team.bruce6e05b042007-03-13 17:39:06 +0000134Set the Name to "GWT Checks for Tests" (important)
135Set the location to "settings/code-style/gwt-checkstyle-tests.xml".
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000136
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000137------------ GWT dev-jar path ------------
138To run applications against the Eclipse projects for GWT rather than an
139extracted jar file, you need to tell GWT where to find its native libraries
140since they won't be in the jar file. Using this approach requires building
141GWT from the command line with ant once to get the files in the proper
142location, but it doesn't need to be redone unless you change any of the native
143libraries.
144
145Window->Preferences->Run/Debug->String Substitution->New...
146Set the Name to "gwt_devjar".
147Set the Value to the approprate path for your install -- for example:
jat@google.com4e26cc62009-09-21 19:02:09 +0000148 <path-to-trunk>\trunk\build\staging\gwt-0.0.0\gwt-dev.jar
149 <path-to-trunk>/trunk/build/staging/gwt-0.0.0/gwt-dev.jar
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000150Description can be left blank.
151
152
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000153== Importing the GWT core projects ==
154
jat@google.com4e26cc62009-09-21 19:02:09 +00001551) Import the 'gwt-dev' and 'gwt-user' projects
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000156
157 File->Import->General->Existing Projects into Workspace->Next
158 Browse to the 'trunk/eclipse' folder and select it
159 Deselect All
160
161 Inside this folder are a number of .projects files, only a few of
162 which you will need to get started. You may import others later.
163
jat@google.com4e26cc62009-09-21 19:02:09 +0000164 Select 'gwt-dev'
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000165 Select 'gwt-user'
166 Select any of the GWT samples as you want. The most useful ones are:
167 - Hello: very simple project useful as a little playground
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000168 - Showcase: complex UI application
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000169 - DynaTable: uses RPC
170 Then press the Finish button.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000171
1722) Dismiss the welcome tab if you are setting up an Eclipse workspace
173 for the first time.
174
scottb@google.com5ea03ef2008-08-12 21:42:04 +0000175 You should now have several new projects in your Eclipse workspace.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000176 If you are lucky, they will compile too!
177
178 If they did not compile, recheck the setting of
179
180 - GWT_ROOT
181 - GWT_TOOLS
182 - JDK_HOME
183
184 Then refresh each project.
185
1863) Finally, drop to the command line and build the project
187 using 'ant'. You may need to first download ant from the web:
188
189 http://ant.apache.org/
190
191 Run the ant installation procedure.
192
193 Before you continue, make sure that the 'ant' binary is on your path.
194
195 $ cd <gwt>/trunk/
196 $ ant
197
198 This only has to be done once to create the 'trunk/build/staging/...'
199 directories. After you build from the command line once, you can
200 use Eclipse's built in compiler.
201
202
203== Launching 'Hello' ==
204
jat@google.come7f61a72008-12-24 00:45:21 +0000205While the 'applicationCreator' script is useful for setting up projects and
206launch configurations that target a GWT installation, it is not intended for
207GWT developers working against the source code. You will want to run not
208against .jar files, but against the class files built by Eclipse. The
209following instructions help you do just that.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000210
2111) Import the 'Hello' project if you haven't already.
212
213 File->Import->General->Existing Projects into Workspace->Next
214 Browse to the 'trunk/eclipse' folder and select it
215 Deselect All
216 Select 'Hello'
217
jat@google.com4e26cc62009-09-21 19:02:09 +00002182) Now you should be able to run the 'Hello' project from the
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000219 Run dialog!
220
221
222== Creating a Launch config for a new project ==
223
224The simplest way to create a new launch config is to use the Run dialog to
225duplicate the 'Hello.launch' and 'Hello compile.launch' configurations and
226then edit the arguments and classpath settings to match your new project.
227
228
229== Recreating a Launch configuration from scratch ==
230
231This section captures the process used to create the original 'Hello.launch'
232
2331) Create or Import a new project
234
jat@google.come7f61a72008-12-24 00:45:21 +0000235 Using the 'applicationCreator' script is an easy way to do this, but you
236 cannot use the created launch scripts to develop the GWT core source because
237 they are configured to run with .jar files from a GWT installation.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000238
2392) Add a project reference to the gwt-user project:
240
241 Project->Preferences...->Projects Tab->Add...
242 Add 'gwt-user' as a project dependency.
243
2442) Create a new launch configuration
245
246 Select the project in the tree on the left of the Main Window
247 Open the Run... dialog
248
249 Create a new Java Application.
250
251 Main Tab:
252 Name: Debug Launch Config
253 Project: <your project>
254 Select the checkbox "Include inherited mains when searching for a main class"
255 Main class: com.google.gwt.dev.GWTShell
256 (Note: the 'Search' button may not work, just type it in without a search.)
257
258Arguments Tab:
259 In the 'Program arguments' text area, add the name of the module
260 host web page and any other hosted mode arguments:
261
262 -out www
263 <your module package>.<module name>/<module name>.html
264
265 e.g.
266 -out
267 www com.google.gwt.sample.hello.Hello/Hello.html
268
269 In the 'VM arguments' text area, add the following:
270
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000271 -Dgwt.devjar=${gwt_devjar}
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000272
273 This is a very obscure way of telling GWT where to find the C++ libraries
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000274 located in that directory, and the gwt_devjar variable should be set as
275 described above. If you do not have this set, or if you have not build GWT
276 at least once using ant, you will see an exception like this at startup:
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000277
278 Exception in thread "main" java.lang.ExceptionInInitializerError
279 Caused by: java.lang.RuntimeException: Installation problem detected,
280 please reinstall GWT
281
282
283 Other VM arguments you might want to add:
284 -ea (enable assertions)
285 -server (enable java server VM)
286 -Xcheck:jni (adds extra checks before passing args to a JNI method)
287
288Classpath:
289 Click on 'User Entries' and use the 'Advanced' button to add the following folders:
290 <project>/src
291 gwt-user/core/src
292 gwt-user/core/super
jat@google.com4e26cc62009-09-21 19:02:09 +0000293 gwt-dev/core/super
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000294
295 Now, select the default classpath (Hello) and move it all the way
296 to the bottom of the list using the 'Down' button.
297
298 You should now be able to run the application
299 using the Eclipse launcher.