I just installed Eclipse KEPLER and am trying to bring all my projects back in from github. The projects are all gradle projects so my procedure is pretty much...
Everything seems to be fine, except I can't "Run As, Groovy Script" the scripts within the project. When I try, the console spews...
java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.getMethod0(Class.java:2764)
at java.lang.Class.getMethod(Class.java:1653)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:99)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:128)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
. Interestingly enough, I can "Run As, Java Application" without issue. Its definitely a Groovy project as it has the G in the project icon. What does the stacktrace mean and how do I overcome it?
The repository that is causing my issue is at https://github.com/robertkuhar/StackOverflow
My gradle is 1.11 on groovy 1.8.6 in eclipse kepler with the Groovy-Eclipse plug-in Version: 2.8.0.xx-20130703-1600-e43-RELEASE
Looks like when creating the "Groovy Script" run configuration, the main class is set to org.codehaus.groovy.tools.GroovyStarter
instead of the script you are intending to run. Replacing it with the Groovy class/script you would like to run sorts the issue.
Update
After some digging the way to solve the issue is:
build.gradle
eclipse {
project {
natures.add 'org.eclipse.jdt.groovy.core.groovyNature'
}
classpath {
file {
withXml {
Node node = it.asNode()
node.appendNode('classpathentry',[exported:"true",kind:"con",path:"GROOVY_SUPPORT"])
node.appendNode('classpathentry',[exported:"true",kind:"con",path:"GROOVY_DSL_SUPPORT"])
}
}
}
}