Get rid of preview warning when with gradle compileJava task?

88 views Asked by At

I configured my Gradle build as follows:

tasks {
    val preview = "--enable-preview"

    withType<JavaCompile> {
        options.compilerArgs.add(preview)
        options.compilerArgs.add("-Xlint:preview")
    }

    withType<Test> {
        useJUnitPlatform()
        jvmArgs = jvmArgs!! + preview
    }

    withType<JavaExec> {
        jvmArgs = jvmArgs!! + preview
    }
}

However, when I compile, I get:

> Task :compileJava
warning: [preview] string templates are a preview feature and may be removed in a future release.
1

There are 1 answers

0
Stephen C On BEST ANSWER

According to the manual, -Xlint:preview enables the check for use of preview features.

Try using -Xlint:-preview instead; i.e.

    options.compilerArgs.add("-Xlint:-preview")