How to resolve maven-javadoc-plugin warning for missing javadoc-bundle-options/package-list file?

0

1

When generating the JavaDoc Java archive resource with the maven-javadoc-plugin, the following warning is displayed:

[WARNING] javadoc: warning - Error reading file: /maven-javadoc-example/target/javadoc-bundle-options/package-list

I have checked the Apache Maven JavaDoc Plugin mojo page:
https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html

I have checked the debug information with -X flag:
mvn javadoc:jar@main-javadoc -X

I have checked the Oracle Java Tool page (JDK12):
https://docs.oracle.com/en/java/javase/12/tools/javadoc.html

I suspect it has something to do with the fact that I have a Maven project setup so that I can compile production code against JDK8 whilst still being able to run/compile test code against JDK11 (when I remove the configuration for the Maven Compiler plugin, the warning ceases, though the warning does appear in other projects that only compile against JDK11).

Here is a minimal Apache Maven POM to reproduce this warning (Note that you will have to have at least one Java class source in the source path):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.superuser.maven</groupId>
    <artifactId>maven-javadoc-example</artifactId>
    <version>1.0.0</version>

    <properties>
        <!-- Settings: maven-resource-plugin -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Settings: maven-compiler-plugin -->
        <maven.compiler.main-jdk>8</maven.compiler.main-jdk>
        <maven.compiler.test-jdk>11</maven.compiler.test-jdk>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>main-compile</id>
                        <phase>compile</phase>
                        <configuration>
                            <source>${maven.compiler.main-jdk}</source>
                            <target>${maven.compiler.main-jdk}</target>
                            <showWarnings>true</showWarnings>
                            <showDeprecation>true</showDeprecation>
                            <compilerArgs>
                                <arg>-Xlint:all,-processing,-cast,-serial,-try</arg>
                            </compilerArgs>
                            <excludes>
                                <exclude>module-info.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <release>${maven.compiler.test-jdk}</release>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <source>${maven.compiler.test-jdk}</source>
                    <target>${maven.compiler.test-jdk}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>main-javadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <sourceFileExcludes>module-info.java</sourceFileExcludes>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <quiet>true</quiet>
                    <failOnWarnings>false</failOnWarnings>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Is there a way to resolve this warning will still having a single Maven module that compiles production code and test code against (possibly) two different JDK APIs?

EDIT:

  • Changing the JDK and/or %JAVA_HOME% doesn't resolve this issue.
  • Adding/removing a module-info.java file doesn't resolve this issue.
  • Added the reason for suspecting compiling against two different JDK APIs might be the cause of this.
  • Fixed execution definitions so that JavaDoc doesn't through an error when compiling/packaging/javadoc against JDK8.

Osmund Francis

Posted 2019-09-26T15:44:44.760

Reputation: 243

Answers

0

What worked for me was removing the source and target tags from the Maven compiler plugin general configuration, and placing them in a new execution configuration.

Here is the POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.superuser.maven</groupId>
    <artifactId>maven-javadoc-example</artifactId>
    <version>1.0.0.Final</version>

    <properties>
        <!-- Settings: maven-resource-plugin -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Settings: maven-compiler-plugin -->
        <maven.compiler.main-jdk>8</maven.compiler.main-jdk>
        <maven.compiler.test-jdk>11</maven.compiler.test-jdk>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <phase>none</phase>
                        <configuration>
                            <release>${maven.compiler.test-jdk}</release>
                        </configuration>
                    </execution>
                    <execution>
                        <id>main-compile</id>
                        <phase>compile</phase>
                        <configuration>
                            <release>${maven.compiler.test-jdk}</release>
                        </configuration>
                    </execution>
                    <execution>
                        <id>main-compile-jdk8</id>
                        <phase>none</phase>
                        <configuration>
                            <source>${maven.compiler.main-jdk}</source>
                            <target>${maven.compiler.main-jdk}</target>
                            <excludes>
                                <exclude>module-info.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <release>${maven.compiler.test-jdk}</release>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                    <compilerArgs>
                        <arg>-Xlint:all,-processing,-cast,-serial,-try</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>main-javadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <sourceFileExcludes>module-info.java</sourceFileExcludes>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <quiet>true</quiet>
                    <failOnWarnings>false</failOnWarnings>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Osmund Francis

Posted 2019-09-26T15:44:44.760

Reputation: 243