In true open source spirit, I scratched my itch. No, not that itch. If you complain about open source projects, you have all the tools at your disposal to fix the problem yourself. Last week, I posted that it’s not straightforward at all to make Spring, Google AppEngine (GAE) and Vaadin work together in Eclipse. This week, I present the solution.
Update: I’ve added a necessary repository to the pom file. So if you had problems previously, please download the file again. Your issues should be solved.
It’s a fairly long Maven pom.xml file, but I believe it remains understandable and usable. Using Maven also makes it easier to integrate your project in continuous build systems and to cooperate on a project with other people. The remainder of this post discusses the details, but you can just go ahead and download the pom.xml right away.
In order to get started you should:
- Adjust the pom.xml to your liking. You probably want to change the artifact and group id’s.
- Run “mvn clean” to create a clean project with the dependencies in the right location.
- Run “mvn eclipse:eclipse” to generate the Eclipse configuration files.
- Import the project into Eclipse (or you can use the m2eclipse Maven integration if you like)
- Start programming your project. With this configuration you will be able to follow the Spring integration tutorial on the Vaadin site (including the annotation driven configuration, which is my favorite).
If you like to know a little more about what the pom.xml does, here are the various issues that are resolved by it.
Google AppEngine
The main issue with Google AppEngine is managing the WAR structure. The Eclipse plugin for GAE cannot directly deploy a .WAR file and it needs a very rigid structure. It takes the contents of the “war” directory and deploys that. The exact directory cannot be changed, neither can the location of the dependencies. So the pom take care of:
- Java classes are compiled to /war/WEB-INF/classes
- JAR dependencies are managed in /war/WEB-INF/lib (“mvn clean” both deletes the old jar files and copies the new ones in the directory)
Eclipse project files
The second large block of code you’ll find in the pom.xml is setting up the Eclipse project files:
- Configuring the various “natures” (those are the different plugins that are enabled for the project)
- Setting up the environment with, for instance, some additional validators and builders.
- For all of this to work, you will need to have all the corresponding Eclipse plugins installed (Vaadin plugin, Spring and AspectJ)
As always, this work would not have been possible without the help of a few people. I stand on the shoulders of giants.
There are still a few to-do’s left:
- Google AppEngine has recently been update from version 1.3.0 to 1.3.1.
- Maven support inside Eclipse is not yet enabled. I think adding the “org.maven.ide.eclipse.maven2Nature” nature to the pom.xml should solve this, but I haven’t tried it out yet.
Good luck and be sure to let me know if you encounter problems or have tips.