Using Grails 2.4.3 in IntelliJ - grails

I've been unable to create/import a Grails 2.4.3 project with IntelliJ 13.1.4. For example, when I create a new module, choose Grails, then click the create button (highlighted below) and choose the location where Grails 2.4.3 is installed, the project is not created correctly (I get a module with just a /src directory instead of a Grails project) and Grails 2.4.3 is not added to the list of Global Libraries. I don't have this problem with any earlier version of Grails.

I have used Grails 2.4.2 with Intellij 13.1.4 successfully. What I did is create the application with the grails create-app command and then do a File / Import Project in Intellij. Give that a try.

As an alternative solution to the IntelliJ 13.1.4 and Grails 2.4.3 bug you can:
grails create app <app-name>
cd app-name
grails integrate-with --intellij
This configured the project correctly for me with just minor tweaks to SDK and application server. This is a minor twist on the work around described above.
See grails doc here

I had the same problem with IntelliJ 13.1.4 and Grails 2.4.3, which i just downloaded.
After using the grails create-app command from the command line i had to import the project, by "create from existing sources" (point to the new top level folder), "Configure SDK" (to set for the Grails 2.4.3) and finally edit the run configuration. In a second test run with a new test project i did not have too configure the run config.
Then the Grails libs for the were downloaded and the basic app ran. Also the Grails specific option in the Intellij "Tools2 section were suddenly available.
So the given answer by Joe is the way to setup a new Grails project but the IDE should be fixed anyways.

It is not consistent. After several tries I can get some applications to work but it does not seem to be automatic. I think I am going to go back to Grails 2.4.2 until this is resolved within Intellij 13.1.4.

In the screenshot above, there are options for groovy/grails/griffon, and so far the alternative offered was command-line. Try choosing groovy option within intelliJ.
We are using IDEA 13.1.4 with grails 1.3.7 and grails 2.2.1(diff projects) and saw the same issue. It appears this is an intelliJ issue and not so much the grails version, so reverting your grails won't gain you anything. Choosing groovy, you should see a prompt for grails directory structure. This does work if you are presented with this option. Seeing inconsistencies here. Thanks to all for posting your workarounds; never hurts to have multiple approaches.
-Duane

Related

Intellij create grails project

when I create new project in IntelliJ on the left Grails is missing,I think there was some kiind of plugins/tools to install Grails on IntelliJ and then it will show up but where is it?
In order to have the grails in you project, you should check that the grails is included in your build.gradle file.
These are the main lines for basic building of the Grails framework.(There are other extensions you can add).
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
grails {
grailsVersion = '3.1.10'
}
dependencies {
compile "org.grails:grails-core:$grailsVersion"
}
After adding those lines you should close the IntelliJ Idea and open it using the build.gradle file.
Then you should see the grails-app [main] directory.
Intellij (I am using version 2016.2.5) does not support the Grails view (on the left side of screen) for Grails 3.x projects. Hopefully in they will add this again for 3.x project I also miss that on the new projects.
EDITED: Intellij 2016.3.0 now says that Grails View is back for Grails 3.x
Support for Grails exists in the Ultimate edition of IntelliJ IDEA. Since Grails is just a Gradle project, the Community version recognizes this, but you will not get code highlighting for things such a GSPs, intellisense and other features.
More information can on the differences can be found on their site: https://www.jetbrains.com/idea/features/editions_comparison_matrix.html

How to enable grails for Intellij Community 2016.2.5

I just installed intellij community 2016.2.5 in mac, and tried to create a grails project. It does not show grails as an option, but shows Groovy, Gradle, Griffin.
I went to the intellij grails page and it says:
Also, make sure that the Grails plugin is enabled in IntelliJ IDEA. The plugin is bundled with IntelliJ IDEA and is activated by default
Then, I tried to enable the plugin, or find in repositories, but didn't find any, only a Grails Tools, that is not from jetbrains, and after a install and restart, still don't show anything.
Anyone has used this lastest version with Grails? Has any solution or workaround to make it works? Should I download some older version?
Thanks.
Here is how I import a Grails 3 app into community edition:
First use SDKMAN to get grails - http://sdkman.io/install.html
sdk use grails 3.2.1
grails create-app mytestapp
Then import existing project, select the build.gradle file
Check Use Auto Import
Use gradle wrapper
You can run it by using the bootRun gradle task in the gradle toolbar or going to the Application.groovy file and running the main() method.
To see some of the run configs in action you can watch https://www.ociweb.com/products/grails/grails-quickcast-6-developing-grails-3-applications-with-intellij-idea/ - Though I would recomend running gradle from inside intellij, not via the command line. That was just to show how remote debugging works.
With community you lose some features, but it does work well.

Build a new Grails app by Gradle

I get a company's project from Github, and import into the GGTS as a gradle project. Everything runs OK. gradle task show this.
I want to create a new Grails app, so I used the command grails create-app wtf, and then import into GGTS as a Gradle project. What make me confused is that the file named build.gradle or the folder named .gradle do not appear, gradle task shows null like this, while I do the same thing in system of company and it runs fine.
Please tell me what happend? And I did not write a build.gradle in system of company manually.
The problem is Grails 2.4.4 does not use Gradle. That didn't start until Grails 3.0.
I believe you need to import the project as a Grails project (I haven't used ggts in a long time, so my recollection it's foggy). You can read more about IDE integration here.

Intellij IDEA 13.1 isn't creating new Grails Projects

My Intellij IDEA 13.1.4 Ultimate isn't creating new Grails projects using "File" > "New Project".
I mark my project as Groovy Project then I select Grails. I setup a Groovy Library pointing to my Grails 2.4.3 home (I've tried with 2.3.11 and 2.2.5). I click Next and put a name for my project.
Then, when I finish this process, the Intellij Window opens but the Grails "create-app" script doesn't runs and the project isn't properly configured. The folders like "grails-app" and "web-app" aren't created. No log error or warn was generated.
Importing an project works well.
Instead of choosing grails in the menu choose groovy and then select the grails library like this:
that will somehow trigger the create-app script
this is a bug in IDEA, see IDEA-127693

Grails dependencies or Maven

I'm using STS latest version (2.7) and latest grails as well. After I created a freshly grails project in STS it freezes in the updating grails dependencies for a long time and it comes out as a timeout error. And it follows by some GroovyObject error, but the project still runs fine in command-line. So I ditched STS for refreshing dependencies, and I included the dependency in BuildConfig.groovy and use grails compile but I still got ClassNotFound error when compiling, it's like grails didn't pick up the Ivy CLASSPATH. So, I'm thinking of changing it to Maven to resolve any dependencies.
My question would be which one is better and integrated seamlessly in STS or Eclipse?, but I still want to use grails commands, not maven.
If your project is just a grails project - use grails dependencies.
I've experience with mavenized grails project, and plain grails project. First is good when you have multimodule project, and only one of them is grails module. At this case you'll lost all grails commands, you need to use commands like mvn grails:run-app and it's complicated thing to pass arguments into commands :(

Resources