简体   繁体   English

将 favicon 设置为 maven-javadoc-plugin 生成的 javadoc 文件

[英]set favicon to maven-javadoc-plugin generated javadoc file

I can set window title using following code in " maven-java doc-plugin ".我可以在“ maven-java doc-plugin ”中使用以下代码设置窗口标题。

<configuration>
     <windowtitle>name</windowtitle>
</configuration>

but I cannot set "favicon" to my java doc但我无法将“favicon”设置为我的 Java 文档

I saw your question and found the following is my observation.我看到了你的问题,发现以下是我的观察。

  1. First of all, there isn't any ready-made solution in maven-javadoc-plugin which will allow you to add a custom favicon.ico in your Javadoc.首先, maven-javadoc-plugin没有任何现成的解决方案可以让您在 Javadoc 中添加自定义 favicon.ico。

But the good thing is:但好处是:
I also found out that in maven-javadoc-plugin you can modify it to use your custom doclet implementation for generating Javadocs.我还发现在maven-javadoc-plugin您可以修改它以使用您的自定义doclet实现来生成 Javadoc。

Now, what is doclet ( More details here )?现在,什么是doclet这里有更多详细信息)?

From the above link,从上面的链接,

Javadoc Doclets You can customize the content and format of the Javadoc tool's output by using doclets . The Javadoc tool has a default "built-in" Javadoc Doclets You can customize the content and format of the Javadoc tool's output by using doclets Javadoc Doclets You can customize the content and format of the Javadoc tool's output by using . The Javadoc tool has a default "built-in" . The Javadoc tool has a default "built-in" doclet , called the standard doclet , that generates HTML-formatted API documentation. You can modify or subclass the standard . The Javadoc tool has a default "built-in" doclet , called the standard doclet , that generates HTML-formatted API documentation. You can modify or subclass the standard , that generates HTML-formatted API documentation. You can modify or subclass the standard doclet , or write your own doclet to generate HTML, XML, MIF, RTF or whatever output format you'd like , that generates HTML-formatted API documentation. You can modify or subclass the standard doclet , or write your own doclet to generate HTML, XML, MIF, RTF or whatever output format you'd like

So basically you can customize what your Javadoc can generate, you can use more information on customizing the doclet in below mentioned links.所以基本上你可以自定义你的 Javadoc 可以生成的内容,你可以在下面提到的链接中使用更多关于自定义 doclet 的信息。

  1. Information about which class to modify to generate custom Javadocs. 信息关于哪一类修改生成自定义的Javadoc。
  2. Once you customize the doclet, then you can use it in your maven-javadoc-plugin as mentioned here .一旦你自定义的doclet,那么您可以在您使用maven-javadoc-plugin提到这里

I hope this helps.我希望这有帮助。

In my experience, creating your own doclet can be very challenging, and is not well supported by the JDK in Java 8 and later.根据我的经验,创建自己的 doclet 可能非常具有挑战性,并且在 Java 8 及更高版本中不受 JDK 的良好支持。

If you are using Maven, an easier way would be to use the Google Maven Replacer plugin to modify the output after it is generated, as in the following example:如果您使用 Maven,更简单的方法是使用Google Maven Replacer插件在生成后修改输出,如下例所示:

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <show>private</show>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>javadoc</goal>
                        </goals>
                        <phase>install</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>maven-replacer-plugin</artifactId>
                <version>1.4.1</version>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>target/site/apidocs/**/*.html</include>
                            </includes>
                            <regex>false</regex>
                            <replacements>
                                <replacement>
                                    <token><![CDATA[<head>]]></token>
                                    <value>
<![CDATA[
<head>
    <link rel="shortcut icon" href="img/favicon/icon.png">
]]>
                                    </value>
                                </replacement>
                            </replacements>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM