Maven Multi-module production build

Hi Vaadin community,

When I’m packaging my Maven multi-module Hilla app as a production build, the theme is missing in the final fat-jar.

Expected result (running ./mvnw spring-boot:run):
image

Actual result (./mvnw clean package -Pproduction && java -jar application/target/application-0.0.1.jar):
image

Notes:
I noticed that the final fat-jar does not contain any Vaadin meta-files/resources:

❯ unzip -l application/target/application-0.0.1.jar| grep 'META-INF'
        0  11-05-2024 07:59   META-INF/
      459  11-05-2024 07:59   META-INF/MANIFEST.MF
        0  02-01-1980 00:00   META-INF/services/
       66  02-01-1980 00:00   META-INF/services/java.nio.file.spi.FileSystemProvider
        0  11-05-2024 07:59   META-INF/maven/
        0  11-05-2024 07:59   META-INF/maven/com.thowimmer/
        0  11-05-2024 07:59   META-INF/maven/com.thowimmer/application/
     1688  11-05-2024 07:09   META-INF/maven/com.thowimmer/application/pom.xml
       59  11-05-2024 07:59   META-INF/maven/com.thowimmer/application/pom.properties

wheres the jar of my module containing frontend folder does contain some Vaadin specific meta-files/resource:

❯ unzip -l views/target/views-0.0.1.jar | grep 'META-INF'         
        0  11-05-2024 07:59   META-INF/
      141  11-05-2024 07:59   META-INF/MANIFEST.MF
        0  11-05-2024 07:59   META-INF/VAADIN/
        0  11-05-2024 07:59   META-INF/VAADIN/config/
        0  11-05-2024 07:59   META-INF/VAADIN/webapp/
        0  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/
        0  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/
        0  11-05-2024 07:59   META-INF/maven/
        0  11-05-2024 07:59   META-INF/maven/com.thowimmer/
        0  11-05-2024 07:59   META-INF/maven/com.thowimmer/views/
   409050  11-05-2024 07:59   META-INF/VAADIN/config/bundle-size.html
      180  11-05-2024 07:59   META-INF/VAADIN/config/flow-build-info.json
     3089  11-05-2024 07:59   META-INF/VAADIN/config/stats.json
      586  11-05-2024 07:59   META-INF/VAADIN/webapp/index.html
    40894  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/FlowClient-CFpeFTrH.js.br
    39940  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/generated-flow-imports-Ba018pJ8.js
     1282  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/FlowBootstrap-BRNFttkU.js.br
   142183  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/FlowClient-CFpeFTrH.js
   394185  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-UV-vEubm.js
     9603  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/generated-flow-imports-Ba018pJ8.js.br
   106435  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-UV-vEubm.js.br
     3739  11-05-2024 07:59   META-INF/VAADIN/webapp/VAADIN/build/FlowBootstrap-BRNFttkU.js
      271  11-05-2024 07:59   META-INF/VAADIN/webapp/index.html.br
       91  11-05-2024 07:59   META-INF/VAADIN/file-routes.json
     2747  11-05-2024 07:09   META-INF/maven/com.thowimmer/views/pom.xml
       53  11-05-2024 07:59   META-INF/maven/com.thowimmer/views/pom.properties

Resources:

I’d be glad if you can point me to the missing piece :sweat_smile:

Thanks!

Try moving the theme from views/src/main/frontend/themes/example-theme to views/src/main/META-INF/resources/frontend/themes/example-theme so it will be packaged in the JAR

Hi Artur,

many thanks for your prompt reply!
Unfortunately the theme is still not part of the final jar of the ‘application’ module.
Here’s what I did:

  • mv views/src/main/frontend/themes/example-theme views/src/main/META-INF/resources/frontend/themes/example-theme
  • ./mvnw clean package -Pproduction
