gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 1 | Eclipse 3.3.X instructions |
| 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. |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 70 | |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 71 | == Checkstyle == |
| 72 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 73 | Checkstyle is used to enforce good programming style. |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 74 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 75 | 1. Install Checkstyle |
| 76 | |
| 77 | The Eclipse Checkstyle plugin can be found at: |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 78 | http://eclipse-cs.sourceforge.net/ |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 79 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 80 | 2. Enable Custom GWT Checkstyle checks: |
| 81 | |
| 82 | Copy "settings/code-style/gwt-customchecks.jar" into: |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 83 | <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] | 84 | |
| 85 | Restart Eclipse. |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 86 | ("gwt-customchecks.jar" is also built from source into build/lib during a full |
| 87 | build) |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 88 | |
| 89 | 3. Import GWT Checks: |
gwt.team.jat | 950681a | 2006-12-21 00:13:44 +0000 | [diff] [blame] | 90 | |
| 91 | Window->Preferences->Checkstyle->New... |
| 92 | Set the Type to "External Configuration File" |
| 93 | Set the Name to "GWT Checks" (important) |
| 94 | Set the location to "settings/code-style/gwt-checkstyle.xml". |
| 95 | Suggested: Check "Protect Checkstyle configuration file". |
| 96 | Click "Ok". |
| 97 | |
gwt.team.scottb | 3f1f1a0 | 2007-08-28 19:27:49 +0000 | [diff] [blame] | 98 | 4. Import GWT Checks for Tests |
| 99 | |
| 100 | Repeat step 2, except: |
gwt.team.bruce | 6e05b04 | 2007-03-13 17:39:06 +0000 | [diff] [blame] | 101 | Set the Name to "GWT Checks for Tests" (important) |
| 102 | Set the location to "settings/code-style/gwt-checkstyle-tests.xml". |
gwt.team.scottb | feecde5 | 2007-11-30 19:12:03 +0000 | [diff] [blame] | 103 | |
| 104 | == Importing the GWT core projects == |
| 105 | |
| 106 | 1) Import the 'gwt-dev-<platform>' and 'gwt-user' projects |
| 107 | |
| 108 | File->Import->General->Existing Projects into Workspace->Next |
| 109 | Browse to the 'trunk/eclipse' folder and select it |
| 110 | Deselect All |
| 111 | |
| 112 | Inside this folder are a number of .projects files, only a few of |
| 113 | which you will need to get started. You may import others later. |
| 114 | |
| 115 | Select 'gwt-dev-<platform>' appropriate to your OS |
| 116 | Select 'gwt-user' |
| 117 | Select any of the GWT samples as you want. The most useful ones are: |
| 118 | - Hello: very simple project useful as a little playground |
| 119 | - KitchenSink: complex UI application |
| 120 | - DynaTable: uses RPC |
| 121 | Then press the Finish button. |
| 122 | |
| 123 | Non-windows users: By default, gwt-user depends on gwt-dev-windows, which you |
| 124 | will not have imported. You must update the gwt-user project configuration |
| 125 | to depend on gwt-dev-linux or gwt-dev-mac (whichever one you imported). This |
| 126 | can be done by editing gwt-user's .classpath file directly, or through the IDE |
| 127 | under Project->Properties->Java Build Path->Projects. |
| 128 | |
| 129 | 2) Dismiss the welcome tab if you are setting up an Eclipse workspace |
| 130 | for the first time. |
| 131 | |
| 132 | You should noew have several new projects in your Eclipse workspace. |
| 133 | If you are lucky, they will compile too! |
| 134 | |
| 135 | If they did not compile, recheck the setting of |
| 136 | |
| 137 | - GWT_ROOT |
| 138 | - GWT_TOOLS |
| 139 | - JDK_HOME |
| 140 | |
| 141 | Then refresh each project. |
| 142 | |
| 143 | 3) Finally, drop to the command line and build the project |
| 144 | using 'ant'. You may need to first download ant from the web: |
| 145 | |
| 146 | http://ant.apache.org/ |
| 147 | |
| 148 | Run the ant installation procedure. |
| 149 | |
| 150 | Before you continue, make sure that the 'ant' binary is on your path. |
| 151 | |
| 152 | $ cd <gwt>/trunk/ |
| 153 | $ ant |
| 154 | |
| 155 | This only has to be done once to create the 'trunk/build/staging/...' |
| 156 | directories. After you build from the command line once, you can |
| 157 | use Eclipse's built in compiler. |
| 158 | |
| 159 | |
| 160 | == Launching 'Hello' == |
| 161 | |
| 162 | While the 'projectCreator' and 'applicationCreator' scripts are useful for |
| 163 | setting up projects and launch configurations that target a GWT installation, |
| 164 | they are not intended for GWT developers working against the source code. You |
| 165 | will want to run not against .jar files, but against the class files build by |
| 166 | Eclipse. The following instructions help you do just that. |
| 167 | |
| 168 | 1) Import the 'Hello' project if you haven't already. |
| 169 | |
| 170 | File->Import->General->Existing Projects into Workspace->Next |
| 171 | Browse to the 'trunk/eclipse' folder and select it |
| 172 | Deselect All |
| 173 | Select 'Hello' |
| 174 | |
| 175 | 2) Non-windows users: Replace the gwt-dev-windows project dependency and paths. |
| 176 | |
| 177 | Run->Open Run Dialog...->Java Application->Hello |
| 178 | Select the 'Classpath' tab |
| 179 | Remove gwt-dev-windows paths |
| 180 | Select 'User Entries' |
| 181 | Advanced->Add Folder-> Add gwt-dev-<platform>/core/super |
| 182 | Select the (default classpath) item and use the 'Down' button |
| 183 | to make it the last item in the list. |
| 184 | You could also just edit Hello.launch and search/replace "windows" with |
| 185 | "linux" or "mac". |
| 186 | |
| 187 | 3) Modify the the gwt.devjar VM argument |
| 188 | |
| 189 | Run->Open Run Dialog...->Java Application->Hello |
| 190 | Select the 'Arguments' tab |
| 191 | Modify the 'gwt.devjar' setting in the VM arguments window |
| 192 | |
| 193 | -Dgwt.devjar=<path to trunk>\trunk\build\staging\gwt-<platform>-0.0.0\gwt-dev-<platform>.jar |
| 194 | |
| 195 | 4) Repeat steps 2 and 3 for the 'Hello compile' project. |
| 196 | |
| 197 | 5) Now you should be able to run the 'Hello' project from the |
| 198 | Run dialog! |
| 199 | |
| 200 | |
| 201 | == Creating a Launch config for a new project == |
| 202 | |
| 203 | The simplest way to create a new launch config is to use the Run dialog to |
| 204 | duplicate the 'Hello.launch' and 'Hello compile.launch' configurations and |
| 205 | then edit the arguments and classpath settings to match your new project. |
| 206 | |
| 207 | |
| 208 | == Recreating a Launch configuration from scratch == |
| 209 | |
| 210 | This section captures the process used to create the original 'Hello.launch' |
| 211 | |
| 212 | 1) Create or Import a new project |
| 213 | |
| 214 | Using the 'projectCreator' and 'applicationCreator' scripts is |
| 215 | an easy way to do this, but you cannot use the created launch |
| 216 | scripts to develop the GWT core source because they are |
| 217 | configured to run with .jar files from a GWT installation. |
| 218 | |
| 219 | 2) Add a project reference to the gwt-user project: |
| 220 | |
| 221 | Project->Preferences...->Projects Tab->Add... |
| 222 | Add 'gwt-user' as a project dependency. |
| 223 | |
| 224 | 2) Create a new launch configuration |
| 225 | |
| 226 | Select the project in the tree on the left of the Main Window |
| 227 | Open the Run... dialog |
| 228 | |
| 229 | Create a new Java Application. |
| 230 | |
| 231 | Main Tab: |
| 232 | Name: Debug Launch Config |
| 233 | Project: <your project> |
| 234 | Select the checkbox "Include inherited mains when searching for a main class" |
| 235 | Main class: com.google.gwt.dev.GWTShell |
| 236 | (Note: the 'Search' button may not work, just type it in without a search.) |
| 237 | |
| 238 | Arguments Tab: |
| 239 | In the 'Program arguments' text area, add the name of the module |
| 240 | host web page and any other hosted mode arguments: |
| 241 | |
| 242 | -out www |
| 243 | <your module package>.<module name>/<module name>.html |
| 244 | |
| 245 | e.g. |
| 246 | -out |
| 247 | www com.google.gwt.sample.hello.Hello/Hello.html |
| 248 | |
| 249 | In the 'VM arguments' text area, add the following: |
| 250 | |
| 251 | -Dgwt.devjar="<path to trunk>/build/staging/gwt-<platform>-0.0.0/gwt-dev-<platform>.jar" |
| 252 | |
| 253 | This is a very obscure way of telling GWT where to find the C++ libraries |
| 254 | located in that directory. The name of the .jar file is not important, |
| 255 | but the path is. If you do not have this set, you'll see the |
| 256 | following exception at startup: |
| 257 | |
| 258 | Exception in thread "main" java.lang.ExceptionInInitializerError |
| 259 | Caused by: java.lang.RuntimeException: Installation problem detected, |
| 260 | please reinstall GWT |
| 261 | |
| 262 | |
| 263 | Other VM arguments you might want to add: |
| 264 | -ea (enable assertions) |
| 265 | -server (enable java server VM) |
| 266 | -Xcheck:jni (adds extra checks before passing args to a JNI method) |
| 267 | |
| 268 | Classpath: |
| 269 | Click on 'User Entries' and use the 'Advanced' button to add the following folders: |
| 270 | <project>/src |
| 271 | gwt-user/core/src |
| 272 | gwt-user/core/super |
| 273 | gwt-dev-<platform>/core/super |
| 274 | |
| 275 | Now, select the default classpath (Hello) and move it all the way |
| 276 | to the bottom of the list using the 'Down' button. |
| 277 | |
| 278 | You should now be able to run the application |
| 279 | using the Eclipse launcher. |