问题描述
我想修改 Javadoc 输出,为此我创建了一个自定义 Doclet,它重用默认的 Doclet,并将 DocletEnvironment 包装在包含我的自定义过滤逻辑的代理类中。
注意:使用了 java 11 javadoc API
我的 Doclet 类:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>childItems</key>
<array>
<dict>
<key>childItems</key>
<array/>
<key>choiceDescription</key>
<string>Standalone App</string>
<key>choiceIdentifier</key>
<string>installer_choice_1</string>
<key>choiceIsEnabled</key>
<true/>
<key>choiceIsSelected</key>
<integer>1</integer>
<key>choiceIsVisible</key>
<true/>
<key>choiceSizeInKilobytes</key>
<integer>457609</integer>
<key>choiceTitle</key>
<string>Orpheus</string>
<key>pathsOfActivePackagesInChoice</key>
<array>
<string>file://localhost/Users/username/path/myinstaller.pkg#mystandalone.pkg</string>
</array>
</dict>
<dict>
<key>childItems</key>
<array/>
<key>choiceDescription</key>
<string>Pluto AU plugin</string>
<key>choiceIdentifier</key>
<string>installer_choice_2</string>
<key>choiceIsEnabled</key>
<true/>
<key>choiceIsSelected</key>
<integer>1</integer>
<key>choiceIsVisible</key>
<true/>
<key>choiceSizeInKilobytes</key>
<integer>8831</integer>
<key>choiceTitle</key>
<string>AU</string>
<key>pathsOfActivePackagesInChoice</key>
<array>
<string>file://localhost/Users/username/path/myinstaller.pkg#AU.pkg</string>
</array>
</dict>
<dict>
<key>childItems</key>
<array/>
<key>choiceDescription</key>
<string>Pluto VST3 plugin</string>
<key>choiceIdentifier</key>
<string>installer_choice_3</string>
<key>choiceIsEnabled</key>
<true/>
<key>choiceIsSelected</key>
<integer>1</integer>
<key>choiceIsVisible</key>
<true/>
<key>choiceSizeInKilobytes</key>
<integer>9002</integer>
<key>choiceTitle</key>
<string>VST3</string>
<key>pathsOfActivePackagesInChoice</key>
<array>
<string>file://localhost/Users/username/path/myinstaller.pkg#VST3.pkg</string>
</array>
</dict>
</array>
<key>choiceIdentifier</key>
<string>__ROOT_CHOICE_IDENT_disTRIBUTION_TITLE</string>
<key>choiceIsEnabled</key>
<true/>
<key>choiceIsSelected</key>
<integer>1</integer>
<key>choiceIsVisible</key>
<true/>
<key>choiceSizeInKilobytes</key>
<integer>0</integer>
<key>choiceTitle</key>
<string>myapp</string>
<key>pathsOfActivePackagesInChoice</key>
<array/>
</dict>
</array>
</plist>
我的 DocletEnvironment 代理类:
public class MyDoclet implements Doclet {
private final HtmlDoclet htmlDoclet;
public MyDoclet() {
htmlDoclet = new HtmlDoclet(this);
}
@Override
public boolean run(DocletEnvironment docEnv) {
var proxy = new DocletEnvironmentProxy(docEnv);
return htmlDoclet.run(proxy);
}
//other code...
}
但是当我尝试运行它时,我得到: java.lang.classCastException:类 mypackage.DocletEnvironmentProxy 不能转换为类 jdk.javadoc.internal.tool。 DocEnvImpl(mypackage.DocletEnvironmentProxy 位于加载器 java.net.urlclassloader @3dfc5fb8 的未命名模块中;jdk.javadoc.internal.tool.DocEnvImpl 位于加载器“app”的模块 jdk.javadoc 中)
我发现了与它相关的 bug 和有趣的 comment,上面写着“这不是一种公认的执行自定义的方式”
我花了很多时间寻找自定义方法的“正确”描述,但没有找到与之相关的任何内容。仅来自 Oracle 的一些关于基本 Doclet API 用法的指南。
也许有人知道我在哪里可以找到“正确”的方法或者已经解决了 Doclet 自定义问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)