Grails / IntelliJ: trouble with simple groovy import? - grails

I'm following Burt Beckwith's (Grails developer and author) use of Heroku as indicated here in Grails book. (See import statement at top of this link -- that's what's giving me problems).
I added the following to BuildConfig.groovy as Burt indicates:
runtime 'postgresql:postgresql:8.4-702.jdbc3' // in the dependencies section as described
compile ':heroku:1.0.1' // in the plugins section as described.
Then IntelliJ prompted me to update the IDE with the BuildConfig changes, which I did. I also exited and restarted IntelliJ to see if that might get rid of the import error for:
import grails.plugin.heroku.PostgresqlServiceInfo
It did not get rid of the import error, which then complains when I do the addition of:
PostgresqlServiceInfo info = new PostgresqlServiceInfo()
in the Bootstrap class as is shown in the example. What am I doing wrong / how do I fix this kind of stuff?

In IDEA you need to open Tools | Grails | Plugins, select Heroku plug-in and click Apply Changes.
This will configure a module for the plug-ins and add this module to the dependencies of your application.

Take some time.
Halt the idea of using IDEA for a moment.
Use command prompt.
Try the same steps.
You will see everything working.
Works for me. :-)

Related

Grails 3 Taglib: cannot resolve symbol in IntelliJ IDEA

I'm using Grails 3.1.7 with IntelliJ IDEA Ultimate 2016.1. In the project are several custom taglibs. The tags are working as expected, but the view editor shows an error on every tag usage:
Is there a way to configure IntelliJ and/or Grails that this is correctly shown? The build in Grails tags are shown correctly and jump to source is also working.
Edit 1:
On some tag there is a message that the that is not allowed here, but jump to source is also not working
In the gradle window, click "Refresh all Gradle Projects" - This usually helps resolve anything that's not found.
Also check out 2016.2 EAP as there are Grails 3 and GORM 5 improvements.

Grails Project Not Auto Reloading

I have a larger Grails project for which I have taken over development. I have used Grails before and one of the features that I found really nice-to-have is the auto-compilation/reloading when developing.
I haven't had to do anything special to make this work in the past, however for some reason it is not triggered for this project.
I do a simple "grails run-app" and modify a file when server is started - nothing! Any suggestions?
Windows 7, Grails 2.0.1, Java 1.6u35
IDE: Groovy Grails Tool Suite 3.1.0.M1 - Based on Eclipse Juno 4.2
Grails command line doesn't seem to properly handle spaces in directory names of GRAILS_HOME or HOME directory.
see:
http://jira.grails.org/browse/GRAILS-7936
it has links to various other related issues.
This comment has a workaround: http://jira.grails.org/browse/GRAILS-7936?focusedCommentId=72170&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-72170 .
Are you using eventCompileStart in scripts/_Events.groovy? That was my problem, see GRAILS-8776 (please comment and vote on that issue if this is your problem so we can get it resolved!).
Commenting out that block cause auto-reloading to start working again for me.
My solution:
Right click on project -> Properties -> Project Facets -> check Java and set it's correct version -> OK
Bingo!

Migrating big grails project to Intellij

I am taking over development of a rather large grails project. The development was initially done in STS however I would like to move to IntelliJ Idea.
Initially I thought this would be a piece-of-cake because of the "integrate-with --intellij" command. This is however not the story :(
The project consist of mulitple grails-plugin projects (Please don't ask me why it was developed this way) and some of them with web-descriptors. I start out by migrating one of these, since this is one of the "main" projects (X).
Each of the developed plugins that X has as a dependecy to Intellij creates as "YinplacePlugin" modules where Y is the plugin name. And this is where the fun begins! The "YinplacePlugin" module created for the Y project has of course a lot dependencies it self. These are, if I look in STS, referred to in $USERHOME$/.grails/project/Y/plugins/xxxx and this path is in STS included in the build-path.
But these depencies FAIL in idea. I CAN use the "grails compile" option from within the project however IntelliJ "Make Project" or "Make Module" fails because of missing references. See below:
The first image shows the failing reference. The second how STS has this on the build path.
So why don't you just add the libraries to the build path? one might ask. Well, I tried. One result:
IDEA hook: Grails not found!
| Error java.lang.NullPointerException
| Error at org.jetbrains.groovy.grails.rt.Agent$2.run(Agent.java:99)
| Error at java.lang.Thread.run(Thread.java:662)
I am out of ideas. Any ideas how to get this to build using "Idea Make Project"? All I want is an IDE without "red-lines" so development will be smooth!

Debug grails recompilation

I am working on grails 2.0.4 project and at some point I've found that recompilation process does not work. Further tries showed that first run-app after removing ~/.grails/2.0.4 has recompiling process working well, but running run-app next time ignores changes in files during run (no changes on pages and no Compiling… message in log after appears). So my question is how to debug recompilation process?
There's some JIRA issues related to the recompilation:
http://jira.grails.org/browse/GRAILS-8951
http://jira.grails.org/browse/GRAILS-8573
http://jira.grails.org/browse/GRAILS-8914
Only the third one is fixed. Looking in the first, some folks said that this not work:
grails run-app
But entering in the interactive mode works:
grails
run-app
Looking a bit in the code, I can see that GrailsProjectWatcher.java is responsible for file changes. Try to add debug to the related package and see if you get messages.
If it's one particular class that's not reloading, one thing you can check is that the package definition is correct. Grails will happily compile a class that is in the wrong package, but this breaks the reloading mechanism.

Command to change package name in Grails

I have created my application under package music. Now I want to change my package to com.mp3.songs.music.
One way is I can manually create the package for grails-app. Is there anything else that I need to take care while changing the package name.
Alternatively, is there a command in grails which can be used to change the package.
I found a way out in the below link. But this works only when you create new files. What if you want to change the package of the older files.
http://www.goto20.nl/tech/groovy/configuring-the-default-package-name-for-a-grails-project/
Thanks!
IntelliJ IDEA has very good support for rename refactoring. I believe it is currently the best (9.0.3 stable) chance you'll have of any major refactoring jobs in Grails. They have a 30 day trial, so it is worth a try.
Why not use Spring Source Tool Suite. Its a great IDE with solid support for Groovy n Grails.

Resources