Confier mes données à Google ? Jamais !
par salvador le Apr.10, 2010, sous GAE, GWT, Google
Ce post est écrit sur Google Wave et inséré ici et sur InsideIT.fr le blog de mon employeur.
Exporter un Wave de cette façon est très simple et documenté à plusieurs endroits, merci à Olivier Croisier pour son post qui explique comment exporter une Wave non pas depuis la sandbox mais depuis le serveur “grand public”.
Keep your source tree clean ! Maven workarounds for GWT 1.6
par salvador le Apr.29, 2009, sous GWT, maven
In this series of posts I’ll analyze the current conflicts between the new Google Eclipse Plugin (also know as GEP), maven and the gwt-maven-plugin. Once these conflicts are identified, I’ll try to find workarounds and advice on what possible perennial solutions could be implemented by each team. This first post is directed at the impatient crowd, the ones looking for a copy-paste solution (you do know that’s bad practice, don’t you ?) so I’ll be as brief as I can and give as little detail as I can to get you started using GWT with Eclipse, the Google Eclipse Plugin and the gwt-maven-plugin. For those of you who don’t mind reading long posts and want to understand exactly what’s keeping these 4 tools from working together and how I came up with the workarounds explained here, check back soon(ish), the following posts will be a lot more detailed.
Introduction
The Google Web Toolkit team announced the release of GWT 1.6.4 a couple of weeks ago (for those keeping track, that’s roughly 6 months after the 1.5.3 release and 13 months after the 1.4 release). I’m not going to describe here at length the improvements brought by this new version, you can read all about it in the release notes and the new and improved developer documentation. Instead I’m going to focus on one of the changes that has caused a great deal of frustration to us GWT developers relying on maven to automate the build process: the new war project structure.
So what’s the problem with the new project structure ? If you use GWT for a personal project and you’re the only person modifying your source you should be fine because it’s relatively trivial to keep your source files separated from generated files. The problem really arises when your project is shared between a whole team (typically on a version control system): in that case you’ll really want to keep your original source and resources files separated from generated files and that’s precisely the problem with the new GWT project structure, it assumes that server-side library dependencies must be copied into /war/WEB-INF/lib and that the java compiler outputs to /war/WEB-INF/classes (thus polluting the war folder).
The solution
How do you configure Eclipse, maven and the gwt-maven-plugin to work with GWT 1.6.4 then ? I’ll start from scratch with the archetype from the gwt-maven-plugin-1.1-SNAPSHOT and I’ll guide you step by step in the pom and eclipse configuration. In the end, you’ll be able to develop your GWT application with Eclipse, taking advantage of the hosted mode for debugging, you’ll have a clean source tree, and you’ll be able to package your application as a war. Unfortunately, I still haven’t found a way to launch as a Google Web Application (the custom launcher provided by the GEP) and the warnings about unavailable classes in client-side code don’t seem to be working, effectively making the GEP almost useless. Fortunately the hosted mode will warn you about unavailable client-side classes and we don’t need the GEP to launch the hosted mode so pretty much all of the GEP functionality is there, only without the GEP.
So without further ado, here’s what you need to run and develop GWT applications with Eclipse, maven and the Google Eclipse Plugin (ok that last one doesn’t do anything useful yet in this configuration, but at least it can be activated).
Prerequisites
- A working maven 2.1.0 installation (I’ve used 2.1.0 to write this guide but I’ve tested in 2.0.9 and it works, and it should work on any 2.x version, let me know in the comments if you tried any other version)
- Eclipse 3.4 JavaEE edition (again, drop me a comment if you succeed with another Eclipse version/edition)
- A working installation of the Google Eclipse Plugin.
- The glue that holds the pieces together: the m2eclipse plugin (Maven Integration for Eclipse)
Project creation with gwt-maven-plugin
- To create a GWT project with the gwt-maven-plugin, just open a command line, change the working directory to the location where you want to create your project (typically the location of your eclipse workspace) and type the following command. You’ll end up with a folder called “maven-example”
- Fire up Eclipse and import the project we just created (“File” > “Import” > “Maven projects” > “Browse” and browse to the “maven-example” folder and click “Finish”).
You’ll end up with a project which looks like this in your workspace.
POM configuration (maven build configuration)
GWT module tweak
- Add a rename-to attribute to the GWT module declaration file.
- Change the Application.html file to look like this. Move that file to the
src/main/webappfolder. - Delete the file named
index.htmllocated in thesrc/main/webappfolder. - Open the
web.xmlfile located insrc/main/webapp/WEB-INFand change the value of thewelcome-filetoApplication.html.
m2eclipse plugin configuration
- Global configuration (“Window > Preferences > Maven” or “Command+,”): no goals should be executed neither on project import nor when updating project configuration.
- Project-level configuration (Right click on project > Properties > Maven):
clean compilegoals on project clean andon resources changecompileon resources change.
Eclipse project configuration
- Check the “Allow output folders for source folders” option in the “Java Build Path” panel under the “Project Properties” dialog.
Change output folders forUpdating project configuration in m2eclipse context menu option should do it automatically.src/main/java,src/main/resourcesand “Default output folder” tomaven-example/target/gwt/WEB-INF/classes.- Create a launcher for hosted mode debugging (Open the “Debug configurations” dialog in the “Run” menu): click the links for screenshots of the “Main” tab, the “Arguments” tab, the “Classpath” tab and the steps to add folders and external jars to the classpath (note that the gwt-dev jar name depends on your OS).
The results
The end result is a working GWT project with the following characteristics:
- Can be developed (code – debug – compile) entirely in Eclipse (hosted mode works fine for compiling and debugging) just like with the GEP.
- Can be packaged automatically by maven (type
mvn packageto get a war in the target directory). - The source tree is completely separated from generated artifacts, allowing for an easiest experience for developers working with VCSs.
- Follows maven conventions (and everybody knows that conventions are good).
What you don’t get:
- Google App Engine application development (outside the scope of this guide).
- Warnings about unavailable classes in client-side GWT code (You’ll get them on the hosted mode console though).
- Right-click > Run as Google Web Application (Google’s fancy launchers don’t seem to like the separation between sources and resources so they won’t launch our application)
I think it’s a pretty good compromise if you’re looking forward to use GWT 1.6 in a maven environment, pretty much all of the functionality of GEP is there AND you are following the maven way. There are a few strange behaviors in some corner cases, so come back later for the follow-up to this post where I’ll explain in detail how I found this workarounds, how these tools work together and how to troubleshoot any problems that you’ll be kind enough to report in the comments.
Edit 1 (03/may/2009):
Thanks to Eugene Kuleshov for his contribution (see first comment). The Eclipse buildpath configuration is now automatically handled by m2eclipse.
If you tried this tutorial before this edit, you should have spotted a bug in m2eclipse that stopped the copy-resources goal from the maven-resources-plugin from working. Try the latest version of the pom and make sure the project level configuration for m2eclipse is correct (check the screenshot).
Update 2 (october 5th 2009):
I haven’t had the time to fully update this tutorial, but from what I can read in the comments, this should also work with GWT 1.7 (do read the comments if you’re attempting to get it working).
Update 3 (october 23th 2009):
As the last commenters noted, all the screenshots are dead, I thought it’d be more reliable to store them on bayimg.com than in my own server but they proved me wrong. I’ll try to reupload them this weekend but in the meantime you can download a zip with all the screenshots by clicking here.




