简体   繁体   中英

set favicon to maven-javadoc-plugin generated javadoc file

I can set window title using following code in " maven-java doc-plugin ".

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

but I cannot set "favicon" to my java doc

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.

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.

Now, what is doclet ( More details here )?

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" . 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

So basically you can customize what your Javadoc can generate, you can use more information on customizing the doclet in below mentioned links.

  1. Information about which class to modify to generate custom Javadocs.
  2. Once you customize the doclet, then you can use it in your maven-javadoc-plugin as mentioned here .

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.

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:

        <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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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