5

Problem:

I want to add some JavaDoc that is inherited from the Android SDK. However Gradle JavaDoc doesn't seem to be able to find the Android source code and thus ignores the {@inheritDoc} tag.

Example class

public class MyCursor implements android.database.Cursor {
  /**
   * {@inheritDoc}
   */
  public int getCount() {
    return 42;
  }

  // ... All other interface methods
}

Gradle task

def javadocTask = task("javadoc${variant.name.capitalize()}", type: Javadoc) {
    description "Generates Javadoc for $variant.name."
    group 'Docs'
    source = variant.javaCompile.source
    source files("${android.sdkDirectory}/sources/${android.compileSdkVersion}")
    ext.androidJar = files(plugins.findPlugin("com.android.library").getBootClasspath())
    classpath = files(variant.javaCompile.classpath.files) + ext.androidJar
    include 'my/package/**'
    exclude 'my/package/internal/**'
    exclude '**/BuildConfig.java'
    exclude '**/R.java'
}

Some speculations:

  • Android SDK uses @hide a lot which crashes JavaDoc generation.

  • using exclude also seems to prevent inheriting from those classes.

Christian Melchior
  • 19,978
  • 5
  • 62
  • 53
  • Are you still seeing this? This user had something similiar: http://stackoverflow.com/questions/25266023/how-to-accomplish-inheriting-javadoc-comments-from-jdk-with-gradle-javadoc-task – Jared Burrows Apr 10 '16 at 20:25

0 Answers0