Widgetset hell

Well, i don’t know if other developers share my impression that compiling a widgetset is a cumbersome operation, but for me it’s being a pain to make it to work in an existing application.
I was unable to compile a widgetset in a existing project, even if i copy all settings from “pom.xml” and “web.xml” line by line from a brand new vaadin archetype application.
I’m pretty sure my settings are right, but i’m getting an error when the widgetset is being compiled (java.lang.NoSuchFieldError: reportUnusedDeclaredThrownExceptionIncludeDocCommentReference).
Even if i could make it work, i don´t want to wait 10-15 minutes every time i need to package my project, waiting for its widgetset to be compiled again and again.
Neither i want to add 25MB+ to my war file because i had to add some add-on.
So, i came to a solution that fitted very well for me, so i will share it here, as it can help other unhappy developers also.
In my scenario, all my applications usually share the same widgetset, basically with vaadin default widgetset, vaadin-charts and some other add-ons.
So, what i did was to compile this commom widgetset in a brand new vaadin archetype application, and then copy the compiled widgetset folders to a simple “jar packaged” project, and use this project as a dependency to all projects that need to share this widgetset.
In my case, the size of my widgetset jar with default vaadin widgetset + vaadin-charts got just 3MB.

PROJECT 1 (WIDGETSET COMPILATION)

  • Create a new maven project using the archetype “vaadin-archetype-application”
    • Change (if needed) and take note of the package where the file “AppWidgetSet.gwt.xml” is placed (ex: “foo.AppWidgetSet.gwt.xml”)
  • Add your add-ons as dependencies in “pom.xml”
  • Run “mvn package”
    • After a long time your widgetset will be compiled at “src/main/webapp/VAADIN”

PROJECT 2 (WIDGETSET JAR)

  • Create a new simple maven project

  • Copy the folder “src/main/webapp/VAADIN/widgetsets” from project 1 to the folder “src/main/resources/VAADIN/widgetsets” in this project

    • PS: It seems the folder “VAADIN/WEB-INF” is not required, and can be removed to reduce the size of the generated jar file
  • Run “mvn package” or “mnv install”

  • Use this project as a dependency for other projects that should use this widgetset

  • In the projects that should use this widgetset, include the jar project as a dependenct and add a param named “widgetset” to your “web.xml” this way:


    ...
	<servlet>
		<servlet-name>App</servlet-name>
		<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
		<init-param>
			<param-name>UI</param-name>
			<param-value>foo.MyVaadinUI</param-value>
		</init-param>
		<init-param>
			<description>Application widgetset</description>
			<param-name>widgetset</param-name>
			<param-value>foo.AppWidgetSet</param-value>
		</init-param>
	</servlet>
    ...

Hope it helps someone.

Regards,

Fabiano [b]

[/b][b]

[/b][b]

[/b][b]

[/b]

The error is almost certainly caused by having multiple different versions of the client compiler JAR (or GWT JARs if using Vaadin 6.x) on the classpath.

For Vaadin 7, vaadin-maven-plugin adds a version of vaadin-client-compiler on the classpath with a version matching the version of the plugin, so make sure you are using the same version of Vaadin and the plugin. Similar but not quite the same issues apply to GWT JARs when using Vaadin 6.x. This extra dependency issue has been addressed in the latest trunk of the plugin, but not yet released (see
#11520
).

I would like to refactor the application archetype into a multimodule project with a separate widgetset module that does nothing but collect dependencies and build the widgetset. That would eliminate extra widgetset recompilations in normal development almost entirely.

Without the refactoring of the archetype or your project, another alternative is to move the Vaadin plugin under and execute it by hand when necessary (new addons/…).