[GRADLE-3116] Groovydoc fails with java.lang.NoClassDefFoundError: groovy/util/AntBuilder when not using groovy-all Created: 01/Jul/14  Updated: 15/Jul/14  Resolved: 15/Jul/14

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.1-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: René Gröschke (Inactive)
Resolution: Fixed Votes: 0

Known Issue Of:
2.0

 Description   

As of Gradle 2.0, the Groovydoc task fails if only the `groovy` library is on the compile classpath. If the `groovy-all` library is used the Groovy task does not fail. Also, adding the `groovy-ant` library to the compile classpath fixes the problem.



 Comments   
Comment by Gradle Forums [ 01/Jul/14 ]

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'

Comment by Perryn Fowler [ 04/Jul/14 ]

While this is being investigated, the following seems to work as a workaround

configurations {
  groovyall
}
dependencies {
   groovyall "org.codehaus.groovy:groovy-all:2.3.3"
}
groovydoc.groovyClasspath = configurations.groovyall
Generated at Wed Jun 30 12:40:25 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.