Question

Using the Google-Eclipse plugin, I have successfully created, built and deployed (locally) a very basic GWT Web Application.

The thing is: I'm not a huge fan of the project structure GWT (or the Google-Eclipse plugin) set up by default. So I'm trying to set things up in a way that makes logical sense for me, but that still is able to run in DevMode and deploy locally.

So I created a 2nd project but did not set it up as a Web Application; instead I used a normal Java Application. I created my source directories, my EntryPoint implementation (TestModule implements EntryPoint), my TestModule.gwt.xml, my host page HTML, etc. All the artifacts that I did in the first (successful) project.

But now I am in Run Configurations trying to manually set up a run config similar to how the Web Application Wizard created one for me with the first app I built.

In the Run Configurations >> GWT tab it gives me a window where I can add Available Modules. When I click the "Add" button, no matter what I type, it doesn't provide me with an available list of options to choose from.

So I exited out of the Run Configurations dialog, assuming that I need to set up my project properties differently. So I right-clicked my project, went to Properties >> Goodle >> Web Toolkit, and sure enough, see a similar panel that allows me to add Available Modules. It is my belief that if I configure this section correctly, then a list of Available Modules will become available to me when inside the Run Configurations dialog, and I should be able to continue.

Here's what I'm seeing:

enter image description here

Any ideas as to how I can configure my project correctly so that this Available Modules dialog actually presents me with options? Thanks in advance!

Please note: I anticipate many answers to be along the lines of "just use the Web Application wizard, it's so much easier", etc. I understand this and am (temporarily) accepting the caveats of trying to configure my own GWT app without the help of the plugin's Web Application wizard. If I find it to be really, really difficult to "roll my own" here, then I'll cave in and go back to the wizard. But I want to give this my best shot before doing so!

Was it helpful?

Solution

Feel free not to use the Google Plugin for Eclipse (hereafter GPE)! There is no need - its all Java, or at least self contained enough to act like Java as far as Eclipse can tell. If you don't want the wizards, the JSNI autocomplete, UiBinder autocomplete, by all means, you can even leave the plugin out.

To run a GWT project in dev mode, you just need the basic moving parts of the SDK: * gwt-dev.jar - Dev mode (code server and simply HTTP server), the compiler, and assorted other tools * gwt-user.jar - GWT language runtime (JavaScriptObject, GWT, etc) and standard events, widgets, and other bits * optional: gwt-servlet.jar - classes to run in a servlet container for some basic GWT servlets * optional: requestfactory-*.jar - if you don't use RequestFactory, don't worry about it

You may also need a json.jar and the valdation-api.jar as well as its sources.

This gives you enough to have any project compile in plain Java. The gwt-user.jar and gwt-dev.jar do not belong in your server classpath - don't put them in a WEB-INF/lib/ dir, just keep them on hand to compile your code to JavaScript.

Both Dev Mode and the compiler itself are just classes with a main method, so a standard Eclipse Run/Debug Configuration can start either. Each will have its own options to get going, such as 'where do i find your sources', 'what module are you starting', and in the case of Dev Mode, 'where is the war/ dir for me to serve'.

Avoid GPE entirely:

DevMode:

Make a new Java Run Configuration, and verify that the above classes are on the classpath, as well as your source directories. Set the main class to com.google.gwt.dev.DevMode, add a few params:

-war path/to/war/dir/ my.package.to.ModuleToRun

Everything else is just extra flags to change out it works, and hints for where to start. Take a look at https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#What_options_can_be_passed_to_development_mode for other options available to you

To debug this, run it as a Debug Configuration - Eclipse will complain a bit about how it can't hot swap classes, but ignore these and hit continue. When you make a change in a .java file, save, and refresh the browser - GWT's specialized Dev Mode classloader will pick up the changes.

Compiling:

As above, make a run config with the important classes and jars on the classpath. This time, use the com.google.gwt.dev.Compiler main class, and specify the module(s) to build under the program arguments. Again, there are many options at your disposal to change how it compiles and what additional output it provides, see https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#DevGuideCompilerOptions for more options

Using GPE without the wizards:

The important thing to remember here is that GPE is just papering over a few details - you don't need to use the wizards, but at some level, its all wizards until you are just working in raw Java. Classpath, imports, etc - these are all Java concepts that more or less apply to GWT development, though it adds Modules to help set up deferred binding rules, etc.

The module selection dialog is not necessary, though two other pieces are. First, as you've done, under Google > Web Toolkit turn on "Use Google Web Toolkit", and ensure a valid SDK is selected. This does two things - it adds the necessary jars to the classpath (under 'GWT SDK'), and enables a few other options throughout the project - JSNI autocomplete, Dev Mode, assorted wizards (that we'll ignore). The other piece that is necessary is to go to Google > Web Application, indicate that "This project has a WAR directory", and give it the path to that directory so Dev Mode knows where to start Jetty.

Once this is done, the plugin should be able to let you start from an html file that points at a module with an entrypoint. I'm going to gloss over these details, as this is basic project setup - things that the wizards are good at, examples are full of, and you presumably have read these directions (else you wouldn't be skipping wizards...). From within the previously selected WAR folder, pick such an html file, right click it and select Run As... > Web Application. It is possible that GPE will ask once again for the WAR folder - help it out, and you'll be on your way. Dev Mode will add a View to eclipse rather than a standalone window, and you'll be able to monitor progress from there.

Compiling is then a matter of going to the G icon in your toolbar and selecting "GWT Compile Project...". A dialog will appear asking for the project to use, and the entrypoint(s) to start with, as well as a few other options. Note that if you compile into the war folder then start Dev Mode, you may find that Dev Mode overwrites part of your compiled output for easier Java debugging, thus requiring an additional compile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top