Sharing code between Vaadin Applications


When working on several applications, it is often handy to share code between them, for example an addressbook custom component. Suppose I am continuously improving my addressbook component in the project “helpertools”.

Eclipse allows in principle to link source code from another project, through “Properties” → “Java Build Path” → “Projects”. However, when I set this up and use classes from “helpertools” in a new vaadin application, the servlet runs into a ClassNotFoundException, while in Eclipse’s project view the class is properly imported and recognized. Linking in the “helpertools” by a symlink also does not work, I have found a bug report on Eclipse on this that is still open. Hardlinking the resource prevents my tomcat from starting up.

What is the best practice to share code between vaadin applications for continous co-development, i.e., without exporting something like “helpertools” into .jar and reimporting it after code updates?

In eclipse you can do Preferences → Deployment Assembly and add your helper tools project to the deployment classpath. This will automatically copy the resources to your deployment destination. Be sure to have the item targetted to WEB-INF/lib.

For production use it’s necessary to build and package the helper tools as a jar and have it deployed together with your webapp.