Vaadin 7 IVY to Vaadin 8 Maven - how to include WEB-INF/lib JARs?

There’s a lot to change/deal with when migrating from Vaadin 7 to 8.7.1, and in the process, I am trying to switch from IVY to Maven in Eclipse. To do this, I created a new Vaadin 8 project (using vaadin-archetype-application).

This gives me a path like src/main/java, where I copied all my prior Java code over to.

It also created the path src/main/webapp. I put all of my HTML/JSP and such there (we have a few JSP documents that are accessed before going into the Vaadin app after login). Previously, this also included the WEB-INF/lib folder that has a bunch of JARs we didn’t previously fetch with Ivy (and don’t expect to pull them from elsewhere for Maven as I wouldn’t know how to find them there?!), such our BouncyCastle JARs, some Apache Commons, pdfbox/fontbox/jempbox, log4j, poi, postgresql driver and some Vaadin add-ons (confirmdialog-3.2.0, dndscroll-2.0.2, dragdroplayouts-1.4.2, popupbutton-3.0.0, resetbutton-vaadin8-1.0).

I am guessing that the Vaadin add-ons can be fetched by Maven instead of being in my WEB-INF/lib. But the others will likely need to be in WEB-INF/lib, used by my Eclipse for compiling, and then deployed when running Tomcat inside Eclipse.

What do people do for such WEB-INF/lib JARs?

Fetching dependencies automatically based on the dependency descriptions in your pom.xml is one of the main jobs of Maven. I think all of the libraries you mentioned (BouncyCastle, Apache Commons, POI, etc) can be found from Maven Central; you can use e.g. https://search.maven.org/ to find them. Put <dependency> configurations with the libraries’ information (group, artifact id, version) inside the <dependencies> block of your pom.xml and let Maven take care of them. Usually libraries’ web pages include Maven dependency strings too, like here: http://commons.apache.org/proper/commons-net/dependency-info.html .

Vaadin add-ons’ Maven dependencies can be found from the Directory, for example https://vaadin.com/directory/component/dndscroll-add-on - just get the <dependency> block from the right-hand side. Note that you’ll need the vaadin-addons repository in your pom.xml:

   <id>vaadin-addons</id>
   <url>http://maven.vaadin.com/vaadin-addons</url>
</repository>

If you have self-made libraries that can’t be found from the internet, the most straightforward option would be to mavenize them too, so you can install them either locally (run mvn clean install and they will be installed to your local .m2 directory) and/or to your own internal repository (like Artifactory). Then you can use them in your <dependencies> block just like libraries found from external repositories. Using an internal repository is also a good option if you’re especially security-conscious; then you can put exactly the versions you need in your internal repo and download nothing from the internet unless explicitly cleared to do so.

One option for dependencies is to place them on the server. This is sometimes done for things like database drivers, so that the the driver matches the database in each environment. You might still need a dependency for development time if it’s needed for compilation.

You can also install .jar files to your local repository manually; this StackOverflow post shows how: https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project . This is probably the least convenient option, as you’ll need to repeat the process for every .jar for every machine.

Thanks for the details. That is very helpful. I’ll see what it means to maven-ize what I can!

What goes into src/main/resources and how would I access them/use them in code?

Usually some static files; javascript files, non-theme images, configuration files or static downloadables. You can access them with getClass().

My original V7 project has a widgetset XML file. I changed to use instead, but after the widgetset compilation, it adds the DefaultWidgetSet inherits element back to the XML file. Is that a problem with a resolution?

Hi David did you manage to pull this out. I also trying to migrate from ivy to maven while migrating from 7 to 8.

What is your maven project folder structure at the end. I had in the old project
src
Web app libraries
WebContent
META-INF
VAADIN
WEB-INF

Where did you copy the VAADIN and WEB INF folder?
Did you have any problems running mvn vaadin:upgrade8 command, i got errors. I am adding plugin dependencies in pom.xml but vaadin upgrade plugin is the problem now.

Thanks

I don’t recall all the details, but I do know it was painful, much more work and expense than going from 6 to 7.

I don’t recall us using mvn vaadin:upgrade8, so perhaps it gave us issues too.

Under ‘src/main’ we have:

‘java’ for our java source code (with our ‘com’ and ‘org’ code under it)

‘resources’ with our .properties files and log4j2.xml,

‘webapps’ with our JSPs, error pages, static CSS/JS files used by our JSPs. It also has the VAADIN folder, but that only contains our ‘themes’ folder (which has our icons, images and CSS). It has the WEB-INF folder, but we don’t have a ‘lib’ folder under it. All of the JARs are specified in the pom.xml.

Thanks David