Inherit JavaDoc from Android SDK using Gradle

Problem:

I want to add a JavaDoc that is inherited from the Android SDK. However, Gradle JavaDoc does not seem to be able to find the Android source code and thus ignores the {@inheritDoc} tag.

Class 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 assumptions:

  • The Android SDK uses @hide lot, which causes JavaDoc to fail to generate.

  • Using exclude also seems to prevent inheritance from these classes.

+5
source share

All Articles