Skip to content

Commit

Permalink
Move to top, update Efficiency section
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinVaadin committed Nov 25, 2024
1 parent 938d9e5 commit c8b8749
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions articles/flow/configuration/live-reload/hotswap-agent.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Check warning on line 17 in articles/flow/configuration/live-reload/hotswap-agent.adoc

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Vaadin.Will] Avoid using 'will'. Raw Output: {"message": "[Vaadin.Will] Avoid using 'will'.", "location": {"path": "articles/flow/configuration/live-reload/hotswap-agent.adoc", "range": {"start": {"line": 17, "column": 50}}}, "severity": "WARNING"}

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.

Check warning on line 19 in articles/flow/configuration/live-reload/hotswap-agent.adoc

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Vaadin.Will] Avoid using 'will'. Raw Output: {"message": "[Vaadin.Will] Avoid using 'will'.", "location": {"path": "articles/flow/configuration/live-reload/hotswap-agent.adoc", "range": {"start": {"line": 19, "column": 80}}}, "severity": "WARNING"}

Vaadin IDE Plugin also provides *Compile on save* option which can be enabled in IDE settings (may differ depending on IDE).

== Manual installation

Check warning on line 23 in articles/flow/configuration/live-reload/hotswap-agent.adoc

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Vaadin.HeadingCase] 'Manual installation' should be in title case. Raw Output: {"message": "[Vaadin.HeadingCase] 'Manual installation' should be in title case.", "location": {"path": "articles/flow/configuration/live-reload/hotswap-agent.adoc", "range": {"start": {"line": 23, "column": 4}}}, "severity": "WARNING"}

Manual setting up hotswapping consists of three steps:

- Install JetBrains Runtime;
Expand All @@ -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

Check warning on line 38 in articles/flow/configuration/live-reload/hotswap-agent.adoc

View workflow job for this annotation

GitHub Actions / lint

[vale] reported by reviewdog 🐶 [Vaadin.HeadingCase] 'HotswapAgent' should be in title case. Raw Output: {"message": "[Vaadin.HeadingCase] 'HotswapAgent' should be in title case.", "location": {"path": "articles/flow/configuration/live-reload/hotswap-agent.adoc", "range": {"start": {"line": 38, "column": 5}}}, "severity": "WARNING"}

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.

Expand All @@ -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.

Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit c8b8749

Please sign in to comment.