Importing existing Grails application into Intellij

Hi all,

First of all I have to admit that I am fairly new to Grails & Groovy. I have an existing project that was created from command line using the grails create-app command.
I've also added a few dependencies into the BuildConfig.groovy file. It looks like this:

dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.

        // runtime 'mysql:mysql-connector-java:5.1.20'
        compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
        compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.2'
        compile 'net.sourceforge.nekohtml:nekohtml:1.9.15'

I also have a few classes (lets say FundFetcher, FundParameter) inside the <ROOT>/src/groovy directory, which reference classes in the jars above. In addition to that, I have a groovy script which instantiate class A, and invoke some methods on it. This script lives inside <ROOT>/src/groovy

import groovy.time.TimeCategory
import org.isolution.wrap.FundFetcher

def fetcher = new FundFetcher()

The first problem is that I'm not quite sure on how I should import this grails project properly in Intellij. I'm coming from Maven, where to import a Maven project into Intellij, I just need to open the root pom file. So what I did to import this Grails project was:
1. Create new project.
2. Point my project to the existing Grails directory, and set the type as 'Grails' module.

Now I want to run my groovy script. But I got the following error:

Exception in thread "main" java.lang.ClassNotFoundException:
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(

Looking at my module dependency, I have :
1.  1.6 (java)
2. Module source
3. grails-2.2.0
4. Grails User Library
5. <project name>-grailsPlugin

When I look at grails-2.2.0, it clearly has groovy jar inside it:
Classes - /Users/foo/.gvm/grails/current/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.0.5.jar

The other thing is.. shouldnt the list above include the extra dependencies that I have stated in my BuildConfig.groovy file, i.e.:


(and hopefully all the transient dependencies that are required by them)

Oh .. I am running Intellij 12.0.1, build 123.94

Thanks in advance for the help..



Please sign in to leave a comment.