Search code examples
javagradlejunit5java-14

After cloning JUnit 5 in local machine, compile time error while executing "assemble" task


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


Solution

  • 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