Search code examples
javagradleintellij-idea

Trying to use org.json library in java


im using gradle and trying to reload my plugin but i cant seem to get it to work. Here is the gradle file. when i click the reload button on gradle it gives this error:

Failed to process the entry 'org/gradle/internal/impldep/com/amazonaws/services/kms/model/transform/CreateGrantRequestProtocolMarshaller.class' from '/Applications/IntelliJ IDEA CE.app/Contents/plugins/gradle/lib/gradle-api-impldep-8.0.jar'

This is the build.gradle file

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
    }
}


Solution

  • "compile" configuration is no longer used in Gradle (since Gradle 7.0)

    Try replacing

    compile 'org.json:json:20210307'
    

    with

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

    See this topic for more info.