rjrjr@google.com | f73c78e | 2009-07-10 16:14:42 +0000 | [diff] [blame] | 1 | Eclipse 3.X instructions |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 2 | |
| 3 | These instructions are intended for contributors to the GWT source |
| 4 | code repository that want to run the Eclipse IDE. It describes how to |
| 5 | configure Eclipse for the correct coding styles and how to setup a GWT |
| 6 | project 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.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 14 | |
| 15 | ---------- Required GWT variables --------- |
| 16 | |
| 17 | Window->Preferences->General->Workspace->Linked Resources |
gwt.team.jat | e24e827 | 2007-01-09 17:02:18 +0000 | [diff] [blame] | 18 | Create a variable named "GWT_ROOT" pointing to your "trunk" folder. |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 19 | |
| 20 | Window->Preferences->Java->Build Path->Classpath Variables |
gwt.team.jat | e24e827 | 2007-01-09 17:02:18 +0000 | [diff] [blame] | 21 | Create a variable named "GWT_TOOLS" pointing to your "tools" folder. |
| 22 | Create a variable named "JDK_HOME" pointing to the root of your JDK install |
rjrjr@google.com | f01acaa | 2011-05-02 16:43:22 +0000 | [diff] [blame] | 23 | (for example, C:\Program Files\jdk1.6 or /usr/lib/j2sdk1.6-sun) |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 24 | |
| 25 | ---------------- Spelling ----------------- |
| 26 | |
gwt.team.jat | 276a80f | 2007-01-04 15:50:01 +0000 | [diff] [blame] | 27 | Window->Preferences->General->Editors->Text Editors->Spelling |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 28 | Enable spell checking |
| 29 | Use "settings/english.dictionary". |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 30 | |
| 31 | ------------ Output Filtering ------------- |
| 32 | |
| 33 | Window->Preferences->Java->Compiler->Building |
| 34 | Make sure "Filtered Resources" includes ".svn/" |
| 35 | |
| 36 | ---------- Code style/formatting ---------- |
| 37 | |
| 38 | Window->Preferences->Java->Code Style->Formatter->Import... |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 39 | settings/code-style/gwt-format.xml |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 40 | |
| 41 | ----------- Import organization ----------- |
| 42 | |
| 43 | Window->Preferences->Java->Code Style->Organize Imports->Import... |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 44 | settings/code-style/gwt.importorder |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 45 | |
| 46 | ------------ Member sort order ------------ |
| 47 | |
| 48 | Window->Preferences->Java->Appearance->Members Sort Order |
gwt.team.bruce | 6e05b04 | 2007-03-13 17:39:06 +0000 | [diff] [blame] | 49 | There is no import here, so make your settings match: |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 50 | settings/code-style/gwt-sort-order.png |
gwt.team.bruce | 6e05b04 | 2007-03-13 17:39:06 +0000 | [diff] [blame] | 51 | |
| 52 | First, members should be sorted by category. |
| 53 | 1) Types |
| 54 | 2) Static Fields |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 55 | 3) Static Initializers |
gwt.team.bruce | 6e05b04 | 2007-03-13 17:39:06 +0000 | [diff] [blame] | 56 | 4) Static Methods |
| 57 | 5) Fields |
| 58 | 6) Initializers |
| 59 | 7) Constructors |
| 60 | 8) Methods |
| 61 | |
| 62 | Second, members in the same category should be sorted by visibility. |
| 63 | 1) Public |
| 64 | 2) Protected |
| 65 | 3) Default |
| 66 | 4) Private |
| 67 | |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 68 | Third, within a category/visibility combination, members should be sorted |
gwt.team.bruce | 6e05b04 | 2007-03-13 17:39:06 +0000 | [diff] [blame] | 69 | alphabetically. |
jat@google.com | e7f61a7 | 2008-12-24 00:45:21 +0000 | [diff] [blame] | 70 | |
| 71 | |
| 72 | ------------ Compiler settings ------------ |
| 73 | Window->Preferences->Java->Compiler |
rjrjr@google.com | f01acaa | 2011-05-02 16:43:22 +0000 | [diff] [blame] | 74 | Set the compiler compliance level to 1.6. |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 75 | |
scottb@google.com | cd0c1ef | 2009-07-06 19:03:03 +0000 | [diff] [blame] | 76 | ------- Compiler errors & warnings -------- |
| 77 | Window->Preferences->Java->Compiler->Errors/Warnings |
| 78 | |
| 79 | The following warnings are suggested. |
| 80 | |
| 81 | Code Style: |
| 82 | - Method with a constructor name |
| 83 | |
| 84 | Potential 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 | |
| 92 | Name shadowing and conflicts: all except "Local variable" hiding |
| 93 | |
| 94 | Deprecated and restricted API: all |
| 95 | |
| 96 | Unnecessary code: all except "Unnecessary 'else' statement" |
| 97 | |
| 98 | Generic types: all except "Generic type parameter declared with final type bound" |
| 99 | |
| 100 | Annotations: |
| 101 | - Annotation is used as super interface |
| 102 | - Enable @SuppressWarnings annotations |
| 103 | |
zundel@google.com | e0fe3c1 | 2011-06-27 16:15:42 +0000 | [diff] [blame] | 104 | ------- Annotation Processor -------- |
| 105 | |
rjrjr@google.com | cb67718 | 2011-09-19 21:21:25 +0000 | [diff] [blame] | 106 | Some components of GWT (RequestFactory) use annotation processing. Do |
| 107 | the following to add a directory named '.apt-generated' to the source |
| 108 | path, and put on the APT factory path annotation processors required |
| 109 | by the RequestFactory unit tests. |
zundel@google.com | e0fe3c1 | 2011-06-27 16:15:42 +0000 | [diff] [blame] | 110 | |
| 111 | Select project 'gwt-user' |
| 112 | |
rjrjr@google.com | cb67718 | 2011-09-19 21:21:25 +0000 | [diff] [blame] | 113 | Project->Properties->Java Compiler->AnnotationProcessor |
zundel@google.com | e0fe3c1 | 2011-06-27 16:15:42 +0000 | [diff] [blame] | 114 | - Check Enable project specific settings |
| 115 | - Check Enable annotation processing |
rjrjr@google.com | cb67718 | 2011-09-19 21:21:25 +0000 | [diff] [blame] | 116 | - Optional: check Enable processing in editor (for on-the-fly |
| 117 | validation of RequestFactory interfaces) |
zundel@google.com | e0fe3c1 | 2011-06-27 16:15:42 +0000 | [diff] [blame] | 118 | |
rjrjr@google.com | cb67718 | 2011-09-19 21:21:25 +0000 | [diff] [blame] | 119 | Project->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.com | e0fe3c1 | 2011-06-27 16:15:42 +0000 | [diff] [blame] | 126 | |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 127 | == Checkstyle == |
| 128 | |
rjrjr@google.com | cb67718 | 2011-09-19 21:21:25 +0000 | [diff] [blame] | 129 | Checkstyle is used to enforce good programming style. Its use in |
| 130 | Eclipse is optional, since it is also run as part of the acceptance |
| 131 | test suite. |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 132 | |
pdr@google.com | 84e8be9 | 2010-09-01 11:21:58 +0000 | [diff] [blame] | 133 | 1. Install Checkstyle version 4.4.3 (newer versions will not work) |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 134 | |
| 135 | The Eclipse Checkstyle plugin can be found at: |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 136 | http://eclipse-cs.sourceforge.net/ |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 137 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 138 | 2. Enable Custom GWT Checkstyle checks: |
| 139 | |
| 140 | Copy "settings/code-style/gwt-customchecks.jar" into: |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 141 | <eclipse>/plugins/com.atlassw.tools.eclipse.checkstyle_x.x.x/extension-libraries |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 142 | |
| 143 | Restart Eclipse. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 144 | ("gwt-customchecks.jar" is also built from source into build/lib during a full |
| 145 | build) |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 146 | |
| 147 | 3. Import GWT Checks: |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 148 | |
| 149 | Window->Preferences->Checkstyle->New... |
| 150 | Set the Type to "External Configuration File" |
| 151 | Set the Name to "GWT Checks" (important) |
| 152 | Set the location to "settings/code-style/gwt-checkstyle.xml". |
| 153 | Suggested: Check "Protect Checkstyle configuration file". |
| 154 | Click "Ok". |
| 155 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 156 | 4. Import GWT Checks for Tests |
| 157 | |
| 158 | Repeat step 2, except: |
gwt.team.bruce | 6e05b04 | 2007-03-13 17:39:06 +0000 | [diff] [blame] | 159 | Set the Name to "GWT Checks for Tests" (important) |
| 160 | Set the location to "settings/code-style/gwt-checkstyle-tests.xml". |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 161 | |
rjrjr@google.com | 7ad09d4 | 2009-01-22 16:32:30 +0000 | [diff] [blame] | 162 | ------------ GWT dev-jar path ------------ |
| 163 | To run applications against the Eclipse projects for GWT rather than an |
| 164 | extracted jar file, you need to tell GWT where to find its native libraries |
| 165 | since they won't be in the jar file. Using this approach requires building |
| 166 | GWT from the command line with ant once to get the files in the proper |
| 167 | location, but it doesn't need to be redone unless you change any of the native |
| 168 | libraries. |
| 169 | |
| 170 | Window->Preferences->Run/Debug->String Substitution->New... |
| 171 | Set the Name to "gwt_devjar". |
rjrjr@google.com | cb67718 | 2011-09-19 21:21:25 +0000 | [diff] [blame] | 172 | Set the Value to the appropriate path for your install -- for example: |
jat@google.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 173 | <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.com | 7ad09d4 | 2009-01-22 16:32:30 +0000 | [diff] [blame] | 175 | Description can be left blank. |
| 176 | |
| 177 | |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 178 | == Importing the GWT core projects == |
| 179 | |
jat@google.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 180 | 1) Import the 'gwt-dev' and 'gwt-user' projects |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 181 | |
| 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.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 189 | Select 'gwt-dev' |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 190 | 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.com | 8b035a8 | 2008-04-17 15:39:58 +0000 | [diff] [blame] | 193 | - Showcase: complex UI application |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 194 | - DynaTable: uses RPC |
| 195 | Then press the Finish button. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 196 | |
pdr@google.com | 3019d1f | 2010-11-12 12:18:43 +0000 | [diff] [blame] | 197 | 2) 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 | |
| 206 | 3) Dismiss the welcome tab if you are setting up an Eclipse workspace |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 207 | for the first time. |
| 208 | |
scottb@google.com | 5ea03ef | 2008-08-12 21:42:04 +0000 | [diff] [blame] | 209 | You should now have several new projects in your Eclipse workspace. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 210 | 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.com | 3019d1f | 2010-11-12 12:18:43 +0000 | [diff] [blame] | 220 | 4) Finally, drop to the command line and build the project |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 221 | 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.com | e7f61a7 | 2008-12-24 00:45:21 +0000 | [diff] [blame] | 239 | While the 'applicationCreator' script is useful for setting up projects and |
| 240 | launch configurations that target a GWT installation, it is not intended for |
| 241 | GWT developers working against the source code. You will want to run not |
| 242 | against .jar files, but against the class files built by Eclipse. The |
| 243 | following instructions help you do just that. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 244 | |
| 245 | 1) 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.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 252 | 2) Now you should be able to run the 'Hello' project from the |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 253 | Run dialog! |
| 254 | |
| 255 | |
| 256 | == Creating a Launch config for a new project == |
| 257 | |
| 258 | The simplest way to create a new launch config is to use the Run dialog to |
| 259 | duplicate the 'Hello.launch' and 'Hello compile.launch' configurations and |
| 260 | then edit the arguments and classpath settings to match your new project. |
| 261 | |
| 262 | |
| 263 | == Recreating a Launch configuration from scratch == |
| 264 | |
| 265 | This section captures the process used to create the original 'Hello.launch' |
| 266 | |
| 267 | 1) Create or Import a new project |
| 268 | |
jat@google.com | e7f61a7 | 2008-12-24 00:45:21 +0000 | [diff] [blame] | 269 | 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.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 272 | |
| 273 | 2) 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.com | 3019d1f | 2010-11-12 12:18:43 +0000 | [diff] [blame] | 278 | 3) Create a new launch configuration |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 279 | |
| 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 | |
| 292 | Arguments 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.com | 7ad09d4 | 2009-01-22 16:32:30 +0000 | [diff] [blame] | 305 | -Dgwt.devjar=${gwt_devjar} |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 306 | |
| 307 | This is a very obscure way of telling GWT where to find the C++ libraries |
rjrjr@google.com | 7ad09d4 | 2009-01-22 16:32:30 +0000 | [diff] [blame] | 308 | 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.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 311 | |
| 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 | |
| 322 | Classpath: |
| 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.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 327 | gwt-dev/core/super |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 328 | |
| 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. |