Search code examples
javagradlethrift

Exclude thrift generated files from javadoc


My build.gradle has the following task which is pretty standard.

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

However I keep getting javadoc lint errors for my thrift generated files. Adding an exclude like exclude '**/gen-java/**' to the end of a task does not seem to work. How can i tell this gradle task to stop looking at my thrift-generated java files?


Solution

  • You could tweak the javadoc task added by the java plugin

    javadoc {
        source = sourceSets.main.allJava.matching {
           exclude '**/gen-java/**'
        }
    }
    

    If you're publishing javadoc & sources jars you might be interested in the nebula.javadoc-jar and nebula.source-jar plugins which save a bit of boilerplate each time in your build scripts