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 |
| 23 | (for example, C:\Program Files\jdk1.5.0_05 or /usr/lib/j2sdk1.5-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 |
| 74 | Set the compiler compliance level to 1.5. |
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 | |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 104 | == Checkstyle == |
| 105 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 106 | Checkstyle is used to enforce good programming style. |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 107 | |
rjrjr@google.com | f73c78e | 2009-07-10 16:14:42 +0000 | [diff] [blame] | 108 | 1. Install Checkstyle version 4.4.2 (newer versions will not work) |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 109 | |
| 110 | The Eclipse Checkstyle plugin can be found at: |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 111 | http://eclipse-cs.sourceforge.net/ |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 112 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 113 | 2. Enable Custom GWT Checkstyle checks: |
| 114 | |
| 115 | Copy "settings/code-style/gwt-customchecks.jar" into: |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 116 | <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] | 117 | |
| 118 | Restart Eclipse. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 119 | ("gwt-customchecks.jar" is also built from source into build/lib during a full |
| 120 | build) |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 121 | |
| 122 | 3. Import GWT Checks: |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 123 | |
| 124 | Window->Preferences->Checkstyle->New... |
| 125 | Set the Type to "External Configuration File" |
| 126 | Set the Name to "GWT Checks" (important) |
| 127 | Set the location to "settings/code-style/gwt-checkstyle.xml". |
| 128 | Suggested: Check "Protect Checkstyle configuration file". |
| 129 | Click "Ok". |
| 130 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 131 | 4. Import GWT Checks for Tests |
| 132 | |
| 133 | Repeat step 2, except: |
gwt.team.bruce | 6e05b04 | 2007-03-13 17:39:06 +0000 | [diff] [blame] | 134 | Set the Name to "GWT Checks for Tests" (important) |
| 135 | Set the location to "settings/code-style/gwt-checkstyle-tests.xml". |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 136 | |
rjrjr@google.com | 7ad09d4 | 2009-01-22 16:32:30 +0000 | [diff] [blame] | 137 | ------------ GWT dev-jar path ------------ |
| 138 | To run applications against the Eclipse projects for GWT rather than an |
| 139 | extracted jar file, you need to tell GWT where to find its native libraries |
| 140 | since they won't be in the jar file. Using this approach requires building |
| 141 | GWT from the command line with ant once to get the files in the proper |
| 142 | location, but it doesn't need to be redone unless you change any of the native |
| 143 | libraries. |
| 144 | |
| 145 | Window->Preferences->Run/Debug->String Substitution->New... |
| 146 | Set the Name to "gwt_devjar". |
| 147 | Set the Value to the approprate path for your install -- for example: |
jat@google.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 148 | <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.com | 7ad09d4 | 2009-01-22 16:32:30 +0000 | [diff] [blame] | 150 | Description can be left blank. |
| 151 | |
| 152 | |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 153 | == Importing the GWT core projects == |
| 154 | |
jat@google.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 155 | 1) Import the 'gwt-dev' and 'gwt-user' projects |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 156 | |
| 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.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 164 | Select 'gwt-dev' |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 165 | 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.com | 8b035a8 | 2008-04-17 15:39:58 +0000 | [diff] [blame] | 168 | - Showcase: complex UI application |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 169 | - DynaTable: uses RPC |
| 170 | Then press the Finish button. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 171 | |
| 172 | 2) Dismiss the welcome tab if you are setting up an Eclipse workspace |
| 173 | for the first time. |
| 174 | |
scottb@google.com | 5ea03ef | 2008-08-12 21:42:04 +0000 | [diff] [blame] | 175 | You should now have several new projects in your Eclipse workspace. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 176 | 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 | |
| 186 | 3) 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.com | e7f61a7 | 2008-12-24 00:45:21 +0000 | [diff] [blame] | 205 | While the 'applicationCreator' script is useful for setting up projects and |
| 206 | launch configurations that target a GWT installation, it is not intended for |
| 207 | GWT developers working against the source code. You will want to run not |
| 208 | against .jar files, but against the class files built by Eclipse. The |
| 209 | following instructions help you do just that. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 210 | |
| 211 | 1) 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.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 218 | 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] | 219 | Run dialog! |
| 220 | |
| 221 | |
| 222 | == Creating a Launch config for a new project == |
| 223 | |
| 224 | The simplest way to create a new launch config is to use the Run dialog to |
| 225 | duplicate the 'Hello.launch' and 'Hello compile.launch' configurations and |
| 226 | then edit the arguments and classpath settings to match your new project. |
| 227 | |
| 228 | |
| 229 | == Recreating a Launch configuration from scratch == |
| 230 | |
| 231 | This section captures the process used to create the original 'Hello.launch' |
| 232 | |
| 233 | 1) Create or Import a new project |
| 234 | |
jat@google.com | e7f61a7 | 2008-12-24 00:45:21 +0000 | [diff] [blame] | 235 | 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.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 238 | |
| 239 | 2) 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 | |
| 244 | 2) 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 | |
| 258 | Arguments 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.com | 7ad09d4 | 2009-01-22 16:32:30 +0000 | [diff] [blame] | 271 | -Dgwt.devjar=${gwt_devjar} |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 272 | |
| 273 | 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] | 274 | 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.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 277 | |
| 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 | |
| 288 | Classpath: |
| 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.com | 4e26cc6 | 2009-09-21 19:02:09 +0000 | [diff] [blame] | 293 | gwt-dev/core/super |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 294 | |
| 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. |