title: Gradle exclude R.java in Android Javadocs when internal classes depend on R.java
body: <p>I am building JavaDoc for an API wherein classes in the API depend on R.java.  I want to build the Javadoc w/o symbol errors referencing the missing R.java file as even when I set <code>failOnError false</code> the build succeeds but our Jenkins job will report the build as Failed when errors occur in successful builds.  The task below will successfully create the javadocs but will report errors during build relating to not finding R.java.  </p>
  
  <pre><code>android.libraryVariants.all { variant -&gt;
  def name = variant.name.capitalize()
  
  task("generate${name}Doclava", type: Javadoc) {
  
      description "Generates Javadoc for $variant.name."
      source = variant.javaCompile.source
      title = null
      // use android.bootClasspath instead of building our own path to android jar
      //ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
      // hardcoded path to generated R.java file to avoid javadoc compile issues
      ext.R = "build/generated/source/r/minSDK15/release"
      classpath += project.files(android.sourceSets.main.java.srcDirs, variant.javaCompile.classpath.files, android.bootClasspath)
      destinationDir = file("${project.docsDir}/${name}/doclava")
      options {
          docletpath = configurations.jaxDoclet.files.asType(List)
          doclet "com.google.doclava.Doclava"
          bootClasspath new File(System.getenv('JAVA_HOME') + "/jre/lib/rt.jar")
          addStringOption "XDignore.symbol.file", "-quiet"
          addStringOption "hdf project.name", "${project.name}"
          addStringOption "federate android", "http://d.android.com/reference"
          addStringOption "federationxml android", "http://doclava.googlecode.com/svn/static/api/android-10.xml"
          addStringOption "federate JDK", "http://download.oracle.com/javase/6/docs/api/index.html?"
          addStringOption "federationxml JDK", "http://doclava.googlecode.com/svn/static/api/openjdk-6.xml"
          addStringOption "templatedir", "${project.docsDir}/${name}/doclava/templates"
          addStringOption "apixml", "${project.docsDir}/${name}/doclava/api-${project.version}.xml"
          addStringOption "since doclava/since/api-1.0.0.xml", "1.0.0"
          addStringOption "apiversion", "${project.version}"
          failOnError false
      }
      // exclude generated files
      exclude '**/BuildConfig.java'
      exclude '**/R.java'
      // exclude internal packages
      exclude '**/internal/**'
      options.addStringOption "apixml", "${project.docsDir}/${name}/doclava/api-${project.version}.xml"
    }
  }
  </code></pre>
  
  <p>Some things I have tried: </p>
  
  <ul>
  <li>Hardcode the path to the generated R.java file and add to the classpath. </li>
  </ul>
  
  <p><code>classpath += project.files(android.sourceSets.main.java.srcDirs, variant.javaCompile.classpath.files, android.bootClasspath, ext.R)</code></p>
  
  <p>This successfully removes the errors so the build succeeds, but the resulting javadoc has empty links to R.*.class in the javadoc.</p>
  
  <ul>
  <li>Remove the <code>exclude '**/R.java'</code> line from the exclude list along with not including the path to R.java in the classpath. </li>
  </ul>
  
  <p>This successfully removes the errors and the build succeeds, but the resulting javadoc has links to R.*.class files.  </p>
  
  <p>It seems the <code>exclude</code> statement is excluding from the classpath and not the javadoc.  Any insight into how to generate a javadoc where classes depend on R.java but don't include R.java in the javadoc output would be deeply appreciated.</p>