gradle 尝试在java中使用org.json库

kmynzznz  于 2023-05-18  发布在  Java
关注(0)|答案(1)|浏览(330)

我正在使用gradle,并试图重新加载我的插件,但我似乎不能让它工作。这里是gradle文件。当我点击gradle上的reload按钮时,它会给出这个错误:
无法处理来自“/Applications/IntelliJ IDEA CE.app/Contents/plugins/gradle/lib/gradle-api-impldep-8.0.jar”的条目“org/gradle/internal/impldep/com/amazonaws/services/kms/model/transform/CreateGrantRequestProtocolMarshaller.class”
这是build.gradle文件

plugins {
    id 'java'
}

group = 'org.centoricraft'
version = '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    maven { url = "https://repo.codemc.org/repository/maven-public/" }
    maven {
        name = "spigotmc-repo"
        url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
    }
    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }
    maven {
        url = uri("https://repo.opencollab.dev/main")
    }
}

dependencies {
    compileOnly "dev.jorel:commandapi-bukkit-core:9.0.1"
    compileOnly "org.spigotmc:spigot-api:1.19.4-R0.1"
    compileOnly("org.geysermc.floodgate:api:2.2.2-SNAPSHOT")
    compile 'org.json:json:20210307'
}

def targetJavaVersion = 17
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release = targetJavaVersion
    }
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}
iq0todco

iq0todco1#

Gradle中不再使用“compile”配置(自Gradle 7.0起)
尝试替换

compile 'org.json:json:20210307'

implementation("org.json:json:20210307")

请参阅this topic了解更多信息。

相关问题