maven javadoc plugin build fails with Java 8 when Javadoc tags are incomplete

时间:2022-11-26 10:14:54

本地开发环境JDK版本是1.7,生成Javadoc没有问题,在测试环境使用Jenkins自动构建时报错(测试服务器JDK版本是1.8),log如下:

/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/ui/ConceptRelationshipUIRedirect.java:28: error: unknown tag: date
 * @date 9 Apr 2015
   ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/CdmSpringConnectionPool.java:19: error: unknown tag: date
 * @date 9 Mar 2015
   ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/IdUuidName.java:16: error: unknown tag: date
 * @date 7 Apr 2015
   ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/LeafNodeTaxonContainer.java:38: error: unknown tag: date
 * @date 10 Mar 2015
   ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/LeafNodeTaxonContainer.java:71: error: @param name not found
     * @param delegate
              ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/LeafNodeTaxonContainer.java:71: warning: no description for @param
     * @param delegate
       ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/LeafNodeTaxonContainer.java:72: warning: no description for @throws
     * @throws SQLException
       ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/LeafNodeTaxonContainer.java:74: warning: no @param for classificationId
    public LeafNodeTaxonContainer(int classificationId) throws SQLException {
           ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/container/TaxonNodeContainer.java:48: warning: no description for @param
     * @param parent
       ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/jscomponent/D3ConceptRelationshipTree.java:40: error: unknown tag: date
 * @date 8 Apr 2015
   ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/jscomponent/D3ConceptRelationshipTreeState.java:16: error: unknown tag: date
 * @date 8 Apr 2015
   ^
/home/andreas/workspaces/cdm/cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/statement/CdmStatementDelegate.java:27: error: unknown tag: date
 * @date 10 Mar 2015
   ^

Command line was: /opt/java-oracle/jdk1.8.0_60/jre/../bin/javadoc @options @packages

Refer to the generated Javadoc files in '/home/andreas/workspaces/cdm/cdm-vaadin/target/site/apidocs' dir.

        at org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeJavadocCommandLine(AbstractJavadocMojo.java:5188)
        at org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeReport(AbstractJavadocMojo.java:2075)
        at org.apache.maven.plugin.javadoc.JavadocReport.generate(JavadocReport.java:130)
        at org.apache.maven.plugin.javadoc.JavadocReport.execute(JavadocReport.java:318)
        ... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

最简单的解决办法如下:

<profiles>
    <profile>
        <id>doclint-java8-disable</id>
        <activation>
            <jdk>[1.8,)</jdk>
        </activation>
        <properties>
            <javadoc.opts>-Xdoclint:none</javadoc.opts>
        </properties>
    </profile>
</profiles>

<build>
    <plugins>
        <!--配置生成Javadoc包-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.10.4</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <aggregate>true</aggregate>
                <charset>UTF-8</charset>
                <docencoding>UTF-8</docencoding>
                <additionalparam>${javadoc.opts}</additionalparam>
            </configuration>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!--配置生成源码包-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

参考链接

Maven is not working in Java 8 when JavaDoc tags are incompletehttp://*.com/questions/15886209/maven-is-not-working-in-java-8-when-javadoc-tags-are-incomplete