grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.78k stars 950 forks source link

InteillJ stucks in recompiling with Grails 6.2.0 once groovy file changes #13525

Open ghostfox911 opened 3 months ago

ghostfox911 commented 3 months ago

Issue description

Environment

Previous with grails-6.1.2 everything works. When running grails-6.1.2 project in IntelliJ in debug mode IDE can auto recompile and re-run project once groovy file updates.

But after upgraded to grails-6.2.0 once groovy file updated IDE stucked in recompiling and never restarted project. You have to manully click on re-run button.

I tried to clear all caches and rebuild project but nothing helped.

Does anyone have same issue?

duxnp commented 2 months ago

I can't say if this is something that should be fixed by JetBrains or Grails, but I did figure out a workaround.

Instead of creating a Run/Debug Configuration using a Grails or Micronaut template, use a Gradle template and enter "bootRun" as the task.

duxnp commented 2 months ago

Also, you do of course still need developmentOnly("org.springframework.boot:spring-boot-devtools") in build.gradle

ghostfox911 commented 2 months ago

Also, you do of course still need developmentOnly("org.springframework.boot:spring-boot-devtools") in build.gradle

Thanks so much. This setting really fixed this issue.

BTW. Since some time IntelliJ cannot recognize grails project and we have to use gradle - application - bootRun. And also ctrl + alt + G cannot open grails command prompt. Any clues? Thanks in advance.

duxnp commented 2 months ago

Some of what we're talking about here probably belongs in the discussions section rather than issues section, or even the JetBrains YouTrack issue tracker.

With Grails 6.2.0, the current IntelliJ Grails plugin (version 241.14494.158) stopped working. This is why the Run Grails Command dialog doesn't appear when you press CTRL + ALT + G. A workaround for this is to add implementation org.grails:grails-shell:6.1.2 to the dependencies in the build.gradle file. This will get the Grails plugin mostly working again. It will recognize all the artefacts and give you all those nice features such as syntax highlighting, code completion, navigation, etc.

However, the Run Grails Command still won't work. It hasn't worked since 6.0.0. The dialog will appear when you press CTRL + ALT + G, but the commands won't run successfully. If you run "--version" from Run Grails Command, it will report "Grails Version: 6.1.2", but you'll see it's running the commands like this \AppData\Local\Temp\1\idea_arg_file1093355971 org.grails.cli.GrailsCli --version. This makes me think it's trying to use some old CLI code still left in grails-core or something as opposed to the newer CLI in grails-forge. If you try to run a command like "create-controller foo" you'll get an error like "Could not resolve all dependencies for configuration ':profile'.", but I think profiles don't exist anymore from Grails 6 onward.

There's a workaround for running Grails commands as well. The Run/Debug workaround is pretty transparent, however this workaround will be a bit disruptive to your workflow. This will involve running the commands manually from the terminal. Since there's no longer Grails wrapper, you'll have to install the new Grails CLI (https://grails.org/blog/2023-03-29-grails-6-m2.html). If you're able to use SDKMan this is pretty trivial. If for whatever reason you're not able to, this is actually pretty annoying as it's a more manual process and I haven't seen any guidance on how to automatically switch CLI versions per project. If you're in this situation it seems like it's up to you to decide on a way to change your GRAILS_HOME environment variable to the correct path.

The disruptive part for you will be initially installing the new CLI and getting accustomed to running the commands from somewhere else. Using "Run Grails Command" or for example right clicking on the services folder to generate a new Grails service from the context menu was pretty convenient, but I'd say running commands from the terminal is as fast or faster.

ghostfox911 commented 2 months ago

Some of what we're talking about here probably belongs in the discussions section rather than issues section, or even the JetBrains YouTrack issue tracker.

With Grails 6.2.0, the current IntelliJ Grails plugin (version 241.14494.158) stopped working. This is why the Run Grails Command dialog doesn't appear when you press CTRL + ALT + G. A workaround for this is to add implementation org.grails:grails-shell:6.1.2 to the dependencies in the build.gradle file. This will get the Grails plugin mostly working again. It will recognize all the artefacts and give you all those nice features such as syntax highlighting, code completion, navigation, etc.

However, the Run Grails Command still won't work. It hasn't worked since 6.0.0. The dialog will appear when you press CTRL + ALT + G, but the commands won't run successfully. If you run "--version" from Run Grails Command, it will report "Grails Version: 6.1.2", but you'll see it's running the commands like this \AppData\Local\Temp\1\idea_arg_file1093355971 org.grails.cli.GrailsCli --version. This makes me think it's trying to use some old CLI code still left in grails-core or something as opposed to the newer CLI in grails-forge. If you try to run a command like "create-controller foo" you'll get an error like "Could not resolve all dependencies for configuration ':profile'.", but I think profiles don't exist anymore from Grails 6 onward.

There's a workaround for running Grails commands as well. The Run/Debug workaround is pretty transparent, however this workaround will be a bit disruptive to your workflow. This will involve running the commands manually from the terminal. Since there's no longer Grails wrapper, you'll have to install the new Grails CLI (https://grails.org/blog/2023-03-29-grails-6-m2.html). If you're able to use SDKMan this is pretty trivial. If for whatever reason you're not able to, this is actually pretty annoying as it's a more manual process and I haven't seen any guidance on how to automatically switch CLI versions per project. If you're in this situation it seems like it's up to you to decide on a way to change your GRAILS_HOME environment variable to the correct path.

The disruptive part for you will be initially installing the new CLI and getting accustomed to running the commands from somewhere else. Using "Run Grails Command" or for example right clicking on the services folder to generate a new Grails service from the context menu was pretty convenient, but I'd say running commands from the terminal is as fast or faster.

Thanks so much again for such detailed explanations.