[英]Generate javadoc fail on BuildConfig
I am trying to generate a Javadoc to be saved on my desktop for my project by using a task in the Gradle.我正在尝试通过使用 Gradle 中的任务为我的项目生成一个 Javadoc 以保存在我的桌面上。 This is my code in the build.gradle
:这是我在build.gradle
中的代码:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
task generateJavadoc() {
group "reporting"
description "Generates Javadoc."
}
android.libraryVariants.all { variant ->
def task = project.tasks.create("generate${variant.name.capitalize()}Javadoc", Javadoc) {
title "API Documentation (${project.android.defaultConfig.versionName})"
group "ApiDoc"
description "Generates Javadoc for $variant.name."
destinationDir = reporting.file("/home/<user>/Desktop/myJavaDoc") //optional
// Source files from the variant
source = variant.sourceSets.collect { it.java.sourceFiles }.inject { m, i -> m + i }
// To fix issue: Error: Can not create variant 'android-lint' after configuration ': library: debugRuntimeElements' has been resolved
doFirst {
classpath = project.files(variant.javaCompileProvider.get().classpath.files,
project.android.getBootClasspath())
}
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
exclude "**/R"
exclude "**/R.**"
exclude "**/R\$**"
exclude "**/BuildConfig*"
//exclude "**/sdk/BuildConfig"
exclude '**/*.kt'
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
options.windowTitle = "API Documentation (${project.android.defaultConfig.versionName})"
options.memberLevel = JavadocMemberLevel.PROTECTED
options.linkSource false
options.author = false
failOnError true
}
task.dependsOn "assemble${variant.name.capitalize()}"
generateJavadoc.dependsOn task
}
dependencies {
....
I excluded the BuildConfig, but still, the task fails saying "cannot find symbol class BuildConfig" :我排除了 BuildConfig,但任务仍然失败,说“找不到符号类 BuildConfig” :
error: cannot find symbol import com.name.sdk.BuildConfig;错误:找不到符号导入 com.name.sdk.BuildConfig; ^ symbol: class BuildConfig location: package com.name.sdk ^ 符号:类 BuildConfig 位置:包 com.name.sdk
I already tried to invalidate the cache, clean and rebuild the project without success.我已经尝试使缓存无效,清理并重建项目但没有成功。
I also added as suggested in previous question about the topic:我还按照上一个关于该主题的问题中的建议添加了:
buildConfigField "String", "FOO", ""foo"" buildConfigField "String", "FOO", ""foo""
but even doing so did not solve the problem但即使这样做也没有解决问题
What am I doing wrong?我究竟做错了什么?
Try exclude "**/BuildConfig.java", "**/R.java"
.尝试exclude "**/BuildConfig.java", "**/R.java"
。 And don't options.addStringOption('Xdoclint:none', '-quiet')
twice ...并且不要options.addStringOption('Xdoclint:none', '-quiet')
两次...
instead use options.verbose()
to see what the problem may be.而是使用options.verbose()
来查看问题可能是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.