Intellij IDEA 13.1 isn't creating new Grails Projects - grails

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

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.

Using Grails 2.4.3 in IntelliJ

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

setup Grails project in IntelliJ IDEA

I have the following directory structure
--my-app
|
|--main-app
|
|--plugins
|
|--plugin1
|
|--plugin2
In grails-app/conf/BuildConfig I've added the necessary configuration to ensure that the plugins are loaded from the plugins directory, so that when I run the application, it picks up the most recent changes.
I'm trying to set this up as a single project in IntelliJ which has 3 modules, one for the main application and one for each of the two plugins. I tried the following:
Generate the IntelliJ project files
cd my-app/main-app
grails integrate-with --intellij
Open the generated .ipr file from inside Intellij (File | Open Project...). This adds the main application and plugins as Grails modules
However every time I open a class from a plugin, IntelliJ reports that the class has two occurrences. It seems each plugin class is being detected
once in the IntelliJ module for the plugin itself
once in the module that IntelliJ automatically creates which contains all the plugins. In my case, this module is named main-app-grailsPlugins
In the project structure view I tried removing the content roots for plugin1 and plugins2 from main-app-grailsPlugins, but they get automatically added back again.
Is there a way to prevent this, or some other way of correctly setting up an IntelliJ project for a Grails app with in-place plugins. I'm using Grails 1.3.7 and IntelliJ 10.5.4
With IntelliJ IDEA 12 Ultimate this is very easy:
"File"
--> "Import Project..."
--> select your grails application, "OK"
--> Select "Create project from existing sources", "Next"
--> "Next"
--> "Next"
--> Select JDK, "Next"
--> Select grails version, "Next"
--> "Finish"
The inplace plugins will automatically be added as modules.
Result: http://d.pr/i/YHkk
The following has worked beautifully for me in a similar situation:
Make sure that your local plugins are referenced correctly:
grails.plugin.location.MyPlugin= "../plugins/MyPlugin"
Start out by creating an empty project - that is, no modules!
Do not import or in any other way "autogenerate" ipr files
Important! Start out with the lower plugins in your "dependency graph"
Click file->New Module
Choose grails module
Point "content root" to the root of your plugin (Module name should be filled in automatically)
Repeat 5-7 until no more plugins
Finish by creating a module for your main app in similar manner as 5-7
This does it for me with many more plugins than two!

Resources