Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontendHotploy isn't working for a Vaadin multi-module gradle project #20992

Open
nico-fri opened this issue Feb 13, 2025 · 14 comments · May be fixed by #21099
Open

frontendHotploy isn't working for a Vaadin multi-module gradle project #20992

nico-fri opened this issue Feb 13, 2025 · 14 comments · May be fixed by #21099
Assignees
Labels
BFP Bugfix priority, also known as Warranty documentation waiting for author

Comments

@nico-fri
Copy link

nico-fri commented Feb 13, 2025

Description of the bug

I have a Vaadin 24 multi-module gradle project where I want to use the frontendHotdeploy so that I don't have to restart the server every time I make a css or js change. Unfortunately the hotdeploy does not work in this constellation.

In the Vaadin 24 gradle starter template, the frontend folder is under src/main/frontend. In a multi-module project it must be under src/main/resources/META-INF/resources/frontend. Otherwise, an error message will appear at startup stating that the files cannot be found. If the frontendHotploy flag is now set to true in build.gradle, it no longer works

Expected behavior

The hotreload of css and js works so that the server does not have to be constantly restarted

Minimal reproducible example

Two Vaadin 24 gradle starter projects where one is added as a dependency via build.gradle.

Project 1:

  • settings.gradle: rootProject.name = 'project-components'

Project 2:

  • settings.gradle:
    rootProject.name = 'project-main'
    include(":project-components")
    project(":project-components").projectDir = new File("../project-components")

  • build.gradle
    vaadin {
    frontendHotdeploy = true;
    }
    dependencies {
    implementation(project(":project-components"))
    }

Versions

  • Vaadin / Flow version: 24
  • Java version: 17
  • OS version: MacOS 15.3
  • Browser version (if applicable): Safari
  • Application Server (if applicable): Wildfly V35
  • IDE (if applicable): Intellij
@knoobie
Copy link
Contributor

knoobie commented Feb 13, 2025

Did you try this property? At least in Maven it works.

  <properties>
    <vaadin.frontend.hotdeploy.dependencies>../moduleB</vaadin.frontend.hotdeploy.dependencies>
  </properties>

@nico-fri
Copy link
Author

The property frontendHotdeployDependencies is not available in a gradle project

Did you try this property? At least in Maven it works.

../moduleB

@mshabarov mshabarov added the BFP Bugfix priority, also known as Warranty label Feb 17, 2025
@mshabarov mshabarov moved this to 🪵Product backlog in Vaadin Flow ongoing work (Vaadin 10+) Feb 17, 2025
@mcollovati
Copy link
Collaborator

vaadin.frontend.hotdeploy.dependencies is expected to be provided as a Java system property.

@mshabarov
Copy link
Contributor

Setting the path to module B to system property vaadin.frontend.hotdeploy.dependencies should work.

We need to document this property as it was created exactly for such use cases - it tells Vite dev server HMR what module to watch.

@mshabarov mshabarov moved this from 🆕 Needs triage to 🔖 High Priority (P1) in Vaadin Flow bugs & maintenance (Vaadin 10+) Feb 18, 2025
@mshabarov mshabarov removed the gradle label Feb 18, 2025
@mshabarov mshabarov moved this from 🪵Product backlog to 🟢Ready to Go in Vaadin Flow ongoing work (Vaadin 10+) Feb 19, 2025
@mshabarov
Copy link
Contributor

Additional observations:

I just tried the system property -Dvaadin.frontend.hotdeploy.dependencies=“../project-components” and the frontendHotdeploy worked for project-components, but not for the project-main. I tried to include the project-main additionally via : or ;. However, this did not work =”../project-components;../project-main”

We have to test and be sure that this property works consistently.

@tepi tepi self-assigned this Feb 26, 2025
@tepi tepi moved this from 🟢Ready to Go to ⚒️ In progress in Vaadin Flow ongoing work (Vaadin 10+) Feb 26, 2025
@tepi
Copy link
Contributor

tepi commented Feb 28, 2025

Tried this just now and got it working with a few minor changes. I'm not exactly sure what you're using to run the app, I was using Jetty via Gretty plugin.

First issue is that Gradle does not forward system properties to the Jetty process it starts so I had to add a line for that in Gretty section of the root project's build.gradle file:

gretty {
	contextPath = "/"
	servletContainer = 'jetty11'
	systemProperties = System.getProperties() // <- This line!
}

If you're using e.g. Spring I think there's a similar way to pass the system properties to that process as well.

Second issue is the separator for multiple paths, which is actually , - so the parameter I used when starting the app is:

