Groovydoc fails in Gradle 2.0-rc-1

When I upgraded our build to Groovy 2.0, I fund that some (but not all) of the Groovydoc tasks fail with the exception below. I haven’t found a clear pattern yet, but it is consistent.

As the Gradle distribution contains the ‘groovy-all’ jar, it should be able to resolve the class from there and not require that it is included in the project classpath.

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':zone:groovydoc'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        ... snipped a lot of irrelevant stack frames
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: java.lang.NoClassDefFoundError: groovy/util/AntBuilder
        at java_lang_ClassLoader$loadClass.call(Unknown Source)
        at org.gradle.api.internal.project.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.groovy:106)
        at org.gradle.api.internal.project.IsolatedAntBuilder$execute$1.call(Unknown Source)
        at org.gradle.api.tasks.javadoc.AntGroovydoc.execute(AntGroovydoc.groovy:55)
        at org.gradle.api.tasks.javadoc.Groovydoc.generate(Groovydoc.java:75)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:570)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:553)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 66 more
Caused by: java.lang.ClassNotFoundException: groovy.util.AntBuilder
        ... 79 more

Here is an example to reproduce - paste these snippets into a ‘build.gradle’ file in empty directory and run gradle.

This works:

file('src/main/groovy').mkdirs()
file('src/main/groovy/Test.groovy').text = 'class Foo {}'
  apply plugin: 'groovy'
dependencies {
    compile "org.codehaus.groovy:groovy-all:2.3.3" // WORKS
}
defaultTasks 'build', 'groovydoc'

This doesn’t:

file('src/main/groovy').mkdirs()
file('src/main/groovy/Test.groovy').text = 'class Foo {}'
  apply plugin: 'groovy'
dependencies {
    compile "org.codehaus.groovy:groovy:2.3.3" // NoClassDefFoundError: groovy/util/AntBuilder
}
defaultTasks 'build', 'groovydoc'

I shouldn’t have to add tool dependencies to my application classpath, but even this doesn’t work:

file('src/main/groovy').mkdirs()
file('src/main/groovy/Test.groovy').text = 'class Foo {}'
  apply plugin: 'groovy'
dependencies {
    compile "org.codehaus.groovy:groovy:2.3.3", // NoClassDefFoundError: groovy/util/AntBuilder
            "org.codehaus.groovy:groovy-ant:2.3.3" // groovy.util.AntBuilder is here, groovydoc is dragged in transitively
}
defaultTasks 'build', 'groovydoc'

Unfortunately we ran out of time and had to release Groovy 2.0 with this as a known issue. I’ve raised GRADLE-3116. Hopefully we can find a suitable workaround for 2.1.

Thanks for the report.

Thanks for acknowledging. For now we’ve patched it by adding a rule to resolve all ‘groovy’ dependencies to ‘groovy-all’, so it is not a showstopper. I suspect there may be a more elegant workaround, but not really inclined to dig.

Congratulations for the release! Time to take some well deserved break :slight_smile:

Cool.

Congratulations for the release! Time to take some well deserved break :slight_smile:

No rest for the wicked :wink:

Fixed in 2.1.