From e98b99edcd523e6690a9b5b963fd52b2f310eb9b Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Mon, 15 Jul 2019 15:25:17 -0700 Subject: [PATCH] Properly acquire JUnit 4, drop json-simple --- buildSrc/src/main/kotlin/PlatformConfig.kt | 5 +++++ worldedit-core/build.gradle.kts | 1 - .../sk89q/worldedit/util/paste/EngineHubPaste.java | 13 ++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index c57dbdd20..e4ab9629a 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -9,6 +9,7 @@ import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.external.javadoc.CoreJavadocOptions import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.getByName import org.gradle.kotlin.dsl.named @@ -38,6 +39,10 @@ fun Project.applyPlatformAndCoreConfiguration() { toolVersion = "7.6.1" } + dependencies { + "testImplementation"("junit:junit:4.12") + } + // Java 8 turns on doclint which we fail tasks.withType().configureEach { (options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet") diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 6a9266247..274cf2e06 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -20,7 +20,6 @@ dependencies { "compile"("com.google.guava:guava:21.0") "compile"("com.google.code.findbugs:jsr305:1.3.9") "compile"("com.google.code.gson:gson:2.8.0") - "compile"("com.googlecode.json-simple:json-simple:1.1.1") "compile"("org.slf4j:slf4j-api:1.7.26") "compileOnly"(project(":worldedit-libs:core:ap")) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java index ac7484846..ab8ebe029 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java @@ -19,8 +19,9 @@ package com.sk89q.worldedit.util.paste; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.util.net.HttpRequest; -import org.json.simple.JSONValue; import java.io.IOException; import java.net.URL; @@ -33,6 +34,8 @@ public class EngineHubPaste implements Paster { private static final Pattern URL_PATTERN = Pattern.compile("https?://.+$"); + private static final Gson GSON = new Gson(); + @Override public Callable paste(String content) { return new PasteTask(content); @@ -59,10 +62,10 @@ public class EngineHubPaste implements Paster { .returnContent() .asString("UTF-8").trim(); - Object object = JSONValue.parse(result); - if (object instanceof Map) { - @SuppressWarnings("unchecked") - String urlString = String.valueOf(((Map) object).get("url")); + Map object = GSON.fromJson(result, new TypeToken>() { + }.getType()); + if (object != null) { + String urlString = String.valueOf(object.get("url")); Matcher m = URL_PATTERN.matcher(urlString); if (m.matches()) {