Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

android - How to skip autogenerated classes from Javadoc using gradle

In an Android library project I use Gradle script to generate Javadocs:

task androidJavadocs(type: Exec, dependsOn: buildJavadocsClasspath) {
  doFirst {

    executable = 'javadoc'

    args = [
        '-classpath', javadocsClasspath,
        '-sourcepath', './src/main/java',
        '-subpackages', 'com.example.myproject',
        '-d', javadocsDestinationDir,
        '-exclude', 'com.example.myproject.internal',
        '-doctitle', project.getName() + " " + VERSION_NAME + " API",
        '-windowtitle', POM_NAME + " API",
        '-link', "http://docs.oracle.com/javase/8/docs/api/",
        '-Xdoclint:none',
        '-quiet'
    ]
  }
}

The problem is that Javadoc returns warnings (Java 8) or errors (Java 11) when generating javadocs for classes that reference autogenerated classes like BuildConfig or DaggerMyClientComponent

./src/main/java/com/example/myproject/MyClient.java:13: error: cannot find symbol
import com.example.myproject.internal.DaggerMyClientComponent;
                                              ^
  symbol:   class DaggerMyClientComponent
  location: package com.example.myproject.internal
./src/main/java/com/example/myproject/internal/storage/client/SdkVersionStorage.java:9: error: cannot find symbol
import com.example.myproject.BuildConfig;
                                     ^
  symbol:   class BuildConfig
  location: package com.example.myproject
./src/main/java/com/example/myproject/internal/utils/UserAgentHeader.java:8: error: cannot find symbol
import com.example.myproject.BuildConfig;
                                     ^
  symbol:   class BuildConfig
  location: package com.example.myproject

One thing that I don't understand is that two errors come from internal classes that are already excluded from javadoc with the "exclude" argument.

On top of that, I don't see an option to fix or suppress those errors. Adding an exclude rule like com.example.myproject.internal.DaggerMyClientComponent doesn't work.

Using Android Studio to generate Javadocs is not an option, I need to use a script that can be used in CI (Bitrise).

question from:https://stackoverflow.com/questions/65842537/how-to-skip-autogenerated-classes-from-javadoc-using-gradle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...