title: Generate JavaDocs with Android Gradle plugin
body: <p>How can I generate JavaDocs for an Android project using the new Gradle build system?</p>
  
  <p>Here is what I have come up with but it doesn't work.</p>
  
  <pre><code>task generateJavadoc(type: Javadoc) {
      source = android.sourceSets.main.java.srcDirs
      ext.cp = android.libraryVariants.collect { variant -&gt;
          variant.javaCompile.classpath.files
      }
      classpath = files(ext.cp) 
  }
  </code></pre>
  
  <p>The main problem is that I do not get the appropriate android.jar on the classpath so some of the links in the JavaDocs are not resolved. I have to find a way to get all the necessary jars on the classpath.</p>
  
  <p>Another problem with the approach I took is it collects the classpaths for all the build variants, rather than selecting one.</p>