How do I import an existing Grails 3 (3.0.12) project in IntelliJ 15

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 17:30:49

问题


There's documentation on IntelliJ's website for creating a new Grails project, but importing a project is more sketchy and I cannot get it to work for me.

If I tell IntelliJ to import a new project, and point it to my project directory, it does not recognize it as a Grails project. After the project imports, I can go to the Project menu, right click on the project and go to "add Framework support..." and select Groovy, but IntelliJ still does not recognize my project as a Grails project. For instance, with a new Grails project the run menu would contain a button for running the app that would be decorated with the 3-cups icon synonymous with Grails. I don't get that with my imported project.

Here are the precise steps I'm taking so far:

  1. Start with my fresh unimported project. This is a project and I can build manually using grails compile.
  2. Open IntellliJ 15 UE and select "Import Project"
  3. Select the top level directory containing my build.gradle file and grails-app directory
  4. Select Create project from existing sources
  5. Default project name/location
  6. Select all source directories that were found. These include:
    1. grails-app conf, controllers, domain, init, taglib directories
    2. src/main/groovy
    3. test/unit
  7. At the Libraries screen, go with the default gradle-wrapper option
  8. At the Modules screen go with the 3
  9. "Select project SDK..." I select my 1.8 JDK setup. There's no mention of Grails here.
  10. I see a "No Frameworks detected" message. Should I be able to configure Grails here?
  11. Select finish.

At this point I'm at the IntelliJ editor window with a project that doesn't build. I can go to "Add Frameworks Support" and enable support for Groovy and at that point reference my Grails SDK. But in any case I feel like I shouldn't have to do this. I think IntelliJ ought to be able to detect my Project type and characteristics and that I'm just not configuring it right.

But regardless, my project still doesn't compile inside IntelliJ. I have to build it via the console. Right now none of my Java files located in src/main/groovy compile. All of the imports that references org.springframework are coming back with the "cannot resolve symbol" error.


回答1:


I've had this issue before as well. The only way around it is to:

  • Blow away the intellij project
  • Import from Existing Sources
  • Double click the build.gradle
  • Ensure auto-import on gradle is set to false

Here's the IntelliJ issue related - https://youtrack.jetbrains.com/issue/IDEA-149513



来源:https://stackoverflow.com/questions/34981134/how-do-i-import-an-existing-grails-3-3-0-12-project-in-intellij-15

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!