vaadin / vaadin-gradle-plugin

Gradle plugin for Vaadin 14 applications. Takes care of front-end build, helps to configure repositories and to create various project and file templates.
Apache License 2.0
31 stars 9 forks source link

Packaged spring-boot application built with vaadinBuildFrontend starts in dev-mode #39

Closed cheppsn closed 4 years ago

cheppsn commented 4 years ago

Setup

Description We are building a multi-module spring-boot application (with Vaadin only being used in a single module of that application).

When I execute gradlew clean vaadinBuildFrontend build and then run the application from my IDE (IntellJ) everything works as expected, the server starts with Vaadin in PROD mode.

However, when I execute the above and then either use bootRun or the start script of the generated bootDistZip, then Vaadin starts in developer mode and will execute npm install etc. during startup:

2020-02-13 15:42:12.372  INFO 20160 --- [           main] c.v.f.s.VaadinServletContextInitializer  : Search for subclasses and classes with annotations took 9 seconds
2020-02-13 15:42:12.382  INFO 20160 --- [           main] c.v.f.server.startup.DevModeInitializer  : Starting dev-mode updaters in ...(redacted)..\master folder.
2020-02-13 15:42:12.464  INFO 20160 --- [           main] dev-updater                              : Visited 105 classes. Took 28 ms.
2020-02-13 15:42:12.479  INFO 20160 --- [           main] dev-updater                              : Added 13 dependencies to main package.json
2020-02-13 15:42:12.480  INFO 20160 --- [           main] dev-updater                              : Updated npm ...(redacted)...\master\package.json.
2020-02-13 15:42:12.495  INFO 20160 --- [           main] dev-updater                              : Updated npm ...(redacted)...\master\target\frontend\package.json.
2020-02-13 15:42:12.499  INFO 20160 --- [           main] dev-updater                              : Added 33 dependencies to '...(redacted)...\master\target\frontend\package.json' 2020-02-13 15:42:12.501  INFO 20160 --- [           main] dev-updater                              : Updated npm ...(redacted)...\master\target\frontend\package.json.
2020-02-13 15:42:12.508  INFO 20160 --- [           main] dev-updater                              : Updated npm ...(redacted)...\master\package.json.
2020-02-13 15:42:12.510  INFO 20160 --- [           main] dev-updater                              : Running `npm install` ...
... etc

I'm not sure how to debug this and whether the problem is caused by the Vaadin gradle plugin or by our multi-module build.

cheppsn commented 4 years ago

Update So I did some remote debugging and found the following problem:

Since we're using Vaadin in a sub-project of a multi-module project, the vaadin code will be packaged as a separate module jar inside the spring-boot jar/dist zip.

This results in a resource path like jar:file://projects/.../server/application/build/libs/server-app-M17.9d1be5e.jar!/BOOT-INF/lib/vaadin-ui.jar!/META-INF/VAADIN/config/flow-build-info.json where vaadin-ui.jar is the library module that contains our frontend code.

Unfortunately resources with two jar! parts like this are explicitly ignored in DeploymentConfigurationFactory.java#L354 and therefore PROD mode is not activated at runtime.

So this is not a problem of the plugin, it is a problem of Vaadin -> I'll file a bug there.