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
562 stars 151 forks source link

'8' is not a valid choice for '-target' #583

Closed absalukaskosina closed 2 years ago

absalukaskosina commented 2 years ago

I am using plugin for compiling Spark jobs and after upgrade plugin from 4.5.6 to 4.6.0, I am getting fail with message: '8' is not a valid choice for '-target'

Settings I use and I found it has some impact:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
 .
 .
 .

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <scala.version>2.11.12</scala.version>
        <scala.compatibility.version>2.11</scala.compatibility.version>
        <scala-maven-plugin.version>4.6.0</scala-maven-plugin.version>
        .
        .
        .
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Scala -->
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-library</artifactId>
                <version>${scala.version}</version>
                <scope>provided</scope>
            </dependency>
            .
            .
            .
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>${scala-maven-plugin.version}</version>
                    <configuration>
                        <scalaVersion>${scala.version}</scalaVersion>
                        <scalaCompatVersion>${scala.compatibility.version}</scalaCompatVersion>
                    </configuration>
                    <executions>
                        <execution>
                            <id>scala-compile</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>compile</goal>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                .
                .
                .
            </plugins>
        </pluginManagement>
    </build>
    .
    .
    .
</project>

When I run mvn clean package I got error:

[INFO] --- scala-maven-plugin:4.6.0:compile (scala-compile) @ spark-testing ---
[INFO] Using incremental compilation using Mixed compile order
[INFO] Compiler bridge file: /Users/ab017z5/.sbt/1.0/zinc/org.scala-sbt/org.scala-sbt-compiler-bridge_2.11-1.6.1-bin_2.11.12__52.0-1.6.1_20220117T214008.jar
[INFO] compiling 6 Scala sources to /Users/ab017z5/projects/metron_mule/spark-testing/target/classes ...
[ERROR] '8' is not a valid choice for '-target'
[ERROR] bad option: '-target:8'

I did some testing and when I remove maven.compiler.source and maven.compiler.target, compiling is OK, but I am unsure for the result.

Is there some configuration way how to change the configuration having maven.compiler set to 8 in place?

slandelle commented 2 years ago

Please upgrade to 4.6.1. Thanks for reporting!

absalukaskosina commented 2 years ago

Thank you very much for quick update!