Using java script libraries like jquery in vaadin add-ons fast leat to version conflicts, since every add-on has to ship its on version of jquery.
This is a proof of concept to solve this conflicts. The idea is to use webjars as dependencies, reference them in the add-ons and let maven solve the versions for you.
Based on the virtin webjars branch from Matti Tahvonen, some talk at the vaadin meetup in Hamburg and ideas from the vaadin forum the following things have been done:
Pack the java script like a webjar, but without version information in the path to the *.js file- Add a dependency to the
vwebjarwebjar in the addon - Use this in a Vaadin @JavaScript annotation, but with the
app://webjarsprotocol and prefix - Serve the javascirpt with a thin servlet registered to the
webjarspath
jquery- the packed jquery version - the pom.xml is copyed from the webjars project, and modified so there is no version information in the filenamesticky- a patched version of the Sticky Vaadin add-on using thepacked jquery librarywebjars jquery libraryvwebjars-servlet- the servlet serving the packed java script resources,this is a dependency to the java script packages
Run mvn install in the parent module, and then mvn jetty:run in the sticky/sticky-demo sub module.
- Add the needed webjar as a dependency to your add-on
- Use the
@JavaScriptannotation in your addon. The script name must beapp://webjars/scriptFileNameorapp://webjars/webjarName/scriptFileName. - Use the
vwebjars-servletin your procejt to serve the webjars
Is there a way to use the original webjar *.jar, so the repacking effort is not needed?