1/**
2 * A helper gradle file to generate documentation using doclava.
3 * Include this file using `apply from` in the gradle build file. This will generate new tasks
4 * "javadoc<Variant>" which will generate javadocs for that target.
5 */
6
7import com.android.internal.doclava.DoclavaJavadocOptionFileOption
8
9def DOCSDIR = "$rootDir/frameworks/opt/setupwizard/tools/docs"
10
11android.libraryVariants.all { variant ->
12    if (variant.buildType.name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
13        return; // Skip debug builds.
14    }
15    def suffix = variant.name.capitalize()
16
17    def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
18        title = null
19        source variant.javaCompile.source
20        classpath = files(variant.javaCompile.classpath.files) + files(
21                "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
22        exclude '**/R.java'
23        exclude '**/R.html', '**/R.*.html'
24        exclude '**/BuildConfig.java'
25
26        options {
27            bootClasspath = files(android.getBootClasspath()).asType(List)
28            doclet = 'com.google.doclava.Doclava'
29            docletpath = files("$DOCSDIR/doclava.jar", "$DOCSDIR/jsilver.jar").asType(List)
30
31            addOption(new DoclavaJavadocOptionFileOption('offlinemode'))
32            addOption(new DoclavaJavadocOptionFileOption('federate'))
33                    .setValue(['Android', 'http://developer.android.com'])
34
35            addOption(new DoclavaJavadocOptionFileOption('federationapi'))
36                    .setValue(['Android', file("$DOCSDIR/android-22.txt").canonicalPath])
37            addStringOption('templatedir',
38                    file("$rootDir/external/doclava/res/assets/templates-sdk").canonicalPath)
39        }
40
41        dependsOn(variant.assemble)
42
43        doLast {
44            println "Docs generated: file://${project.docsDir}/javadoc/reference/index.html"
45        }
46    }
47}
48