Javadoc does not recognize doctitle option/flag

走远了吗. 提交于 2019-12-07 07:30:46

问题


I am running javadoc with my doclet through gradle, and when I am running my javadoc/doclet task, I am receiving the next error:

error - invalid flag: -doctitle

And after that, the next usage table

usage: javadoc [options] [packagenames] [sourcefiles] [@files]
-overview <file>          Read overview documentation from HTML file
-public                   Show only public classes and members
-protected                Show protected/public classes and members (default)
-package                  Show package/protected/public classes and members
-private                  Show all classes and members
-help                     Display command line options and exit
-doclet <class>           Generate output via alternate doclet
-docletpath <path>        Specify where to find doclet class files
-sourcepath <pathlist>    Specify where to find source files
-classpath <pathlist>     Specify where to find user class files
-exclude <pkglist>        Specify a list of packages to exclude
-subpackages <subpkglist> Specify subpackages to recursively load
-breakiterator            Compute 1st sentence with BreakIterator
-bootclasspath <pathlist> Override location of class files loaded
                          by the bootstrap class loader
-source <release>         Provide source compatibility with specified release
-extdirs <dirlist>        Override location of installed extensions
-verbose                  Output messages about what Javadoc is doing
-locale <name>            Locale to be used, e.g. en_US or en_US_WIN
-encoding <name>          Source file encoding name
-quiet                    Do not display status messages
-J<flag>                  Pass <flag> directly to the runtime system

Does anyone have an idea from why Javadoc is not accepting that flag? In theory, I am running the javadoc from tools.jar from jdk1.6. I thought it was something that javadoc would always accept that doctitle option. Thank you for your time!

EDIT: That doctitle option is part of the Standard Doclet, so it looks like I am not being able to access the Standard Doclet options.


回答1:


EDITED:

Got it! The problem was in the Doclet itself. I was not extending the Standard Doclet ("public class MyDoclet extends Standard {"), so the flags from the Standard Doclet were not available (and doctitle is part of the flags of the Standard Doclet).

Thanks to Paulo for making me "re-think" my answer :-)




回答2:


You can set the task local variable 'title' to empty on the javadoc task

task javadocTask(type: Javadoc) {
    title = ""
    //Other items like source and options
}

Or alternatively

javadocTask.title = ""

Why

Gradle sets the local variable 'title' in the javadoc task that is then used to populate the -doctitle and -windowtitle arguments. If it is empty, they will not populate the fields and you can avoid this problem.

Interestingly, title seems to be populated by the java plugin, so if you are running javadoc from a project that does not have java (say as an aggregator project) you will not run into this problem, but if you move the javadoc generation into a java project you will.

Note: title = "" and title = null both work on the newest version of gradle. This is likely because gradle knows both "" and null are empty. However, on older versions of gradle, there are reports of using null not working, but an empty string did.



来源:https://stackoverflow.com/questions/11034326/javadoc-does-not-recognize-doctitle-option-flag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!