Compile groovy failing without apparent reason

I am running gradle m6 Here is the stack trace:

  • Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:compileGroovy’.

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:71)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:48)

at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)

at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)

at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)

at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)

at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)

at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)

at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)

at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:243)

at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)

at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)

at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)

at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)

at org.gradle.execution.DefaultBuildExecuter.access$300(DefaultBuildExecuter.java:23)

at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:80)

at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)

at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:63)

at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)

at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)

at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)

at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)

at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)

at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)

at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:233)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:217)

at org.gradle.launcher.Main.doAction(Main.java:48)

at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)

at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)

at org.gradle.launcher.exec.Execution.execute(Execution.java:28)

at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)

at org.gradle.launcher.Main.main(Main.java:39)

at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)

at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)

at org.gradle.launcher.GradleMain.main(GradleMain.java:24) Caused by: : Forked groovyc returned error code: 1

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)

at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)

at org.gradle.api.internal.project.AntBuilderDelegate.nodeCompleted(DefaultIsolatedAntBuilder.groovy:140)

at org.gradle.api.internal.tasks.compile.AntGroovyCompiler$_execute_closure1.doCall(AntGroovyCompiler.groovy:66)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:136)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:85)

at org.gradle.util.ConfigureUtil$configure.call(Unknown Source)

at org.gradle.api.internal.project.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.groovy:101)

at org.gradle.api.internal.project.IsolatedAntBuilder$execute.call(Unknown Source)

at org.gradle.api.internal.tasks.compile.AntGroovyCompiler.execute(AntGroovyCompiler.groovy:63)

at org.gradle.api.internal.tasks.compile.IncrementalJavaSourceCompiler.execute(IncrementalJavaSourceCompiler.java:73)

at org.gradle.api.tasks.compile.GroovyCompile.compile(GroovyCompile.java:60)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)

at org.gradle.api.tasks.compile.GroovyCompile_Decorated.invokeMethod(Unknown Source)

at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)

at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:129)

at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:127)

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:63)

… 37 more

A reproducible example would help a lot.

I have a potentially related issue with a sample project at:

Gradle M6 and “Forked groovyc returned error code: 1” when using spock?

Peter,

unfortunately I can’t reproduce it reliably. In my macbook running apple jvm 1.6_26 with groovy-1.8.4 and gradle M6 it all works fine. On the CI box, with SUN JVM 1.6_26 running on ubuntu it fails.

I am willing to do whatever it takes to resolve this issue but I need guidance. One thing to notice is that I am indeed using spock for my tests but the failure I am seeing is during the groovyCompile task; before tests are even looked at and spock should not be in this class path.

Please advice how I can help to figure out this problem.

Ok,

here is what I did. I wrote a little ant script to compile my groovy code outside of gradle and be able to see the compiler output (this is certainly a bug in gradle but it is not related to the cause of my problem although it would have made it easier to find out). It turns out to be a classpath problem; a classnotfoundexception is been thrown by the compiler. The funny thing is that in my macbook the classpath is generated correctly, in ubuntu (CI server) it is not. Namely, I am using org.apache.httpcomponents:httpclient:4.1.2 which adds a transitive dependency on org.apache.httpcomponents:http-core:4.1.2 which is not been included. Here are my dependencies:

dependencies {
   groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.8.4', force: true
 groovy group: 'commons-cli', name: 'commons-cli', version: '1.2'
 groovy group: 'com.h2database', name: 'h2', version: '1.3.158'
 groovy group: 'org.apache.ant', name: 'ant', version: '1.8.2'
 groovy group: 'org.apache.ant', name: 'ant-jsch', version: '1.8.2'
 groovy group: 'com.jcraft', name: 'jsch', version: '0.1.44-1'
 groovy (group: 'com.syncapse', name: 'aws-tools', version: '0.3'){
  exclude module: 'commons-httpclient:commons-httpclient:3.1'
  exclude module: 'javax:mail:mail'
 }
 groovy group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.1.2'
 groovy group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.1.2'
    testCompile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2'
 testCompile group: 'org.spockframework', name:'spock-core', version: '0.5-groovy-1.8'
 testCompile (group: 'org.codehaus.groovy.modules.http-builder', name:'http-builder', version:'0.5.1') {
  exclude module: 'org.codehaus.groovy:groovy'
 }
    testRuntime group: 'cglib', name:'cglib-nodep', version: '2.2.2'
 testRuntime group: 'org.objenesis', name:'objenesis', version: '1.2'
   }

I can work around this by defining the dependency explicitly I guess, but I would like to know what is actually causing this problem.

Thanks.

Erick.

Can you post the exact output of the (failing) Ant Groovy compilation?

Although it may not be the cause of your problem, the ‘groovy’ configuration is just for Groovy itself. Everything else should be added to ‘compile’ or some other configuration.