英文:
After cloning JUnit 5 in local machine, compile time error while executing "assemble" task
问题
我正在尝试查看 JUnit 5 的源代码。我在本地机器上克隆了他们的代码库。他们的代码库中写道,构建该项目需要 JDK 11。但我尝试使用 JDK 14 来运行它。请告诉我它是否只能在 JDK 11 上运行。
我从项目的根目录执行了以下命令:
gradlew clean assemble
在这里,Gradle 报了一个编译时错误:
{我的根目录}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:110: 错误: 注释 @Category 缺少元素'value'的默认值
@Category("JUnit")
^
{我的根目录}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:111: 错误: 注释 @Label 缺少元素'value'的默认值
@Label("Test Plan")
^
{我的根目录}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:112: 错误: 注释 @Name 缺少元素'value'的默认值
@Name("org.junit.TestPlan")
^
(更多类似的错误)
我需要一些帮助来解决这个问题,以便能够成功构建该项目。
我的系统信息:
操作系统:Windows 10
JDK 版本:jdk-14.0.2
Gradle 版本:Gradle 6.5.1
英文:
I am trying to check out JUnit 5's source code. I cloned their repository in my local machine.
Their repository says I need JDK 11 to build this project. But I tried to run it using JDK 14. Please let me know if it runs only on JDK 11.
From the projects root directory, I executed
gradlew clean assemble
Here gradle is throwing a compile time error
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:110: error: annotation @Category is missing a default value for the element 'value'
@Category("JUnit")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:111: error: annotation @Label is missing a default value for the element 'value'
@Label("Test Plan")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:112: error: annotation @Name is missing a default value for the element 'value'
@Name("org.junit.TestPlan")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:157: error: annotation @Label is missing a default value for the element 'value'
@Label("Test")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:158: error: annotation @Name is missing a default value for the element 'value'
@Name("org.junit.TestExecution")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:129: error: annotation @Category is missing a default value for the element 'value'
@Category("JUnit")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:160: error: annotation @Label is missing a default value for the element 'value'
@Label("Result")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:162: error: annotation @Label is missing a default value for the element 'value'
@Label("Exception Class")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:164: error: annotation @Label is missing a default value for the element 'value'
@Label("Exception Message")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:133: error: annotation @Label is missing a default value for the element 'value'
@Label("Unique Id")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:135: error: annotation @Label is missing a default value for the element 'value'
@Label("Display Name")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:137: error: annotation @Label is missing a default value for the element 'value'
@Label("Tags")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:139: error: annotation @Label is missing a default value for the element 'value'
@Label("Type")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:115: error: annotation @Label is missing a default value for the element 'value'
@Label("Contains Tests")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:117: error: annotation @Label is missing a default value for the element 'value'
@Label("Engine Names")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:123: error: annotation @Name is missing a default value for the element 'value'
@Name("org.junit.UniqueId")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:150: error: annotation @Label is missing a default value for the element 'value'
@Label("Skipped Test")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:151: error: annotation @Name is missing a default value for the element 'value'
@Name("org.junit.SkippedTest")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:153: error: annotation @Label is missing a default value for the element 'value'
@Label("Reason")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:168: error: annotation @Category is missing a default value for the element 'value'
@Category("JUnit")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:169: error: annotation @Label is missing a default value for the element 'value'
@Label("Report Entry")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:170: error: annotation @Name is missing a default value for the element 'value'
@Name("org.junit.ReportEntry")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:174: error: annotation @Label is missing a default value for the element 'value'
@Label("Unique Id")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:176: error: annotation @Label is missing a default value for the element 'value'
@Label("Key")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:178: error: annotation @Label is missing a default value for the element 'value'
@Label("Value")
^
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:60: error: reference to begin is ambiguous
event.begin();
^
both method begin() in Event and method begin() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:66: error: reference to commit is ambiguous
event.commit();
^
both method commit() in Event and method commit() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:74: error: reference to commit is ambiguous
event.commit();
^
both method commit() in Event and method commit() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:82: error: reference to begin is ambiguous
event.begin();
^
both method begin() in Event and method begin() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:92: error: reference to end is ambiguous
event.end();
^
both method end() in Event and method end() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:96: error: reference to commit is ambiguous
event.commit();
^
both method commit() in Event and method commit() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:106: error: reference to commit is ambiguous
event.commit();
^
both method commit() in Event and method commit() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:114: error: reference to Event is ambiguous
static class TestPlanExecutionEvent extends Event {
^
both constructor Event() in Event and constructor Event() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:131: error: reference to Event is ambiguous
abstract static class TestEvent extends Event {
^
both constructor Event() in Event and constructor Event() in Event match
{my root directory}\junit-platform-jfr\src\main\java\org\junit\platform\jfr\FlightRecordingListener.java:172: error: reference to Event is ambiguous
static class ReportEntryEvent extends Event {
^
both constructor Event() in Event and constructor Event() in Event match
35 errors
I need some help to solve this, so that I can build the project successfully.
My system information
OS: Windows 10
JDK version: jdk-14.0.2
Gradle version: Gradle 6.5.1
答案1
得分: 0
截止今日,运行 JUnit 5 的 Gradle 设置需要 JDK 11。请参阅 https://github.com/junit-team/junit5/#building-from-source 获取最新的说明。
为了在更新的 JDK 上构建 JUnit 5,你需要指定一个额外的 JDK 路径,用于在编译源代码时使用 —— 除了运行 Gradle 的 JDK 11 安装。以下是在 JDK 14、15 和 16 上运行的“跨版本”1 工作流程要点:
gradlew -PjavaHome=$ADDITIONAL_JDK build
英文:
As of today, JDK 11 is required to run the Gradle setup of JUnit 5. Refer to https://github.com/junit-team/junit5/#building-from-source for the latest instructions.
In order to build JUnit 5 on newer JDKs, you need to specifiy an additional path to the JDK that should be used when compiling source files -- in addition to the JDK 11 installation that runs Gradle. Here's the gist of the "cross-version" workflow running on JDK 14, 15, and 16:
gradlew -PjavaHome=$ADDITIONAL_JDK build
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论