Vaadin 14 maven multi module project configuration

Hello.

I had success making one module root project working with no problem (mostly).

Now i can not figure it out , how to configure multi-module project with vaadin 14 and npm.

Structure :

  1. root
    2) BL (jpa, ws, etc,…) → jar
    3) DATA (entity, pojos,…) → jar
    4) CLIENT (client for app ws) → jar
    5) UI (vaadin 14 ui, npm, frontend,…) → war (including jar from 2 and 3)

I have frontend folder in root project which should be OK. But then i got problem with npm and node_modules.

Now my questions:

  1. Wherte to put package.json ?
  2. In which pom.xml do i need prepare-frontend, production profile etc ,… ?

Thanks for answers.

Hi,

here you have an example of a multi module maven project: https://github.com/TatuLund/bookstore-flow-ee?files=1

In short, everything related to vaadin ( package, frontend, prepare frontend, npm) should be in the ui module.

This is exactly what i was looking for.

Thank you very much. It is working now.

Time to migrate project to v14. :slight_smile:

In case of several UI моdules (several application) in multi module Vaadin project, is there a possibility to share node_modules and package*.json?

JavaOPs Empty:
In case of several UI моdules (several application) in multi module Vaadin project, is there a possibility to share node_modules and package*.json?

I’m not sure if I understand the question, but if you have multiple modules and run only 1 application (with jetty or spring-boot… ), you should have only 1 package*.json and mode_modules.
If you run multiple applications, then the node_modules + package*.json should be different.

Hello Jean-Christophe!
I’ve multiple applications. And a lot of duplication in every node_modules.
I’ve try pnpm (https://vaadin.com/docs/v14/flow/advanced/tutorial-switch-npm-pnpm.html, use 14.4.5 version), but node_modules still created for every application. I’ve used NTFS links as workaround, but I hope should be a solution for sharing this multiple node_modules.

There is an explanation why pnpm is using pnpm hardlinks:
https://pnpm.js.org/en/faq

I didn’t go too deep into the explanation but it has been done on purpose.

Hello! As I understand, for Windows my workaround (NTFS links to node_modules) is the best solution.

Has anyone tried this with different UIs (apps)? If so I would love to hear how you got it to work.