vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
616 stars 167 forks source link

Hot deploy: Theme variant change only applied after full Maven rebuild #6044

Open mvysny opened 5 years ago

mvysny commented 5 years ago

Hot deploy issue: happens with IDE (IntelliJ) which is able to reuse something (resources or classes?) from the original project location even though it's deployed to the web server.

Vaadin 14.0.0.rc4

I have the skeleton starter app, with @Theme(value = Lumo.class, variant = Lumo.LIGHT) added on the MainView class. I recompile the project with mvn clean package and launch the WAR file in Intellij+Tomcat. A white button on white background is properly shown.

Now I change the theme variant to dark as follows: @Theme(value = Lumo.class, variant = Lumo.DARK). The theme has not been changed, only the variant. I restart the Tomcat in Intellij, however the dark variant is not applied: the page still uses light theme, as can be seen on the body element: <body theme="light">. I need to run mvn clean package again, in order to actually activate the dark theme. That doesn't make any sense since the theme is webpacked in in both variants, as can be seen in a browser: simply change the body element to <body theme="dark"> to have the dark theme applied.

It should not be necessary to do mvn clean package after the variant changes in the annotation - the change should be applied without having to run Maven.

mehdi-vaadin commented 5 years ago

Acceptance criteria

denis-anisimov commented 5 years ago

I'm not able to reproduce the issue.

To avoid any external servers and extra maven task influence do this:

What I'm doing is :

It might be that your resulting WAR file is not updated for some reason ( or WAR deployed to the web server is not a new one but is just the same). Please check that.

mvysny commented 5 years ago

@denis-anisimov the bug was filed because it should not be necessary to rebuild WAR in order to change the variant. In other words, the variant change should be applied even when you omit do mvn package from your steps.

The following command document.body.setAttribute("theme","dark") in vaadin-bundle-yyyy-cache.js appears to be generated at Maven compile time from the @Theme annotation. Is there a reason for that? Shouldn't client-side receive the "dark" String as a parameter from the server and apply it?

denis-anisimov commented 5 years ago

Hmm....

I'm not sure how that possible.......

You are deploying a WAR file into the external Web server. How may you produce a WAR file without doing mvn package? I think I'm lost...

denis-anisimov commented 5 years ago

Is there a reason for that? Shouldn't client-side receive the "dark" String as a parameter from the server and apply it?

This is a bit out of the scope of my current activity. I'm just trying to make sure that there is an issue via reproducing it. This is the way how it's implemented right now. I don't know the reasons why it's done like it's done.

But I still don't understand how it may come from the server if it's not build with the updated value.

I don't think I understand the ticket at all.

mvysny commented 5 years ago

Aha, that's the problem :) I'm not deploying a fully-built WAR to an external Web server. I'm developing an app in Intellij Ultimate, deploying into Tomcat via Intellij's Run configuration. Intellij doesn't need to build the WAR file via Maven in order to deploy exploded WAR into Tomcat. My use-case is that I simply wish to see how the app looks like with the dark theme. So, I stop Tomcat from Intellij, change the annotation, then run the project in Intellij's Tomcat. Intellij doesn't run Maven but uses its own build system to rebuild stuff. Yes, Intellij won't run Vaadin Flow Maven plugin and won't recompile vaadin-bundle-yyyy-cache.js, that's why the variant is apparently ignored. That's the problem.

However, this issue will plague every customer developing on Intellij (this issue has actually been reported to me from a customer via Expert Chat). Therefore I believe that the theme variant must not be compiled into the cache.js file.

denis-anisimov commented 5 years ago

Alright, now I got this. So this is kind of hot deploy issue. We have a bunch of issues related to this kind of functionality. I will update the title, thanks.

mvysny commented 5 years ago

Thanks! Yet I think it's not necessarily a hot-redeploy: you can kill Tomcat, change the annotation and run Tomcat from scratch from Intellij, and the variant change would still not be applied to the app. A cold redeploy if you will :)