San Jaisy
San Jaisy

Reputation: 17088

error: invalid source release 14 with --enable-preview

I am using Micronaut2.0.2 application with IntelliJ IDE 2020.2.2. I have enabled the preview feature in from the language level in IDE

enter image description here

And in the Gradle file I have the below option

java {
    sourceCompatibility = JavaVersion.toVersion('14')
    targetCompatibility = JavaVersion.toVersion('14')
}

tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
    options.compilerArgs.addAll([
            '-parameters',
            // enables incremental compilation
            '-Amicronaut.processing.incremental=true',
            '-Amicronaut.processing.annotations=fete.bird.*',
            "-Amicronaut.processing.group=$project.group",
            "-Amicronaut.processing.module=$project.name",
            "--enable-preview"
    ])
}

Getting an error as error: invalid source release 14 with --enable-preview

Upvotes: 5

Views: 11055

Answers (2)

Kidus Tekeste
Kidus Tekeste

Reputation: 661

If you have some wrong configurations in your pom.xml like this remove it. It worked for me after I remove the configs:

    <configuration>
        <source>15</source>
        <target>15</target>
        <compilerArgs>--enable-preview</compilerArgs>
    </configuration>

That's what was messing up for me. Since I already have Java 16 already.

Upvotes: 3

Andrey
Andrey

Reputation: 16391

Set Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM to 14 JDK version.

Upvotes: 6

Related Questions