I am using HotswapAgent with Intellij IDEA and it works very nicely for the UI components. Great alternative to JRebel. Thank you!
Anyhow, I cannot make changes in translations.properties to be available without restarting the debug session.
Is HotswapAgent the right approach or should the file be reloaded automatically by Vaadin in Development mode? What is the best practice for development here?
I have tried to configure hotswap-agent.properties by setting the folder: watchResources=src/main/resources/vaadin-i18n (setting a wrong folder gives an error message, so HotswapAgent uses this file).
This is the logging for a change in the file:
HOTSWAP AGENT: 15:40:32.207 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/Users/timo/projekte/github.com/timomeinen/demo/src/main/resources/vaadin-i18n/translations.properties' --> translations.properties
HOTSWAP AGENT: 15:40:32.342 DEBUG (org.hotswap.agent.annotation.handler.WatchEventCommand) - Executing resource changed method resourceChanged on class org.hotswap.agent.plugin.vaadin.VaadinPlugin for event WatchFileEvent on path /Users/timo/projekte/github.com/timomeinen/demo/src/main/resources/vaadin-i18n/translations.properties for event ENTRY_MODIFY
HOTSWAP AGENT: 15:40:32.550 DEBUG (org.hotswap.agent.command.impl.SchedulerImpl) - Executing Command{class='com.vaadin.flow.hotswap.Hotswapper', methodName='onHotswap'}
HOTSWAP AGENT: 15:40:35.310 DEBUG (org.hotswap.agent.watch.nio.WatcherNIO2) - Watch event 'ENTRY_MODIFY' on '/Users/timo/projekte/github.com/timomeinen/demo/target/classes/vaadin-i18n' --> vaadin-i18n
You can set a breakpoint in the com.vaadin.flow.hotswap.Hotswapper.onHotswap(URI[] createdResources, URI[] modifiedResources, URI[] deletedResources) method, to check if resource bundles cache is cleared and the page refresh is triggered.
Also, setting DEBUG level for com.vaadin.flow.hotswap category should show if a refresh attempt is done.
Do note that there was an issue with this in earlier HotswapAgent versions but it is supposed to be resolved in the latest one. If you have manually set up HotswapAgent, check that you are using the latest
@marcoc_753 Thanks for the link. The breakpoint hits on UI class changes, but not on changes in translations.properties. Only after setting watchResources=src/main/resources/vaadin-i18n the breakpoint hits and ResourceBundle.clearCache(); is called.
@Artur I am using HotSwapAgent 2.0.2 from the Intellij Vaadin Plugin 1.4.6.
To sum up: It is working now, but only with setting watchResources in the config.
You’re right about watchedResources. It will work without, if you modify the property file in target/classes, but not for the sources.
It is also mentioned in the hotswap agent README
Reload resource after a change - resources from the webapp directory are usually reloaded by the application server. But what about other resources like src/main/resources? Use watchResources property to add any directory to watch for a resource change.
I think there could be some situation the IDE will also update the property file in the classes folder
Ah got it. That was probably the source for my cofusion. Thank you very much for the effort in integrating HotswapAgent. This is really a productivity boost!