Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent Javadoc from failing gradle build

I’m trying to upload my Library project to jCenter. when I run gradlew install I’m getting the error:

Execution failed for task ':myLibraryProject:javadoc'

I added the code below to my library project:

task androidJavadocs(type: Javadoc) {
    failOnError false // add this line
    source = android.sourceSets.main.java.getSrcDirs()
}

but still I get

"Javadoc generation failed. Generated Javadoc options file..."

I've also tried the accepted answer from here: Generate JavaDocs with Android Gradle plugin

Can I disable the generation of Javadocs, or maybe try to continue with the build although the failure?

like image 719
BoazGarty Avatar asked Feb 16 '16 14:02

BoazGarty


3 Answers

Add these lines to your module build.gradle

tasks.withType(Javadoc) {
      failOnError false
      options.addStringOption('Xdoclint:none', '-quiet')
      options.addStringOption('encoding', 'UTF-8')
      options.addStringOption('charSet', 'UTF-8')
}

Or you can add these:

android.libraryVariants.findAll { variant -> variant.name == 'Release' } each { variant ->
    task("generate${variant.name}Javadoc", type: Javadoc) {
        description "Generates Javadoc for $variant.name."
        source = variant.javaCompile.source
        ext.androidJar = "${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
        classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
    }

    task("bundle${variant.name}Javadoc", type: Zip) {
        description "Bundles Javadoc into zip for $variant.name."
        classifier = "javadoc"
        from tasks["generate${variant.name}Javadoc"]
    }
like image 160
Deep Patel Avatar answered Nov 13 '22 13:11

Deep Patel


I don't recommend disabling JavaDoc generation. Instead, try just running

./gradlew javadoc

This should give you detailed log output about the warnings and errors that are occurring. Fixing these errors should prevent JavaDoc from causing the failure.

like image 3
Suragch Avatar answered Nov 13 '22 15:11

Suragch


In our case, the problem was that we had to remove .gitignore files. They were listed in the file javadoc.options. After that, the task finished successfully.

like image 2
Juan José Melero Gómez Avatar answered Nov 13 '22 14:11

Juan José Melero Gómez