From fff84fafae5f3ef2763057708f57f76c81c89b45 Mon Sep 17 00:00:00 2001 From: carm Date: Thu, 16 Mar 2023 01:14:35 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/minesql/util/DBPropertiesUtil.java | 2 +- .../plugin/minesql/util/MavenReadUtil.java | 45 ------------------- 2 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 core/src/main/java/cc/carm/plugin/minesql/util/MavenReadUtil.java diff --git a/core/src/main/java/cc/carm/plugin/minesql/util/DBPropertiesUtil.java b/core/src/main/java/cc/carm/plugin/minesql/util/DBPropertiesUtil.java index 86d28b7..ef4e454 100644 --- a/core/src/main/java/cc/carm/plugin/minesql/util/DBPropertiesUtil.java +++ b/core/src/main/java/cc/carm/plugin/minesql/util/DBPropertiesUtil.java @@ -17,7 +17,7 @@ public class DBPropertiesUtil { if (!propertiesFolder.exists() || !propertiesFolder.isDirectory()) return propertiesMap; File[] files = propertiesFolder.listFiles(); - if (files == null || files.length == 0) return propertiesMap; + if (files == null) return propertiesMap; for (File file : files) { if (!validateName(file.getName())) continue; String name = file.getName().substring(0, file.getName().lastIndexOf(".")); diff --git a/core/src/main/java/cc/carm/plugin/minesql/util/MavenReadUtil.java b/core/src/main/java/cc/carm/plugin/minesql/util/MavenReadUtil.java deleted file mode 100644 index e091441..0000000 --- a/core/src/main/java/cc/carm/plugin/minesql/util/MavenReadUtil.java +++ /dev/null @@ -1,45 +0,0 @@ -package cc.carm.plugin.minesql.util; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.InputStream; -import java.util.Properties; - -public class MavenReadUtil { - - public static String getMavenPropertiesPath(@NotNull String groupID, @NotNull String artifactID) { - return String.format("/META-INF/maven/%s/%s/pom.properties", groupID, artifactID); - } - - public static synchronized @Nullable String getVersion(@NotNull Object provider, - @NotNull String groupID, - @NotNull String artifactID) { - String path = getMavenPropertiesPath(groupID, artifactID); - String version = null; - // Using maven properties to get the version - try (InputStream is = provider.getClass().getResourceAsStream(path)) { - if (is != null) { - Properties p = new Properties(); - p.load(is); - version = p.getProperty("version", ""); - } - } catch (Exception ignored) { - } - - if (version != null) return version; - - // Fine, lets try Java API - Package pkg = provider.getClass().getPackage(); - if (pkg != null) { - version = pkg.getImplementationVersion(); - if (version == null) { - version = pkg.getSpecificationVersion(); - } - } - - return version; - } - - -}