Unable to import Grails project

已回答

I am running IntelliJ IDEA 2016.3.2, Build #IU-163.10154.41, built on December 21, 2016.  The Grails plugin is installed and enabled:

 

But I have yet to see the dialog box where you get asked for a Grails SDK.  I have created a new Grails project in IDEA, so it definitely knows about Grails.  And I have restarted IDEA, but that has not made any difference.

I figured out that I can't import from my Eclipse external model, even though it's an Eclipse project.  That route never got me to the frameworks dialog box at all.  I found that if I select Create project from existing sources, I will eventually get to the frameworks selection screen, but this is what it shows:

Of course, once I click Finish, IDEA does not recognize the project as a Grails project.

Is there any way to mark it as a Grails project at this point?  Or any idea how to make the import work as expected?

0

What Grails version do you use? For Grails 3.x you just import build.gradle file in IDEA: https://www.jetbrains.com/help/idea/2016.3/getting-started-with-grails-3.html.

For Grails 2 please refer to https://www.jetbrains.com/help/idea/2016.3/getting-started-with-grails-1-2.html.

0

Thanks for your quick reply, Serge.  Since I'm obviously not creating a new project, can you please explain what it means by adding a module to an existing project?  I would think that what I am doing is importing the existing project, so what module am I creating?  Do I have to make up a fictitious module to convince IDEA to import the existing project? 

0

Since you can't import build.gradle, I'm assuming that you are using Grails 2? Is that correct?

0

Yes, sorry, I forgot to say that.

0

In this case IDE should recognize the structure automatically: https://www.jetbrains.com/help/idea/2016.3/creating-grails-application-from-existing-code.html.

Probably there is something nonstandard in your project so that IDE cannot recognize it as a Grails project.

In the recent IDEA versions there is no longer a Grails module or Grails facet configuration needed, IDE recognizes the project being a Grails project when there is a Grails library in the dependencies.

I suggest creating a new Grails 2 project using the wizard, then you will see a library for Grails, move it to Global libraries:

Then try adding this library to the dependencies of your modules in the existing project: http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html.

0

The problem at this point may be my inexperience with IDEA, but I don't have what you have, and I'm not sure how to get it.  Is this the new module that I'm supposed to create?

0

Did you create a new Grails 2 project following the wizard steps?

0

That must be the problem.  I created a Grails 3.1.9 project.  I'll have to try installing Grails 2 tomorrow.

Many thanks for walking me through this, Serge.  I'll let you know how it goes.

0

FYI, there doesnt seem to be any way to import a fresh grails 3.3.8 project into intellij ultimate either.  It doesnt recognise it as grails, nor does it pickup that its gradle. I can create a new grails project from scratch within intellij, but it doesnt seem to want to pickup existing projects created with a simple "grails create-app".

0

Did you try to open build.gradle file?

0

It doesnt recognise it if you open a grails apps folder. It half recognises it if you open the settings.gradle in the folder above. This used to work. Now When I import the same project, or a new one, it only shows the app, not the module it depends on in the grails view. 

This is what I did:

$ cd myproj

$ grails create-app myapp

$ grails create-plugin myplug

Create settings.gradle with:

    include ":myapp", ":myplug"

 

$ cd myapp

edit build.gradle with:

 

grails {

   exploded = true

    plugins {

        compile project(':myplug')

    }

}

 

Now I should just be able to import the settings.gradle. This half works. The project is imported, and I can run it, it finds the plugin's classes, but the plugin module is missing from grails view - it only shows the app.  It should show both (as it used to), as now I cant navigate to the plugins files in the grails view (which worked in the last version)

0

Here's what I see after following your steps and importing settings.gradle.

Plugin module is visible and is currently selected in Project View:

The plugin is visible in Grails View as well:

Please reach our support and attach screencast or screenshots and describe what was expected.

0

请先登录再写评论。