WhatsApp4j - Api |无法编译,因为 class 使用预览功能

WhatsApp4j - Api | Does not compile because class uses preview features

我想试用 (https://github.com/Auties00/WhatsappWeb4j) Whatsapp4j 库, 我的 gradle:

        plugins {
        id 'java'
    }
    
    group 'de.test'
    version '1.0-SNAPSHOT'
    
    repositories {
        mavenCentral()
    }

dependencies {
    implementation 'com.github.auties00:whatsappweb4j:2.2.1'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
    useJUnitPlatform()
}

我只将它添加到我的 gradle 文件中,当我 运行 我的 Main.java(它只实现了这个库的 class)

  import it.auties.whatsapp4j.whatsapp.WhatsappAPI;
    
    public class Main {
    
        public static void main(String[] args) {
        }
    }

我收到此错误:

error: classfile for
C:\Users\User\.gradle\caches\modules-2\files-2.1\com.github.auties00\whatsappweb4j.2.1b3c7842cc489e3ae0cc6147c84b11ff6334671e\whatsappweb4j-2.2.1.jar(/it/auties/whatsapp4j/whatsapp/WhatsappAPI.class)
uses preview features of Java SE 16.

我试图修复它,将我的语言级别设置为预览(我不知道什么是预览功能): 但遗憾的是那没有用。错误仍然存​​在。 我希望有人知道如何修复它。

-我用的是IntelliJ IDEA

正如@Mark Rotteveel 指出的那样,在 Gradle 构建文件中启用预览功能有效。

添加这个有效。

tasks.withType(JavaCompile) {
    options.compilerArgs += "--enable-preview"
}

tasks.withType(Test) {
    jvmArgs += "--enable-preview"
}

tasks.withType(JavaExec) {
    jvmArgs += '--enable-preview'
}