diff --git a/build.gradle b/build.gradle index 9b76df2..505019a 100644 --- a/build.gradle +++ b/build.gradle @@ -10,8 +10,6 @@ dependencies { implementation gradleApi() implementation "org.yaml:snakeyaml:${project.snakeyaml_version}" implementation "com.google.code.gson:gson:${project.gson_version}" - implementation "com.google.guava:guava:${project.guava_version}" - implementation "org.apache.commons:commons-lang3:${project.commons_lang3_version}" } javadoc { diff --git a/gradle.properties b/gradle.properties index d6471a9..66c532c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,10 +9,3 @@ # https://mvnrepository.com/artifact/com.google.code.gson/gson gson_version = 2.10.1 - - # https://mvnrepository.com/artifact/com.google.guava/guava - guava_version = 33.1.0-jre - - # https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 - commons_lang3_version = 3.14.0 - diff --git a/src/main/java/me/fallenbreath/yamlang/Yamlang2JsonlangMapper.java b/src/main/java/me/fallenbreath/yamlang/Yamlang2JsonlangMapper.java index 190d83a..0993160 100644 --- a/src/main/java/me/fallenbreath/yamlang/Yamlang2JsonlangMapper.java +++ b/src/main/java/me/fallenbreath/yamlang/Yamlang2JsonlangMapper.java @@ -1,8 +1,8 @@ package me.fallenbreath.yamlang; -import com.google.common.io.CharStreams; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import me.fallenbreath.yamlang.utils.IOUtils; import org.yaml.snakeyaml.Yaml; import java.io.FilterReader; @@ -16,7 +16,7 @@ public class Yamlang2JsonlangMapper extends FilterReader { public Yamlang2JsonlangMapper(Reader reader) throws IOException { - super(new StringReader(yamlang2Jsonlang(CharStreams.toString(reader)))); + super(new StringReader(yamlang2Jsonlang(IOUtils.readerToString(reader)))); } private static String yamlang2Jsonlang(String ymlContent) diff --git a/src/main/java/me/fallenbreath/yamlang/YamlangPlugin.java b/src/main/java/me/fallenbreath/yamlang/YamlangPlugin.java index 3f165bc..e4ef827 100644 --- a/src/main/java/me/fallenbreath/yamlang/YamlangPlugin.java +++ b/src/main/java/me/fallenbreath/yamlang/YamlangPlugin.java @@ -1,6 +1,6 @@ package me.fallenbreath.yamlang; -import org.apache.commons.lang3.StringUtils; +import me.fallenbreath.yamlang.utils.StringUtils; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.Task; diff --git a/src/main/java/me/fallenbreath/yamlang/utils/IOUtils.java b/src/main/java/me/fallenbreath/yamlang/utils/IOUtils.java new file mode 100644 index 0000000..83199fc --- /dev/null +++ b/src/main/java/me/fallenbreath/yamlang/utils/IOUtils.java @@ -0,0 +1,19 @@ +package me.fallenbreath.yamlang.utils; + +import java.io.IOException; +import java.io.Reader; + +public class IOUtils +{ + public static String readerToString(Reader reader) throws IOException + { + StringBuilder builder = new StringBuilder(); + char[] buf = new char[4096]; + int n; + while ((n = reader.read(buf)) != -1) + { + builder.append(buf, 0, n); + } + return builder.toString(); + } +} diff --git a/src/main/java/me/fallenbreath/yamlang/utils/StringUtils.java b/src/main/java/me/fallenbreath/yamlang/utils/StringUtils.java new file mode 100644 index 0000000..d20419a --- /dev/null +++ b/src/main/java/me/fallenbreath/yamlang/utils/StringUtils.java @@ -0,0 +1,26 @@ +package me.fallenbreath.yamlang.utils; + +public class StringUtils +{ + /** + * No need to handle those codepoint things, + * cuz this method is only used to capitalize a gradle source set name + */ + public static String capitalize(final String str) + { + if (str == null || str.isEmpty()) + { + return str; + } + + char firstChar = str.charAt(0); + if (firstChar > 0x7F /* unicode? */ || Character.isUpperCase(firstChar)) + { + return str; + } + else + { + return Character.toUpperCase(firstChar) + str.substring(1); + } + } +}