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()
fetcher.initialize()
fetcher.login()
use(TimeCategory){
fetcher.fetch(5.days.ago)
}
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: org.codehaus.groovy.tools.GroovyStarter
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
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.:
'net.sourceforge.htmlcleaner:htmlcleaner:2.2'
'net.sourceforge.nekohtml:nekohtml:1.9.15'
(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..
Regards,
Alex
Please sign in to leave a comment.