Wie behebt man die Maven-Javadoc-Plugin-Warnung wegen fehlender Javadoc-Bundle-Options-/Package-List-Datei?

Wie behebt man die Maven-Javadoc-Plugin-Warnung wegen fehlender Javadoc-Bundle-Options-/Package-List-Datei?

Beim Generieren der JavaDoc-Java-Archivressource mit dem Maven-Javadoc-Plugin wird die folgende Warnung angezeigt:

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

Ich habe die Mojo-Seite des Apache Maven JavaDoc Plugin überprüft:
https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html

Ich habe die Debug-Informationen mit -Xdem Flag überprüft:
mvn javadoc:jar@main-javadoc -X

Ich habe die Oracle Java Tool-Seite (JDK12) überprüft:
https://docs.oracle.com/en/java/javase/12/tools/javadoc.html

Ich vermute, es hat etwas damit zu tun, dass ich ein Maven-Projekt so eingerichtet habe, dass ich Produktionscode gegen JDK8 kompilieren kann, während ich gleichzeitig Testcode gegen JDK11 ausführen/kompilieren kann (wenn ich die Konfiguration für das Maven-Compiler-Plugin entferne, wird die Warnung nicht mehr angezeigt, obwohl die Warnung in anderen Projekten erscheint, die nur gegen JDK11 kompilieren).

Hier ist ein minimales Apache Maven POM zum Reproduzieren dieser Warnung (Beachten Sie, dass Sie mindestens eine Java-Klassenquelle im Quellpfad haben müssen):

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

Gibt es eine Möglichkeit, diese Warnung zu beheben, wenn weiterhin ein einzelnes Maven-Modul vorhanden ist, das Produktionscode und Testcode für (möglicherweise) zwei verschiedene JDK-APIs kompiliert?

BEARBEITEN:

  • Das Ändern des JDK und/oder %JAVA_HOME% löst dieses Problem nicht.
  • Das Hinzufügen/Entfernen einer Datei module-info.java löst dieses Problem nicht.
  • Der Grund für die Vermutung wurde hinzugefügt, dass die Kompilierung mit zwei unterschiedlichen JDK-APIs die Ursache hierfür sein könnte.
  • Ausführungsdefinitionen korrigiert, sodass JavaDoc beim Kompilieren/Verpacken/Javadoc gegen JDK8 keinen Fehler verursacht.

Antwort1

Was bei mir funktioniert hat, war das Entfernen derQuelleUndZielTags aus der allgemeinen Konfiguration des Maven-Compiler-Plugins und platzieren Sie diese in einer neuen Ausführungskonfiguration.

Hier ist das 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>

verwandte Informationen