On 20/09/2010, at 3:06 AM, Romain wrote: > Hi > > I am trying to use gradle and groosh together. > Unfortunately I tried hard, but did not manage to make it work. > > Groosh provides shell commands, and is very usefull. > > Here is the official presentation > http://groovy.codehaus.org/Groosh > > I tried with thisbuilde.gradle > > buildscript{ > repositories { > mavenCentral() > } > > dependencies { > classpath 'org.codehaus.groovy.modules:groosh:0.3.6' > } > } > > repositories { > mavenCentral() > } > > defaultTasks 'help' > > task help{ > def org.codehaus.groovy.groosh.builtin.Dir toto //No problem so the class > is in the classpath. > new groosh.Groosh() //throw java.lang.ClassNotFoundException: > org.codehaus.groovy.groosh.builtin.Dir > > } > > And this is the output : > > FAILURE: Build failed with an exception. > > * Where: > Build file '/home/romain/mercurial/daiki-control2/build.gradle' > > * What went wrong: > A problem occurred evaluating root project 'daiki-control2'. > Cause: java.lang.ExceptionInInitializerError (no error message) > > * Try: > Run with -S option to get the full (very verbose) stacktrace. > > * Exception is: > org.gradle.api.LocationAwareGradleScriptException: Build file > '/home/romain/mercurial/daiki-control2/build.gradle' > A problem occurred evaluating root project 'daiki-control2'. > at > org.gradle.groovy.scripts.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:51) > at > org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127) > at > org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38) > at > org.gradle.configuration.DefaultProjectEvaluator.evaluate(DefaultProjectEvaluator.java:38) > at > org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:491) > at > org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:69) > at > org.gradle.api.internal.project.ProjectInternal$evaluate.call(Unknown Source) > at > org.gradle.configuration.BuildConfigurer$_closure1.doCall(BuildConfigurer.groovy:41) > at $Proxy6.execute(Unknown Source) > at > org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:467) > at > org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:462) > at org.gradle.api.Project$allprojects.call(Unknown Source) > at > org.gradle.configuration.BuildConfigurer.process(BuildConfigurer.groovy:48) > at > org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:136) > at > org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:107) > at > org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:75) > at org.gradle.launcher.Main.execute(Main.java:93) > at org.gradle.launcher.Main.main(Main.java:42) > at org.gradle.launcher.GradleMain.main(GradleMain.java:49) > Caused by: java.lang.ExceptionInInitializerError: null > at > build_gradle_5f59d4a892719914e5611d5054461359$_run_closure2.class$(/home/romain/mercurial/daiki-control2/build.gradle) > at > build_gradle_5f59d4a892719914e5611d5054461359$_run_closure2.$get$$class$groosh$Groosh(/home/romain/mercurial/daiki-control2/build.gradle) > at > build_gradle_5f59d4a892719914e5611d5054461359$_run_closure2.doCall(/home/romain/mercurial/daiki-control2/build.gradle:19) > at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61) > at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:31) > at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:407) > at > org.gradle.api.internal.project.AbstractProject.task(AbstractProject.java:914) > at > org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158) > at > org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93) > at > org.gradle.api.internal.project.DefaultProject_Decorated.invokeMethod(Unknown > Source) > at > org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.groovy:68) > at > build_gradle_5f59d4a892719914e5611d5054461359.run(/home/romain/mercurial/daiki-control2/build.gradle:17) > at > org.gradle.groovy.scripts.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:49) > ... 18 common frames omitted > Caused by: java.lang.ClassNotFoundException: > org.codehaus.groovy.groosh.builtin.Dir > at java_lang_Class$forName.call(Unknown Source) > at > groosh.Groosh$_registerInternalProcesses_closure2.doCall(Groosh.groovy:119) > at groosh.Groosh.registerInternalProcesses(Groosh.groovy:118) > at groosh.Groosh$registerInternalProcesses.callStatic(Unknown Source) > at groosh.Groosh.<clinit>(Groosh.groovy:76) > ... 31 common frames omitted > > BUILD FAILED > > Total time: 3.888 secs > > > I looked into the source code of Groosh : > http://kenai.com/projects/groovy-groosh/sources/subversion/show/org.codehaus.groovy.groosh/src/main/groovy/groosh > > And there is some strange classloading. Is it possible that Groosh and Gradle > interfere because they use two differents way of to load classes?
It looks like Groosh is using Class.forName(String) to load the class. This doesn't work in Groovy if the calling class (Groosh) is in a different classloader to the Groovy runtime, which is the case in Gradle. This is a Groovy problem. The fix would involve changing either Groovy to fix the problem, or Groosh to use Class.forName(String, boolean, ClassLoader) instead of forName(String). -- Adam Murdoch Gradle Developer http://www.gradle.org CTO, Gradle Inc. - Gradle Training, Support, Consulting http://www.gradle.biz
