Skip to content

Commit

Permalink
reduce unnecessary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Apr 17, 2024
1 parent df46c9c commit 0633409
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/fallenbreath/yamlang/YamlangPlugin.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/me/fallenbreath/yamlang/utils/IOUtils.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
26 changes: 26 additions & 0 deletions src/main/java/me/fallenbreath/yamlang/utils/StringUtils.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit 0633409

Please sign in to comment.