JavaDoc - 未声明的类型变量 [英] JavaDoc - Undeclared Type Variable

查看:381
本文介绍了JavaDoc - 未声明的类型变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为每个必须使用Maven和Java8的人都知道这个错误,发布版本突然因JavaDoc中的拼写错误而失败。作为一家公司,我们决定让一些可怜的傻瓜(也就是我)全部工作。现在我遇到了以下错误:

I think everybody who has to work with Maven and Java8 knows of this bug that release builds suddenly fail for spelling mistakes in JavaDoc. As a company we decided to let some poor sap (aka me) work all of them out. Now I'm stuck with the following "error":

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.1:javadoc (default-cli) on project org.acme.project.demo: An error has occurred in JavaDocs report generation:
[ERROR] Exit code: 1 - C:\jenkins\workspace\Project 2.0\org.acme.project.demo\src\main\java\org\acme\project\demo\SomeClass.java:36: error: cannot access OtherClass
[ERROR] import org.acme.project.OtherClass;
[ERROR] ^
[ERROR] bad class file: C:\jenkins\workspace\Project 2.0\org.acme.project\target\org.acme.project-2.0.0-SNAPSHOT-v20150128-1503.jar(org/acme/project/OtherClass.class)
[ERROR] undeclared type variable: N
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath.

我试图将其清理一下,但总结一下:Project B在尝试时抛出异常解决对项目A的方法调用(是的,在生成JavaDoc时!)。有问题的方法如下:

I tried to clean it up a bit, but to summarize: Project B throws the exception when it tries to resolve a method call to Project A (yes, while generating JavaDoc!). The method in question looks like that:

public static <N extends Bean> void hookContinousImageFunction(final OtherClass<N> dialog,
        final ImageGroup imageGroup, N model, final BiFunction<Image, N, ? extends Image> imageFunction) {
    final Image original = imageGroup.getImage();
    dialog.setOnCancelClick((notUsed) -> imageGroup.setImage(original));
    model.addPropertyChangeListener(new ContinousImageFunctionListener<>(dialog, imageGroup, imageFunction));
    dialog.setInitialModel(model);
}

它甚至没有JavaDoc(并不是说任何一个都应该重要Project A的JavaDoc的生成已经完成,Maven正在尝试为Project B生成JavaDoc。)

It doesn't even have JavaDoc (not that any of this should matter when the generation of Project A's JavaDoc is already finished, and Maven is trying to generate JavaDoc for Project B).

截至目前,我们在多个项目中都有这个bug,关于项目A(具有类似方法/类的类型)通常在完全不同的构建反应堆中,有时完全不受我们的控制。

As of now, we have this bug in multiple projects, about 1 out of 5. Project A (the one with a typed method / class like above) is more often than not in an entirely different build reactor and sometimes completely out of our control.

如何在错误中修复此错误?

How do I fix this bug inside a bug?

(作为旁注,Jenkin运行Java 1.8.0_31和jdk1时出错.8.0_40或本地1.8.0_45,1.8.0_60,但本地不是1.8.0_20,但JavaDoc生成并不可靠,所以我不能肯定它与Java版本有关。 )

(As a as a side note, the error occurs on the Jenkin's running with Java 1.8.0_31 and jdk1.8.0_40 or locally with 1.8.0_45, 1.8.0_60, but not locally with 1.8.0_20, but JavaDoc generation hasn't been that reliable, so I can't say for sure it has something to do with the Java version.)

推荐答案

好的答案是a)将Java降级到1.8.0_20,或者 - 如果不可能 - b)用这个鳕鱼e在 pom.xml 中禁用项目的JavaDoc,直到Java用户觉得需要修复bug:

Okay the answer is to a) downgrade Java to 1.8.0_20, or - if that is not possible - b) to use this code in the pom.xml to disable JavaDoc of the project until the Java people feel the need to fix the bug:

<properties>
    <maven.javadoc.skip>true</maven.javadoc.skip>
</properties>

这篇关于JavaDoc - 未声明的类型变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