davidB / scala-maven-plugin

The scala-maven-plugin (previously maven-scala-plugin) is used for compiling/testing/running/documenting scala code in maven.
https://davidb.github.io/scala-maven-plugin/
The Unlicense
557 stars 151 forks source link

Mixed Java & Scala 3.x compilation broke with release 4.7.2 and newer #673

Closed roman-mibex-2 closed 1 year ago

roman-mibex-2 commented 1 year ago

It looks like mixed compilation with Java 8 and Scala 3.x (Scala 3.2.2 in my case) is broken.

The compilation fails with:

[INFO] compiling 2 Scala sources and 54 Java sources to /home/roman/dev/include-cloud/datacenter/target/classes ...
[ERROR] : 1.8 is not a valid choice for -java-output-version
[INFO] :   scalac -help  gives more information
[ERROR] one error found

The issue seems to be introduced by this change: https://github.com/davidB/scala-maven-plugin/commit/ede3d72e206b8d9a7ad07d28fc27863ccc7264d6

The rough issue: -release 1.8 is added to the Scalac command, which it doesn't like. The ScalaMojoSupport.targetOption does translate the Maven 1.8 Java version to 8, but only for the Scala 2.x compiler series.

So, it seems that either the -release flag isn't correct for Scala 3.x, or the version translation should be applied to Scacal 3.x as well.

slandelle commented 1 year ago

@roman-mibex-2 Please provide a sample project to reproduce your issue.

roman-mibex-2 commented 1 year ago

Here is an example project: https://github.com/roman-mibex-2/reproduce-java-8-scala-3-example

slandelle commented 1 year ago

@roman-mibex-2 Thanks. PR under built. I've verified locally that it fixes your issue. I'm waiting for the CI to pass before merging and releasing.

slandelle commented 1 year ago

Release 4.8.1 should be up on maven central in ~20 minutes.

roman-mibex-2 commented 1 year ago

It does work for us. Thanks for the incredible fast fix.