[英]Right way to exclude R.java from javadoc using gradle
I'm generating javadoc for my Android project with this gradle task: 我正在使用这个gradle任务为我的Android项目生成javadoc:
android.applicationVariants.all { variant ->
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())
exclude '**/BuildConfig.java'
exclude '**/R.java'
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.linksOffline("http://d.android.com/reference","${android.sdkDirectory}/docs/reference");
options {
failOnError false
}
destinationDir = file("${project.projectDir}/javadoc")
}
}
It excludes R.java
, so i don't get R.html in output dir. 它排除了
R.java
,因此我没有在输出目录中获得R.html。 However, i'm getting very annoying errors cannot find symbol class R
in the process of generating doc for my usual java classes, in the line import com.mypackagename.R
. 但是,我在非常烦人的错误
cannot find symbol class R
,在为我常用的java类生成doc的过程中,在行import com.mypackagename.R
。 I use common android things like R.string.string_res
, so i can't remove this import. 我使用常见的Android东西,如
R.string.string_res
,所以我无法删除此导入。 Is there a proper way to include symbol R
to index, but not include it to a javadoc, or, at least, simply to supress this error? 是否有一种正确的方法将符号
R
包含在索引中,但不包含在javadoc中,或者至少只是为了抑制此错误?
You can try to add next two lines to your code: 您可以尝试在代码中添加下两行:
classpath += files("build/generated/source/r/${variant.flavorName}/release")
classpath += files("build/generated/source/buildConfig/${variant.flavorName}/release")
But in this case your task should depend on one of the tasks which generates R classes. 但在这种情况下,您的任务应该依赖于生成R类的任务之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.