Test HotswapAgent http://hotswapagent.org
Test HotswapAgent http://hotswapagent.org
"we are getting limited grails 6 hotswap behavior with DCEMV /hotswapagent.org. Happy to share what we know and help with that " @lbwexler
Perhaps a good starting place is demonstrating on a super basic app?
Is current HotswapAgent licensed under GPL?
@osscontributor Looks like GPL 2.0
https://github.com/HotswapProjects/HotswapAgent/blob/master/LICENSE https://github.com/HotswapProjects/HotswapAgent?tab=readme-ov-file https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
Also looks like project is active, but no formal releases since 2020 except for a snapshot that points to 2020 commits. https://github.com/HotswapProjects/HotswapAgent/tags They probably plan on an official release at some point given the activity
What are the implications of the GPL license?
Since it's an agent and not embedded in grails I do not believe the implications are of any concern. This is similar to gpl 2 and MySQL
Agent has had recent updates and contributions as of September! Jdk 21 works now as well
@davydotcom Are we able to use ResetAgent.java instead of groovyReset.jar?
Currently blocked by https://github.com/apache/grails-core/issues/13669#issuecomment-3066110262
The following example project has been updated with the latest Grails 7 changes:
https://github.com/jamesfredley/hotswap-demo - this automatically installs and runs the right JDK (only JETBRAINS 17 and 21 work), downloads and installs hotswap-agent.jar from mavenCentral (org.hotswapagent:hotswap-agent:2.0.2) and uses groovyReset.jar.
To replicate the exact steps from: https://www.youtube.com/watch?v=Fz_sKuZ-ytg, although you will see more log errors:
clone https://github.com/jamesfredley/hotswap-demo
./grailsw
create-domain-class Car
// manually add String name to Car domain class
run-app
// view list of controllers on http://localhost:8080/
create-scaffold-controller com.example.Car
// view list of controllers on http://localhost:8080/
// you can create a Car and save, view the list, delete etc.
But other tasks, while Grails is running, such as adding a domain, adding a new field to a domain do not appear to work without a restart. Adding an action to an existing controller works, just make sure the view exists.
./grailsw
run-app
// view list of controllers on http://localhost:8080/
create-domain-class Pet
// manually add String name to Pet domain class
create-scaffold-controller com.example.Pet
// view list of controllers on http://localhost:8080/
// click on PetController
// Error: Either class [com.example.Pet] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
exit
./grailsw
run-app
// view list of controllers on http://localhost:8080/
// click on PetController, it works fine
https://github.com/HotswapProjects/HotswapAgent/issues/581 is relevant
Loading new domain classes, reloading changed domain classes and resolving all of the logged errors may require changes to https://github.com/HotswapProjects/HotswapAgent and it's plugins
@jamesfredley were you seeing hotswap working properly at the Service level as well? In Grails 5, domain class changes required a restart I'm pretty sure so that's not a regression. Is that right @brandonray-gs ?
@jaGarcia editing an existing service reloads. Creating new service requires a restart.
@jamesfredley were you seeing hotswap working properly at the Service level as well? In Grails 5, domain class changes required a restart I'm pretty sure so that's not a regression. Is that right @brandonray-gs ?
Can't recall specifically on domain classes.. believe they did require a restart. Creating new services or injecting other services has always required a restart as well.
I recall editing Domain classes always being something that required restart.
My usage of hotswap in Grails 5 always required restart for anything like creating new artifacts, editing Domain classes, class and method renames, etc. But this never seemed like a huge concern for me -- 90% of the benefit of hotswap comes from being able to change logic in existing methods.
It sounds like https://github.com/jamesfredley/hotswap-demo is on par with expectation from Grails 5.
Here are the changes required to configure Hotswap Agent in an existing application, including automating the download and usage of hotswap-agent.jar and gragent.jar:
https://github.com/jamesfredley/hotswap-demo/commit/fb8386c50f7aad6aee1cefdbc37cc1571ad7d747