Using Vaadin in an existing GWT project

Using Vaadin JAR with Google Eclipse plugin in a GWT project

With GWT development and run-time classes now included in Vaadin, it is easy to move from Google’s build of GWT to Vaadin.

By switching to the GWT integrated in Vaadin 7, you immediately get easier integration of SuperDevMode in your application. Many future GWT bugfixes will be available in Vaadin before they get integrated to the official version and more and more Vaadin widgets ready to use in your application. You risk nothing and can easily switch back to stand-alone GWT if you don’t use features from com.vaadin packages.

You also have the option to easily move to a hybrid application development model integrating business logic on the server with custom components and other parts of your UI implemented using GWT. You can easily combine the productivity and security benefits of a server side framework with the flexibility of client side development where needed.

Using Google Eclipse Plugin

Google Plugin for Eclipse assumes the use of GWT SDK. Nevertheless, the plugin can easily be used to develop client side applications with Vaadin, by following the steps described below.

For lighter deployment, a minimal run-time version of Vaadin JAR will be available in the future.

  1. You need to have the IvyDE plugin for Eclipse installed

  2. Disable some error messages by setting Preferences…​ → Google → Errors/Warnings → Missing SDK → Ignore. Note that you may still get an error message about missing gwt-servlet.jar when modifying project build path.

  3. If you don’t already have a client side application project, you can create one with “New Web Application Project…​”, selecting any recent version of the GWT SDK. If you don’t have any version of GWT installed, download one here - the next steps will switch to using Vaadin JAR.

  4. Open project properties, select Java Build Path → Libraries and remove the GWT SDK from the project class path

  5. In the project properties, make sure the project JRE version in Project Facets is 1.6 or later

  6. Copy the ivy.xml and ivy-settings.xml from an existing Vaadin project created with the Vaadin Plugin for Eclipse

  7. Set the Vaadin version in ivy.xml to your preferred version

  8. Add the following dependency in the ivy.xml: <dependency org="javax.servlet" name="jsp-api" rev="2.0" />

  9. Right-click the ivy.xml and select Add Ivy library…​ and click Finish

  10. Right-click project, select Ivy → Resolve

That’s it - you are now ready to debug the application using GWT development mode server:

  • Debug as…​ → Web Application

To avoid the need to install and update browser plug-ins, use SuperDevMode.

Using Maven

Also the Maven plug-in for GWT makes some assumptions but it is easy to switch to the combined Vaadin JAR.

As the Vaadin JAR now includes GWT, Maven projects should not depend directly on GWT JARs (gwt-user, gwt-dev, gwt-servlet).

To convert an existing Maven project, perform the following modifications in your pom.xml

  • update compiler source and target Java version to 1.6

  • remove dependencies to GWT (com.google.gwt:gwt-user, com.google.gwt:gwt-servlet, com.google.gwt:gwt-dev)

  • add dependencies to Vaadin

XML

  1. <!-- this replaces gwt-user.jar -->
  2. <dependency>
  3. <groupId>com.vaadin</groupId>
  4. <artifactId>vaadin-client</artifactId>
  5. <version>7.0.0.beta9</version>
  6. <scope>provided</scope>
  7. </dependency>
  8. <!-- this replaces gwt-dev.jar -->
  9. <dependency>
  10. <groupId>com.vaadin</groupId>
  11. <artifactId>vaadin-client-compiler</artifactId>
  12. <version>7.0.0.beta9</version>
  13. <scope>provided</scope>
  14. </dependency>
  15. <!-- optional - this replaces gwt-servlet.jar etc. and is deployed on the server -->
  16. <dependency>
  17. <groupId>com.vaadin</groupId>
  18. <artifactId>vaadin-server</artifactId>
  19. <version>7.0.0.beta9</version>
  20. </dependency>
  • if not included e.g. via Jetty/Tomcat/other, add a “provided” dependency to the servlet API

XML

  1. <dependency>
  2. <groupId>javax.servlet</groupId>
  3. <artifactId>servlet-api</artifactId>
  4. <version>2.5</version>
  5. <scope>provided</scope>
  6. </dependency>
  • replace the gwt-maven-plugin with com.vaadin:vaadin-maven-plugin, comment out <dependencies> in its configuration (if exists) and use plug-in version that matches the Vaadin version

  • use goal vaadin:compile instead of gwt:compile etc.

The vaadin-client, vaadin-client-compiler and their dependencies only need to be deployed on the server for debugging with SuperDevMode.