title: How generate javadoc with Gradle?
body: <p>I would like generate javadoc out of aar lib file, but my actual task not work and finish with error. I'm somewhat lost with gradle.</p>
  
  <p>Where should generate javadocs?</p>
  
  <pre><code>android.libraryVariants.all { variant -&gt;
  
      // This part is for change AAR location
      variant.outputs.each { output -&gt;
          def outputFile = output.outputFile
          if (outputFile != null &amp;&amp; outputFile.name.endsWith('.aar')) {
              def fileName = "${archivesBaseName}-${version}.aar"
              output.outputFile = new File("$rootProject.projectDir/build/generated-aar", fileName)
          }
      }
  
      // Here generate tasks for variant to generate Javadocs
      task "generate${variant.name.capitalize()}Javadoc"(type: Javadoc) {
          description = "Generates javadoc for build $variant.name"
          destinationDir = new File("$rootProject.projectDir/build/generated-javadoc", variant.baseName)
  
          // add SDK classes
          source = variant.javaCompiler.source
  
          ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
          classpath = files(variant.javaCompiler.classpath.files) + files(ext.androidJar)
  
          ext.androidDoc = "${android.sdkDirectory}/docs/reference"
  
          options.linksOffline("http://d.android.com/reference", ext.androidDoc)
          options.links("http://docs.oracle.com/javase/7/docs/api/")
          options.links("http://d.android.com/reference/")
  
          exclude '*BuildConfig.java'
          exclude '*R.java'
          exclude '*impl*'
          exclude '*tests*'
      }
  }
  </code></pre>