make 'mvn test' work with JDK's < 11

Issue #575 invalid
Peter Moore created an issue

Right now, running ‘mvn test’ with a JDK < 11 will fail with:

[ERROR] Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.20.0:format (default) on project snakeyaml: Execution default of goal net.revelc.code.formatter:formatter-maven-plugin:2.20.0:format failed: Unable to load the mojo 'format' in the plugin 'net.revelc.code.formatter:formatter-maven-plugin:2.20.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: net/revelc/code/formatter/FormatterMojo has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[ERROR] -----------------------------------------------------

This stems from revelc only working with jdk11. Could the execution of revelc be made conditional on the JDK version?

In the attached pom.xml I moved the revelc plugin to a new ‘jdk11_or_greater’ profile that is activated by <jdk>[11,)</jdk> (i.e. all jdk versions greater or equal to 11). With that pom, ‘mvn test’ now works with jdk8. I’m not sure what the revelc plugin does, but I have confirmed that a jdk11 build with that pom will generate revelc related messages in the debug output and apidocs are still generated.

Comments (7)

  1. Andrey Somov

    What is the added value to run under Java 8 ?

    You can use docker to run under any JDK. Feel free to check the included scripts (and modify them)

    ./docker-run-jdk*

  2. Peter Moore reporter

    We ship our product on JDK 8 and so we test using the JDK that the customer will use. In particular, being able to run the tests with JDK8 would allow catching issues like 573.

  3. Andrey Somov

    @{6204d7ce35a62a006844789c} I tried to apply the POM, but I get an error:
    ./mvnw clean install site

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project snakeyaml: Fatal error compiling: invalid flag: --release -> [Help 1]

  4. Log in to comment