From c8b8749c8a1970085e0d337d8efd915bddc3949c Mon Sep 17 00:00:00 2001 From: marcin Date: Mon, 25 Nov 2024 16:38:54 +0100 Subject: [PATCH] Move to top, update Efficiency section --- .../live-reload/hotswap-agent.adoc | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/articles/flow/configuration/live-reload/hotswap-agent.adoc b/articles/flow/configuration/live-reload/hotswap-agent.adoc index 739e18eff9..5aff09f72d 100644 --- a/articles/flow/configuration/live-reload/hotswap-agent.adoc +++ b/articles/flow/configuration/live-reload/hotswap-agent.adoc @@ -12,6 +12,16 @@ JetBrains Runtime offers hotswapping of any type of Java changes into a running In addition to getting the Java changes into the running JVM, most frameworks have some global data that needs to be updated when a class changes -- or some caches that need to be cleared for the new class to take effect. HotswapAgent is a collection of plugins for various frameworks, which offers these kinds of global updates and cache clearing when needed. +== Using Vaadin Copilot and Vaadin IDE Plugin + +Depending on project setup and used IDE, Copilot will download proper version of JDK and suggest Vaadin plugin for your IDE. + +Debugging application using *Debug using HotSwap Agent* from Vaadin IDE plugin will automatically check if you are using proper JDK, check if HotSwap Agent is available and apply additional required JVM arguments. + +Vaadin IDE Plugin also provides *Compile on save* option which can be enabled in IDE settings (may differ depending on IDE). + +== Manual installation + Manual setting up hotswapping consists of three steps: - Install JetBrains Runtime; @@ -20,12 +30,12 @@ Manual setting up hotswapping consists of three steps: All above can be done automatically using Vaadin Copilot together with Vaadin IDE Plugin. -== JetBrains Runtime +=== JetBrains Runtime You can download the latest version from the https://github.com/JetBrains/JetBrainsRuntime/releases[JetBrains GitHub release page]. Be sure to select the correct architecture. Use JetBrains Runtime to execute your application, not necessarily your IDE. -== HotswapAgent +=== HotswapAgent You can download HotSwapAgent from the https://github.com/HotswapProjects/HotswapAgent/releases[HotswapAgent GitHub release page]. You'll need version 1.4.2 or later. @@ -34,7 +44,7 @@ Download the JAR file and place it inside the JetBrains Runtime installation dir If you want to know more about the features of HotswapAgent, the documentation in the https://hotswapagent.org/[HotswapAgent webpage] is a good resource. -== Running Application +=== Running Application To enable hotswapping when launching the application, you need to pass `-XX:+AllowEnhancedClassRedefinition -XX:HotswapAgent=fatjar` as JVM arguments -- not program arguments. @@ -46,14 +56,6 @@ In the same dialog you need to click menu:Modify options[Add VM options] to be a If you have another type of application, you'll need to pass the JVM options in the appropriate way. -== Using Vaadin Copilot and Vaadin IDE Plugin - -Depending on project setup and used IDE, Copilot will download proper version of JDK and suggest Vaadin plugin for your IDE. - -Debugging application using *Debug using HotSwap Agent* from Vaadin IDE plugin will automatically check if you are using proper JDK, check if HotSwap Agent is available and apply additional required JVM arguments. - -Vaadin IDE Plugin also provides *Compile on save* option which can be enabled in IDE settings (may differ depending on IDE). - == Testing With the settings in place, when you start the application in debug mode, you'll see the following type of log output: @@ -78,7 +80,7 @@ Don't launch the Maven `spring-boot:run` target as that forks another JVM proces By default, any change in the Java code causes the application to reload in the browser. This is convenient when you make changes to the initial layout, constructors, post construct methods or similar. However, if you're modifying the logic inside a listener, there's no need to do a page reload for the change to take effect. -IntelliJ doesn't by default compile a Java file when you save it. If your habit is to press the compile shortcut, hotswapping works fine. Otherwise, you might want to set IntelliJ to build the project when you save. You can do that through menu:Settings[Build, Execution, Deployment > Compiler > Build project automatically]. You'll also need to ensure that the build takes place when the application is running in debug mode. This is done through menu:Advanced Settings[Allow auto-make to start even if developed application is currently running]. Finally, through menu:Settings[Build, Execution, Deployment > Debugger > HotSwap], [guilabel]*Reload classes after compilation* should be set to [guilabel]*Always*. +When using Vaadin IntelliJ plugin Java file can be compiled automatically on save. Otherwise, you might want to set IntelliJ to build the project when you save. You can do that through menu:Settings[Build, Execution, Deployment > Compiler > Build project automatically]. You'll also need to ensure that the build takes place when the application is running in debug mode. This is done through menu:Advanced Settings[Allow auto-make to start even if developed application is currently running]. Finally, through menu:Settings[Build, Execution, Deployment > Debugger > HotSwap], [guilabel]*Reload classes after compilation* should be set to [guilabel]*Always*. == Additional Considerations