atreides322
atreides322

Reputation: 159

Grails Dependencies not Added as Libraries to IntelliJ IDEA

I am running into an issue when I import a Grails project into IntelliJ IDEA. None of the dependencies are added as libraries. Everything out there says that Tools -> Grails -> Synchronize Grails Settings should be sufficient to configure the project. However, when I run that command, I get the following error:

"C:\Program Files\Java\jdk1.7.0_75\bin\java" -Dgrails.home=C:\Users\req88100\.gvm\grails\2.4.4 -Dbase.dir=C:\Users\req88100\Projects\COI_2.4.4 "-Dtools.jar=C:\Program Files\Java\jdk1.7.0_75\lib\tools.jar" -Dgroovy.starter.conf=C:\Users\req88100\.gvm\grails\2.4.4/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -Djline.WindowsTerminal.directConsole=false -Dfile.encoding=windows-1252 -classpath C:\Users\req88100\.gvm\grails\2.4.4\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.3.7.jar;C:\Users\req88100\.gvm\grails\2.4.4\dist\grails-bootstrap-2.4.4.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf C:\Users\req88100\.gvm\grails\2.4.4/conf/groovy-starter.conf "idea-print-project-settings -plain-output"
|Loading Grails 2.4.4
|Configuring classpath
|Running pre-compiled script
|Script 'IdeaPrintProjectSettings' not found, did you mean:
   1) SetProxy_
   2) CreateMultiProjectBuild_
   3) Interactive
   4) ClearProxy_
   5) UrlMappingsReport
Please make a selection or enter Q to quit:

I can manually add the jars to the module as libraries, but this is cumbersome. Without it, none of the code completion works correctly. That project is working correctly because grails run-app runs just fine.

This is with IntelliJ IDEA 14.1.3 on Windows 7 and several different version of Grails 2.x.x. I've tried the command manually is both Cygwin and with a standard Windows Command Prompt. Both yield that same results as IntelliJ IDEA.

There are very few Google results for either idea-print-project-settings or IdeaPrintProjectSettings. I am not sure where this script is supposed to come from.

How do I configure IntelliJ IDEA to properly pull the libraries into the module configuration?

Upvotes: 4

Views: 5944

Answers (5)

jesus tepec
jesus tepec

Reputation: 111

I resolved this problem by creating a scripts directory in usernamefolder/.grails/

Upvotes: 2

Felipe Costa
Felipe Costa

Reputation: 21

I've just come across with this issue on Windows 10 and I was finally able to solve it after a few attempts. I just did the following:

  1. Searched for the IdeaPrintProjectSettings.groovy script.

  2. Copied it to my actual Grails scripts directory that was something like ...\Grails2.2.2\scripts or whatever IntelliJ was pointing to at the time.

  3. Synchronized my Grails projects again.

The issue here, as it was previously pointed out, is that IntelliJ context for Grails is looking for this script in another directory. In my case, IntelliJ was looking in the Grails cache.

Upvotes: 2

vitran
vitran

Reputation: 5

I solved the problem by adding IdeaPrintProjectSettings.groovy in USER-HOME.grails\scripts\IdeaPrintProjectSettings.groovy (i'm using IDEA version2016.3) OR USER-HOME.grails\IdeaPrintProjectSettings.groovy It depends on your IDEA version.

(sorry I don't know how to attach this file in stackoverflow for someone who needs it).

Upvotes: 0

TekOps
TekOps

Reputation: 186

If you are getting the "Error executing script IdeaPrintProjectSettings:" inside intellij try this on linux:

  1. go to command prompt in home directory cd to project root directory (e.g., cd $HOME/IdeaProjects/Simulator01)
  2. run the 'grails' command
  3. at the prompt once at the grails prompt run "refresh-dependencies" and hit [ENTER]
  4. once that completes without error you should be able to do the next step:
  5. at the grails prompt run 'idea-print-project-settings' and get the output without error.

Now try the project rebuild in intellij, might have to invalidate cache first.

Good luck, David

Upvotes: 0

atreides322
atreides322

Reputation: 159

Understanding how Grails resolves Gant scripts really helps:

http://grails.github.io/grails-doc/2.3.x/guide/commandLine.html

Grails searches in the following directories for Gant scripts to execute:

  • USER_HOME/.grails/scripts
  • PROJECT_HOME/scripts
  • PROJECT_HOME/plugins/*/scripts
  • GRAILS_HOME/scripts

The problem seems that IntelliJ IDEA is automagically providing this Gant script, but putting the script in the wrong spot.

Using VisualVM, here are the user directories:

user.dir=C:\Users\%USERNAME%
user.home=\\SOME\network\drive\%USERNAME%

So even though Cygwin, and so it seems IntelliJ IDEA, treats C:\Users\%USERNAME% as the home directory, the Windows Group Policy maps it to a network share and Java uses this value as user.home.

Looking in C:\Users\%USERNAME%\.grails\scripts, I was able to find the script. I copied it to \\SOME\network\drive\%USERNAME%\.grails\scripts and then Grails recognized the script and IntelliJ IDEA was able to configure itself properly.

Upvotes: 3

Related Questions