-Dvaadin.frontend.hotdeploy.dependencies='./components,./components2'

Do also note the ' instead of ", although this might depend on the OS or shell used.

Please try it out and let me know if you still have issues.

Note to Flow team: we most likely need to update documentation about how to do this.

@tepi
Copy link
Contributor

tepi commented Feb 28, 2025

Another thing to consider internally is that if the Flow Gradle Plugin would have frontendHotdeployDependencies as a plugin configuration property, one would not need to do the system property forwarding since the plugin would pick it up from its configuration in build.gradle.

@TatuLund
Copy link
Contributor

I'm not exactly sure what you're using to run the app, I was using Jetty via Gretty plugin.

There is

Application Server (if applicable): Wildfly V35

Mentioned in the issue description.

@tepi
Copy link
Contributor

tepi commented Feb 28, 2025

Application Server (if applicable): Wildfly V35

Mentioned in the issue description.

Thanks, missed that. Maybe I'll wait for more info or test results from the author. Quickly searching I could not find a Wildfly plugin for Gradle (well there was something last updated 2018), so not sure how to run it in dev mode with Wildfy+Gradle combination.

mcollovati added a commit that referenced this issue Feb 28, 2025
Activating a feature flag in the project does not work when a default bundle
is used because the values of the flags sent to the client are hard-coded at
bundle build time. Additionally, if a feature flag is active during bundle
creation, it remains active on the client side even if the project does not
activate it in the `vaadin-featureflags.properties` file.

This change ensures that feature flags in the frontend bundle are always
disabled initially and are activated on page load based on the current
project settings.

Fixes #20992
@tepi
Copy link
Contributor

tepi commented Mar 3, 2025

@nico-fri Could you please check if the comments here help you at all? Additionally, it would help my testing if you could provide information on your setup to run the dev mode using WIldfly+Gradle. Thank you!

@nico-fri
Copy link
Author

nico-fri commented Mar 3, 2025

Separated by a comma, the system property works
=> -Dvaadin.frontend.hotdeploy.dependencies='../project-components,../project-components-2,../project-main'.
Unfortunately only for the project-components and the project-components-2 project. However, frontendHotdeploy does not work for the main project (project-main).

The project consists of two Vaadin Gradle Starter templates (https://github.com/vaadin/base-starter-gradle) with the customizations from the initial request (Minimal reproducible example). It is started with the default Wildfly (https://www.wildfly.org/downloads/) and the VM options (-Dvaadin.frontend.hotdeploy.dependencies).

And to the other addition: It would be very helpful if the Flow Gradle plugin would have frontendHotdeployDependencies as a configuration property.

@tepi
Copy link
Contributor

tepi commented Mar 3, 2025

Tried my project with latest Wildfly with the same result: both the root project and the two sub-project hotdeploy works correctly. I probably have something set up differently than you do, but right now I can't see it. I'll attach my project here so you can take a look at what is the difference.

Please note the root build.gradle contains Gretty config so that can be run from command line. For Wildfly I deployed and started using IDEA.

GradleTest.zip

@nico-fri
Copy link
Author

nico-fri commented Mar 4, 2025

The difference between our projects is that the frontend folder of the main project is under src/main/frontend. In my project, it is located under src/main/resources/META-INF/resources/frontend, just like in the components projects. The reason for this is that the main project is also only a part of another overall project.

As a comparison in our example, we can say that the individual “components” projects can be started alone for development purposes with development routes to display/develop the components in isolation. In this case, the frontendHotdeploy does not work (provided, of course, that frontendHotdeploy = true is set in the build.gradle of the components project).

Setting the frontendDirectory in build.gradle did not help either:
frontendDirectory = new File(project.projectDir, “src/main/resources/META-INF/resources/frontend”)

@tepi
Copy link
Contributor

tepi commented Mar 5, 2025

Related Docs issue: vaadin/docs#2412

@tepi tepi linked a pull request Mar 7, 2025 that will close this issue
@tepi tepi moved this from ⚒️ In progress to 🔎Iteration reviews in Vaadin Flow ongoing work (Vaadin 10+) Mar 7, 2025
@tepi tepi moved this from 🔎Iteration reviews to ⚒️ In progress in Vaadin Flow ongoing work (Vaadin 10+) Mar 12, 2025
@tepi tepi moved this from ⚒️ In progress to 🔎Iteration reviews in Vaadin Flow ongoing work (Vaadin 10+) Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFP Bugfix priority, also known as Warranty documentation waiting for author
Projects
Status: 🔖 High Priority (P1)
Status: 🔎Iteration reviews
Development

Successfully merging a pull request may close this issue.

6 participants