简体   繁体   English

maven-javadoc-plugin 找不到 Spigot 包

[英]maven-javadoc-plugin cannot find Spigot packages

This is NOT a duplicate of this question .这不是这个问题的重复。 I am having trouble includding external dependencies to my Javadoc, which is not what that question is about.我在将外部依赖项包含到我的 Javadoc 时遇到了麻烦,这不是那个问题的意义所在。

I am trying to deploy my API to Maven Central.我正在尝试将我的 API 部署到 Maven Central。 Everything is going smooth, except for the Maven Javadoc plugin.一切都很顺利,除了 Maven Javadoc 插件。 My API has two dependencies (Spigot API - org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT and JetBrains Annotations - org.jetbrains:annotations:23.0.0 ).我的 API 有两个依赖项(Spigot API - org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT和 JetBrains Annotations - org.jetbrains:annotations:23.0.0 )。
Running mvn clean deploy triggers the Javadoc plugin, which follows into a verbose error:运行mvn clean deploy会触发 Javadoc 插件,随后会出现详细错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.253 s
[INFO] Finished at: 2022-07-14T20:10:43+05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.4.0:jar (attach-javadocs) on project UnderscoreEnchantsAPI: MavenReportException: Error while generating Javadoc: 
[ERROR] Exit code: 1 - path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\EnchantmentsCombineEvent.java:3: error: package org.bukkit.entity does not exist
[ERROR] import org.bukkit.entity.Player;
[ERROR]                         ^
[ERROR] path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\EnchantmentsCombineEvent.java:4: error: package org.bukkit.event does not exist
[ERROR] import org.bukkit.event.Cancellable;
[ERROR]                        ^
[ERROR] path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\EnchantmentsCombineEvent.java:5: error: package org.bukkit.event does not exist
[ERROR] import org.bukkit.event.Event;
[ERROR]                        ^
[ERROR] path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\EnchantmentsCombineEvent.java:6: error: package org.bukkit.event does not exist
[ERROR] import org.bukkit.event.HandlerList;
[ERROR]                        ^
[ERROR] path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\EnchantmentsCombineEvent.java:7: error: package org.bukkit.inventory does not exist
[ERROR] import org.bukkit.inventory.ItemStack;
[ERROR]                            ^
[ERROR] path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\EnchantmentsCombineEvent.java:8: error: package org.jetbrains.annotations does not exist
[ERROR] import org.jetbrains.annotations.NotNull;
[ERROR]                                 ^
... A LOT MORE ...
[ERROR] path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\PreEnchantEvent.java:23: error: cannot find symbol
[ERROR]     public PreEnchantEvent(@NotNull Player player, @NotNull Enchantment enchantment, int level, @NotNull ItemStack item) {
[ERROR]                             ^
[ERROR]   symbol:   class NotNull
[ERROR]   location: class PreEnchantEvent
[ERROR] path\to\project\UnderscoreEnchantsAPI\src\main\java\com\roughlyunderscore\enchantsapi\events\PreEnchantEvent.java:23: error: cannot find symbol
[ERROR]     public PreEnchantEvent(@NotNull Player player, @NotNull Enchantment enchantment, int level, @NotNull ItemStack item) {
[ERROR]                                                     ^
[ERROR]   symbol:   class NotNull
[ERROR]   location: class PreEnchantEvent
[ERROR] 
[ERROR] Command line was: cmd.exe /X /C "path\to\jdks\.jdks\corretto-16.0.2\bin\javadoc.exe @options @packages @argfile"
[ERROR] 
[ERROR] Refer to the generated Javadoc files in 'path\to\project\UnderscoreEnchantsAPI\target\apidocs' dir.
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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

From what I pre-concluded, maven-javadoc-plugin does not see the dependencies that I have.从我预先得出的结论来看,maven-javadoc-plugin 没有看到我拥有的依赖项。 Now, here is my pom.xml, or, actually, the parts that matter:现在,这是我的 pom.xml,或者,实际上,重要的部分:


              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <links>
                        <link>https://hub.spigotmc.org/javadocs/bukkit/</link>
                        <link>https://javadoc.io/doc/org.jetbrains/annotations-java5/23.0.0/</link>
                    </links>
                <!-- The links section does not seem to help! -->
                </configuration>
            </plugin>

      <repositories>
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.19-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>23.0.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

If for any reason at all you would like to see my full pom.xml, it's here .如果出于任何原因您想查看我的完整 pom.xml,它就在这里 The full error can be found here .完整的错误可以在这里找到。 Any help is appreciated.任何帮助表示赞赏。 This error has been bothering me for more than a week now and I couldn't seem to find any of such problems (many similar, but none that had this very problem).这个错误已经困扰我一个多星期了,我似乎找不到任何这样的问题(很多类似的,但没有一个有这个问题)。 Any help is appreciated.任何帮助表示赞赏。

Edit: Adding <configuration><doclint>none</doclint></configuration> doesn't help.编辑:添加<configuration><doclint>none</doclint></configuration>没有帮助。

I managed to resolve this problem by building the project against Java 1.8 and adding the following block into my pom.xml:我设法通过针对 Java 1.8 构建项目并将以下块添加到我的 pom.xml 中来解决此问题:

     <profiles>
        <profile>
            <id>doclint-java8-disable</id>
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.4.0</version>
                        <configuration>
                            <links>
                                <link>https://hub.spigotmc.org/javadocs/bukkit/</link>
                                <link>https://javadoc.io/doc/org.jetbrains/annotations-java5/23.0.0/</link>
                            </links>
                            <additionalOptions>
                                <additionalOption>-Xdoclint:none</additionalOption>
                            </additionalOptions>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

This is a hacky way, and I am still looking for a way to make it work on Java 16. Do suggest your ideas if you have any.这是一种 hacky 方式,我仍在寻找使其在 Java 16 上运行的方法。如果您有任何想法,请提出您的想法。

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

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