maven-compiler-plugin icon indicating copy to clipboard operation
maven-compiler-plugin copied to clipboard

[MCOMPILER-420] Support for testCompileSourceRoots to handle multiReleaseOutput

Open jira-importer opened this issue 5 years ago • 0 comments

John Patrick opened MCOMPILER-420 and commented

Testing out surefire v3.0.0-M5 and coming across issues with testCompile.

I've got;

src/main/java/aaa
src/main/java11/module-info.java
src/test/java/bbb
src/test/java11/module-info.java

My current working copy of the compile configuration looks like this but am trying multiple different versions.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<executions>
<execution>
<id>java11-main</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>11</release>
<jdkToolchain>
<version>11</version>
</jdkToolchain>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
<execution>
<id>java11-test</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<release>11</release>
<jdkToolchain>
<version>11</version>
</jdkToolchain>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/test/java11</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>

The java11-tests configuration for multiReleaseOutput appears to be ignored as java 1.8 is being compiled into target/test-classes and then it's recompiled using java 11 also into target/test-classes

So when surefire executes using java 1.8 I get;

[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[ERROR] <<<TestClass>>> 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

Because I'm creating jar's with base version 1.8 and additional java 11 classes, i need to test against java 1.8 and execute again using java 11 to check no regression issues.

Adding support for multiReleaseOutput or testMultiReleaseOutput, might solve the issue or I might still have issues to resolve.


Affects: 3.8.1

jira-importer avatar Jun 16 '20 00:06 jira-importer