Vaadin and Maven best practices

I despise the fact that by default the maven archetype sets up the project such that the GWT generated javascript gets pushed into src/main/webapp/VAADIN.

To me this is quite ugly. Maybe I’m a bit OCD but placing generated sources inside of the ‘normal’ source directory just seems like a hack. Good enough to work but not a good long term solution.

I’ve done a bit of googling but I’m not coming up with a good solution in general.

The standard maven way would be to generate these files into target/generated-sources/webapp/VAADIN

However since this step takes a long time I can see why src/main is used as a hack.

For my project I’m considering doing the following:

  1. Creating a separate maven submodule that will contain the generated sources (probably the best)
  2. Creating a new top-level directory in my web module named ‘generated’ (ugly but better)
  3. ??? (hopefully some clever solution somebody will point me to I’m not aware of)

So what are those who care about this sort of thing doing in regards to making maven and Vaadin work happily together?

My two cents on this:

Whether or not using generated-sources, I would strongly argue that using a separate module for the compiled widgetset is the way to go and saves a lot of time as well as it only needs to be compiled when Vaadin framework version or client side widget versions change.

This should ideally be separate from other modules containing client side code (which do not need direct widgetset compilation as their widgetsets will be included in the main application widgetset, or only need it for running tests but not for deployment). Each client side widget or logical set of widgets should ideally be its own module, a Vaadin add-on of its own, even when specific to the application.

I can’t really say off the bat whether simply moving generated files to generated-sources causes problems related e.g. to the order of lifecycle phases, but even if it does, those should be easy to manage if the widgetset is a separate module.

The widgetset module file (.gwt.xml) should probably be in the widgetset module under resources/main/com/mypackage/…/MyWidgetset.gwt.xml where the package path matters if there are client side source files under that package (in a “client” subpackage). This could be argued both ways, though.

Ideally, the compiled widgetset should not be in the sources tree at all but under webapp just like you suggested. I have the recollection, though, that at least sometime in the past there wasn’t anything like generated-sources/webapp that the WAR and application server plugins would have used consistently. Instead, they only accessed webapp/main directly, and generated-sources was only used for source files. Some server plugins and the WAR plugin could be configured by hand to use (only) an alternate directory, but there was no generic way to do that. Maybe I am wrong, though - I would prefer to have been wrong here. Can you confirm whether the WAR, Tomcat, Jetty etc. plugins actually use generated-sources/webapp?