blob: 108404ddab2480d80612da682f17cf635bb3083d [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
rjrjr@google.comf01acaa2011-05-02 16:43:22 +000023 (for example, C:\Program Files\jdk1.6 or /usr/lib/j2sdk1.6-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
rjrjr@google.comf01acaa2011-05-02 16:43:22 +000074Set the compiler compliance level to 1.6.
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
zundel@google.come0fe3c12011-06-27 16:15:42 +0000104------- Annotation Processor --------
105
rjrjr@google.comcb677182011-09-19 21:21:25 +0000106Some components of GWT (RequestFactory) use annotation processing. Do
107the following to add a directory named '.apt-generated' to the source
108path, and put on the APT factory path annotation processors required
109by the RequestFactory unit tests.
zundel@google.come0fe3c12011-06-27 16:15:42 +0000110
111Select project 'gwt-user'
112
rjrjr@google.comcb677182011-09-19 21:21:25 +0000113Project->Properties->Java Compiler->AnnotationProcessor
zundel@google.come0fe3c12011-06-27 16:15:42 +0000114- Check Enable project specific settings
115- Check Enable annotation processing
rjrjr@google.comcb677182011-09-19 21:21:25 +0000116- Optional: check Enable processing in editor (for on-the-fly
117 validation of RequestFactory interfaces)
zundel@google.come0fe3c12011-06-27 16:15:42 +0000118
rjrjr@google.comcb677182011-09-19 21:21:25 +0000119Project->Properties->Java Compiler->AnnotationProcessor->Factory Path
120- Add Variable
121- Select GWT_TOOLS and click Extend
122- Select lib/requestfactory and the most recently dated
123 requestfactory-apt-YYYY-MM-DD.jar
124- Optional: deselect org.eclipse.jst.ws.annoations.core if eclipse has
125 added it, it can make eclipse sluggish
zundel@google.come0fe3c12011-06-27 16:15:42 +0000126
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000127== Checkstyle ==
128
rjrjr@google.comcb677182011-09-19 21:21:25 +0000129Checkstyle is used to enforce good programming style. Its use in
130Eclipse is optional, since it is also run as part of the acceptance
131test suite.
gwt.team.jat950681a2006-12-21 00:13:44 +0000132
pdr@google.com84e8be92010-09-01 11:21:58 +00001331. Install Checkstyle version 4.4.3 (newer versions will not work)
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000134
135The Eclipse Checkstyle plugin can be found at:
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000136 http://eclipse-cs.sourceforge.net/
gwt.team.jat950681a2006-12-21 00:13:44 +0000137
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +00001382. Enable Custom GWT Checkstyle checks:
139
140Copy "settings/code-style/gwt-customchecks.jar" into:
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000141 <eclipse>/plugins/com.atlassw.tools.eclipse.checkstyle_x.x.x/extension-libraries
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000142
143Restart Eclipse.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000144("gwt-customchecks.jar" is also built from source into build/lib during a full
145 build)
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +0000146
1473. Import GWT Checks:
gwt.team.jat950681a2006-12-21 00:13:44 +0000148
149Window->Preferences->Checkstyle->New...
150Set the Type to "External Configuration File"
151Set the Name to "GWT Checks" (important)
152Set the location to "settings/code-style/gwt-checkstyle.xml".
153Suggested: Check "Protect Checkstyle configuration file".
154Click "Ok".
155
gwt.team.scottb3f1f1a02007-08-28 19:27:49 +00001564. Import GWT Checks for Tests
157
158Repeat step 2, except:
gwt.team.bruce6e05b042007-03-13 17:39:06 +0000159Set the Name to "GWT Checks for Tests" (important)
160Set the location to "settings/code-style/gwt-checkstyle-tests.xml".
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000161
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000162------------ GWT dev-jar path ------------
163To run applications against the Eclipse projects for GWT rather than an
164extracted jar file, you need to tell GWT where to find its native libraries
165since they won't be in the jar file. Using this approach requires building
166GWT from the command line with ant once to get the files in the proper
167location, but it doesn't need to be redone unless you change any of the native
168libraries.
169
170Window->Preferences->Run/Debug->String Substitution->New...
171Set the Name to "gwt_devjar".
rjrjr@google.comcb677182011-09-19 21:21:25 +0000172Set the Value to the appropriate path for your install -- for example:
jat@google.com4e26cc62009-09-21 19:02:09 +0000173 <path-to-trunk>\trunk\build\staging\gwt-0.0.0\gwt-dev.jar
174 <path-to-trunk>/trunk/build/staging/gwt-0.0.0/gwt-dev.jar
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000175Description can be left blank.
176
177
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000178== Importing the GWT core projects ==
179
jat@google.com4e26cc62009-09-21 19:02:09 +00001801) Import the 'gwt-dev' and 'gwt-user' projects
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000181
182 File->Import->General->Existing Projects into Workspace->Next
183 Browse to the 'trunk/eclipse' folder and select it
184 Deselect All
185
186 Inside this folder are a number of .projects files, only a few of
187 which you will need to get started. You may import others later.
188
jat@google.com4e26cc62009-09-21 19:02:09 +0000189 Select 'gwt-dev'
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000190 Select 'gwt-user'
191 Select any of the GWT samples as you want. The most useful ones are:
192 - Hello: very simple project useful as a little playground
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000193 - Showcase: complex UI application
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000194 - DynaTable: uses RPC
195 Then press the Finish button.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000196
pdr@google.com3019d1f2010-11-12 12:18:43 +00001972) If you are using the Google Plugin for Eclipse
198 (http://code.google.com/eclipse), enable it for 'gwt-user'
199
200 Right click the 'gwt-user' project and go to properties. Select
201 Google->Web Toolkit, and check the box for 'Use Google Web Toolkit'.
202
203 Then, select Google->Web Application, and uncheck 'This project has a WAR
204 directory'. Then press the "Apply" button.
205
2063) Dismiss the welcome tab if you are setting up an Eclipse workspace
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000207 for the first time.
208
scottb@google.com5ea03ef2008-08-12 21:42:04 +0000209 You should now have several new projects in your Eclipse workspace.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000210 If you are lucky, they will compile too!
211
212 If they did not compile, recheck the setting of
213
214 - GWT_ROOT
215 - GWT_TOOLS
216 - JDK_HOME
217
218 Then refresh each project.
219
pdr@google.com3019d1f2010-11-12 12:18:43 +00002204) Finally, drop to the command line and build the project
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000221 using 'ant'. You may need to first download ant from the web:
222
223 http://ant.apache.org/
224
225 Run the ant installation procedure.
226
227 Before you continue, make sure that the 'ant' binary is on your path.
228
229 $ cd <gwt>/trunk/
230 $ ant
231
232 This only has to be done once to create the 'trunk/build/staging/...'
233 directories. After you build from the command line once, you can
234 use Eclipse's built in compiler.
235
236
237== Launching 'Hello' ==
238
jat@google.come7f61a72008-12-24 00:45:21 +0000239While the 'applicationCreator' script is useful for setting up projects and
240launch configurations that target a GWT installation, it is not intended for
241GWT developers working against the source code. You will want to run not
242against .jar files, but against the class files built by Eclipse. The
243following instructions help you do just that.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000244
2451) Import the 'Hello' project if you haven't already.
246
247 File->Import->General->Existing Projects into Workspace->Next
248 Browse to the 'trunk/eclipse' folder and select it
249 Deselect All
250 Select 'Hello'
251
jat@google.com4e26cc62009-09-21 19:02:09 +00002522) Now you should be able to run the 'Hello' project from the
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000253 Run dialog!
254
255
256== Creating a Launch config for a new project ==
257
258The simplest way to create a new launch config is to use the Run dialog to
259duplicate the 'Hello.launch' and 'Hello compile.launch' configurations and
260then edit the arguments and classpath settings to match your new project.
261
262
263== Recreating a Launch configuration from scratch ==
264
265This section captures the process used to create the original 'Hello.launch'
266
2671) Create or Import a new project
268
jat@google.come7f61a72008-12-24 00:45:21 +0000269 Using the 'applicationCreator' script is an easy way to do this, but you
270 cannot use the created launch scripts to develop the GWT core source because
271 they are configured to run with .jar files from a GWT installation.
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000272
2732) Add a project reference to the gwt-user project:
274
275 Project->Preferences...->Projects Tab->Add...
276 Add 'gwt-user' as a project dependency.
277
pdr@google.com3019d1f2010-11-12 12:18:43 +00002783) Create a new launch configuration
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000279
280 Select the project in the tree on the left of the Main Window
281 Open the Run... dialog
282
283 Create a new Java Application.
284
285 Main Tab:
286 Name: Debug Launch Config
287 Project: <your project>
288 Select the checkbox "Include inherited mains when searching for a main class"
289 Main class: com.google.gwt.dev.GWTShell
290 (Note: the 'Search' button may not work, just type it in without a search.)
291
292Arguments Tab:
293 In the 'Program arguments' text area, add the name of the module
294 host web page and any other hosted mode arguments:
295
296 -out www
297 <your module package>.<module name>/<module name>.html
298
299 e.g.
300 -out
301 www com.google.gwt.sample.hello.Hello/Hello.html
302
303 In the 'VM arguments' text area, add the following:
304
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000305 -Dgwt.devjar=${gwt_devjar}
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000306
307 This is a very obscure way of telling GWT where to find the C++ libraries
rjrjr@google.com7ad09d42009-01-22 16:32:30 +0000308 located in that directory, and the gwt_devjar variable should be set as
309 described above. If you do not have this set, or if you have not build GWT
310 at least once using ant, you will see an exception like this at startup:
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000311
312 Exception in thread "main" java.lang.ExceptionInInitializerError
313 Caused by: java.lang.RuntimeException: Installation problem detected,
314 please reinstall GWT
315
316
317 Other VM arguments you might want to add:
318 -ea (enable assertions)
319 -server (enable java server VM)
320 -Xcheck:jni (adds extra checks before passing args to a JNI method)
321
322Classpath:
323 Click on 'User Entries' and use the 'Advanced' button to add the following folders:
324 <project>/src
325 gwt-user/core/src
326 gwt-user/core/super
jat@google.com4e26cc62009-09-21 19:02:09 +0000327 gwt-dev/core/super
gwt.team.scottbfeecde52007-11-30 19:12:03 +0000328
329 Now, select the default classpath (Hello) and move it all the way
330 to the bottom of the list using the 'Down' button.
331
332 You should now be able to run the application
333 using the Eclipse launcher.