grails-core: Inline plugin reloading does not work with Gradle 3

Steps to Reproduce

  1. clone https://github.com/graemerocher/grails-multi-project-build-example
  2. Set grails to use gradle version 3.5.1: export GRAILS_GRADLE_HOME=/home/user/.sdkman/candidates/gradle/3.5.1
  3. run grails run-app in myapp dir.
  4. Change myplugin/grails-app/controllers/myplugin/FooController.groovy and check to see if it has been reloaded.

Expected Behaviour

FooController should be reloaded.

Actual Behaviour

It isn’t reloaded.

Environment Information

  • Operating System: Ubuntu 16
  • Grails Version: 3.2.11, 3.2.8
  • Gradle Version: 3.5.1
  • JDK Version: Java™ SE Runtime Environment (build 1.8.0_91-b14)

Example Application

It does work with Gradle 2.12 (and presumably other 2.x versions):

$ export GRAILS_GRADLE_HOME=/home/chris/.sdkman/candidates/gradle/2.12
$ grails run-app
| Error Error occurred loading commands: org/hibernate/tool/schema/TargetType (Use --stacktrace to see the full trace)
| Error Error occurred loading commands: Could not initialize class grails.dev.commands.ApplicationContextCommandRegistry (Use --stacktrace to see the full trace)
| Running application...
Grails application running at http://localhost:8080 in environment: development
File /home/chris/dev/projects/research/grails3-re/grails-multi-project-build-example/myplugin/grails-app/controllers/myplugin/FooController.groovy changed, recompiling...

Also tried Gradle 4 and this also does not reload. We have a large multi project app that our Grails apps are part of, which requires Gradle 3.x, so we cannot go back to Gradle 2. Have not tried other Gradle 3.x versions.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Ok, this is all coming together now…

Since grails.run.active is a JVM arg to the gradle daemon itself and not bootRun (that’s the part I wasn’t considering), you’d have to start the daemon with it and it causes issues in other ways to have an exploded jar file.

I added it to gradle.properties and reloading does work with 3.3.3, but it broke gradle assemble when it tried to compile assets, presumably because of the exploded classpath.

Probably the best option is to just run gradle bootRun -Dgrails.run.active=true and setup IntelliJ to also add that JVM arg when executing bootRun. That should allow reloading to work once 3.3.3 is availab.e

@longwa Does it work with Grails 3.3.9? I could not make hot reload work with gradle bootRun.

Hi @chrisbrookes, thanks for the tip, after some debugging I ended up with having the same dependencies for the app and the plugins (even if they are not needed in the plugin) and stopping the gradle daemons manually after changes to the build-file (and I also upgraded to gradle 4.5). Now it seems to work so far.