We are migrating our java 8 projects to java 11. JAVA_HOME still points to java 8 but the first project to be migrated compiles in java 11 and the unit tests run just fine.
The maven-compiler-plugin and the toolchain are defined as in this question. Maven version is 3.5.0.
When i run
mvn verify
I get the following error:
Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.11.0:
pmd (pmd) on project <yourproject>:
Execution pmd of goal org.apache.maven.plugins:maven-pmd-plugin:3.11.0:
pmd failed: An API incompatibility was encountered while executing
org.apache.maven.plugins:maven-pmd-plugin:3.11.0:pmd:
java.lang.UnsupportedClassVersionError:
<Yourclass> 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 //(indentation added for readability)
I understand that the classes were compiled using java 11 (as intended) and that maven runs on java 8 because that is what JAVA_HOME points to. But why does that trip up the pmd-plugin? It is supposed to check the source code, never mind the compiled classes.
Is there a way around this, short of setting JAVA_HOME to 11?