Trying to use org.json library in java

huangapple go评论63阅读模式
英文:

Trying to use org.json library in java

问题

I'm using Gradle and trying to reload my plugin, but I can't 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
    }
}

(Note: This is a translation of your provided text without additional content.)

英文:

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 &#39;java&#39;
}

group = &#39;org.centoricraft&#39;
version = &#39;1.0-SNAPSHOT&#39;

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

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

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

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

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset &#39;UTF-8&#39;
    filesMatching(&#39;plugin.yml&#39;) {
        expand props
    }
}

答案1

得分: 0

"compile"配置在Gradle中不再使用(自Gradle 7.0起)。

尝试替换:

compile 'org.json:json:20210307'

用以下方式:

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

更多信息请参阅此主题

英文:

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

Try replacing

compile &#39;org.json:json:20210307&#39;

with

implementation(&quot;org.json:json:20210307&quot;)

See this topic for more info.

huangapple
  • 本文由 发表于 2023年5月17日 14:32:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76269125.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定