unzip -l application/target/application-0.0.1.jar| grep 'META-INF'                                             
        0  11-05-2024 11:48   META-INF/
      459  11-05-2024 11:48   META-INF/MANIFEST.MF
        0  02-01-1980 00:00   META-INF/services/
       66  02-01-1980 00:00   META-INF/services/java.nio.file.spi.FileSystemProvider
        0  11-05-2024 11:48   META-INF/maven/
        0  11-05-2024 11:48   META-INF/maven/com.thowimmer/
        0  11-05-2024 11:48   META-INF/maven/com.thowimmer/application/
     1688  11-05-2024 11:41   META-INF/maven/com.thowimmer/application/pom.xml
       59  11-05-2024 11:48   META-INF/maven/com.thowimmer/application/pom.properties

How can I ensure that the views/target/classes/META-INF/VAADIN is considered in the repacking happening in the application module (using the spring-boot-maven-plugin)?

I just noticed that the issue might be related to the index*.css not being part of the build output in my multi-module scenario:

Single module build:

unzip -l target/vaadin-single-module-0.0.1.jar | grep 'index'
      669  11-05-2024 13:46   META-INF/VAADIN/webapp/index.html
        0  11-05-2024 13:46   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-B_SY1GJM.css
        1  11-05-2024 13:46   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-B_SY1GJM.css.br
   465718  11-05-2024 13:46   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-JpDjlFtk.js
   115167  11-05-2024 13:46   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-JpDjlFtk.js.br
      267  11-05-2024 13:46   META-INF/VAADIN/webapp/index.html.br

Multi-module build (just the views.jar):

❯ unzip -l views/target/views-0.0.1.jar| grep 'index'
      586  11-05-2024 14:02   META-INF/VAADIN/webapp/index.html
   394185  11-05-2024 14:02   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-UV-vEubm.js
   106435  11-05-2024 14:02   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-UV-vEubm.js.br
      271  11-05-2024 14:02   META-INF/VAADIN/webapp/index.html.br

Any thoughts @Artur ?

I created a simpler project to reproduce it:
GitHub - thowimmer/vaadin-hilla-multimodule-theme: Example Maven multi-module packaging of a Vaadin Hilla webapp.

  • main branch: multi module setup (app = create bundle; presentation = contain vaadin view & theme)
  • single-module branch: single module setup (contains exactly the same files as in multi-module setup)

When running ./mvnw clean package -Pproduction the output is different for either setup:

single-module:

❯ unzip -l target/vaadin-multi-module-0.0.1.jar | grep 'index' 
      669  11-06-2024 10:23   META-INF/VAADIN/webapp/index.html
       40  11-06-2024 10:23   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-BaMXoIpY.css.br
   465942  11-06-2024 10:23   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-B4cZbuEf.js
   113981  11-06-2024 10:23   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-B4cZbuEf.js.br
       36  11-06-2024 10:23   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-BaMXoIpY.css
      265  11-06-2024 10:23   META-INF/VAADIN/webapp/index.html.br

multi-module:

❯ unzip -l presentation/target/presentation-0.0.1.jar | grep 'index' 
      586  11-06-2024 10:26   META-INF/VAADIN/webapp/index.html
   104217  11-06-2024 10:26   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-DUMlgTCX.js.br
   386208  11-06-2024 10:26   META-INF/VAADIN/webapp/VAADIN/build/indexhtml-DUMlgTCX.js
      239  11-06-2024 10:26   META-INF/VAADIN/webapp/index.html.br

The multi-module build does not contain the css file generated by Vite.

Is this a known issue?

I think that the problem is that you have the @Theme annotation in the app module, but you run the build-frontend in the presentation module.
This way the Vaadin maven plugin cannot find the theme annotation.

1 Like

Hi @marcoc_753,

you are indeed right! :pray:

Solution
The AppShellConfigurator with the @Theme annotation has to reside in the module where the Vaadin Maven Plugin is applied.

Fix
Created a dedicated class which implements the AppShellConfigurator interface within the presentation module: