Gradle task groovyDoc failing with NoClassDefFoundError

OK, here’s a reduction to two files:

‘build.gradle’

apply plugin: ‘java’

apply plugin: ‘groovy’

sourceCompatibility = 1.7

repositories {

jcenter()

}

dependencies {

compile ‘org.codehaus.groovy:groovy-all:2.3.7’

}

groovydoc {

// Create GroovyDoc for Groovy + Java classes

source = sourceSets.main.groovy + sourceSets.main.java

}

‘RPCClient.java’:

import java.io.IOException;

import java.io.EOFException;

import java.net.SocketException;

public class RPCClient {

public void a() throws IOException {

throw new IOException("");

}

public void b() throws Exception {

try {

a();

} catch (EOFException | SocketException e) {

e.printStackTrace();

}

}

}

‘gradle groovydoc’ with Gradle 2.1 produces the error.

Thanks Sean, much appreciated. Apparently Groovydoc requires Jansi to print error messages. (In the code above it seems to trip over the multi-catch clause.) However, jansi is only listed as an optional dependency in the groovy-all POM, and therefore transitive dependency resolution will not include it automatically. This answer on the Groovy mailing list has the details: http://groovy.329449.n5.nabble.com/jansi-is-a-hard-dependency-in-groovy-all-td5719856.html#a5719864

It’s worthwhile to investigate whether Gradle’s Groovydoc task can/should compensate for this automatically. I’ve raised GRADLE-3174 for this.