mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 18:48:20 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 72584f66ac | |||
| 05e055a6f1 | |||
| e52195a8bb | |||
| 9ae21a79fa | |||
| 172098a613 | |||
| 7959783f0d | |||
| e373068017 |
@@ -0,0 +1,9 @@
|
|||||||
|
# EasyConfiguration Javadoc
|
||||||
|
|
||||||
|
基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/EasyConfiguration) 。
|
||||||
|
|
||||||
|
## 如何实现?
|
||||||
|
|
||||||
|
若您也想通过 [Github Actions](https://docs.github.com/en/actions/learn-github-actions)
|
||||||
|
自动部署项目的Javadoc到 [Github Pages](https://pages.github.com/) ,
|
||||||
|
可以参考我的文章 [《自动部署Javadoc到Github Pages》](https://pages.carm.cc/doc/javadoc-in-github.html) 。
|
||||||
@@ -40,14 +40,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
rm -rf docs
|
rm -rf docs
|
||||||
mkdir -vp docs
|
mkdir -vp docs
|
||||||
cp -vrf api/target/apidocs/* docs/
|
cp -vrf core/target/apidocs/* docs/
|
||||||
cp -vrf .documentation/JAVADOC-README.md docs/README.md
|
cp -vrf .documentation/JAVADOC-README.md docs/README.md
|
||||||
|
|
||||||
- name: "Generate the Javadoc sitemap"
|
- name: "Generate the Javadoc sitemap"
|
||||||
id: sitemap
|
id: sitemap
|
||||||
uses: cicirello/generate-sitemap@v1
|
uses: cicirello/generate-sitemap@v1
|
||||||
with:
|
with:
|
||||||
base-url-path: https://carmjos.github.io/EasySQL
|
base-url-path: https://CarmJos.github.io/EasyConfiguration
|
||||||
path-to-root: docs
|
path-to-root: docs
|
||||||
|
|
||||||
- name: "Output stats"
|
- name: "Output stats"
|
||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd docs
|
cd docs
|
||||||
git init
|
git init
|
||||||
git remote add origin git@github.com:CarmJos/EasySQL.git
|
git remote add origin git@github.com:CarmJos/EasyConfiguration.git
|
||||||
git checkout -b gh-pages
|
git checkout -b gh-pages
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "API Document generated."
|
git commit -m "API Document generated."
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
[](https://github.com/CarmJos/EasyConfiguration/releases)
|
[](https://github.com/CarmJos/EasyConfiguration/releases)
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://github.com/CarmJos/EasyConfiguration/actions/workflows/maven.yml)
|
[](https://github.com/CarmJos/EasyConfiguration/actions/workflows/maven.yml)
|
||||||
[](https://www.codefactor.io/repository/github/carmjos/easysql)
|
[](https://www.codefactor.io/repository/github/carmjos/easyconfiguration)
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
|||||||
+22
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
@@ -16,4 +16,25 @@
|
|||||||
<artifactId>easyconfiguration-core</artifactId>
|
<artifactId>easyconfiguration-core</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -18,18 +18,26 @@ public class ConfigInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void initialize(ConfigurationProvider provider, Class<? extends ConfigurationRoot> rootClazz, boolean saveDefault) {
|
public static void initialize(ConfigurationProvider provider, Class<? extends ConfigurationRoot> rootClazz, boolean saveDefault) {
|
||||||
ConfigPath sectionAnnotation = rootClazz.getAnnotation(ConfigPath.class);
|
|
||||||
|
|
||||||
String rootSection = null;
|
String rootSection = null;
|
||||||
|
|
||||||
|
ConfigPath sectionAnnotation = rootClazz.getAnnotation(ConfigPath.class);
|
||||||
if (sectionAnnotation != null && sectionAnnotation.value().length() > 1) {
|
if (sectionAnnotation != null && sectionAnnotation.value().length() > 1) {
|
||||||
rootSection = sectionAnnotation.value();
|
rootSection = sectionAnnotation.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rootSection != null) {
|
||||||
|
//Not usable for null section.
|
||||||
|
ConfigComment comments = rootClazz.getAnnotation(ConfigComment.class);
|
||||||
|
if (comments != null && comments.value().length > 0) {
|
||||||
|
provider.setComments(rootSection, comments.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Class<?> innerClass : rootClazz.getDeclaredClasses()) {
|
for (Class<?> innerClass : rootClazz.getDeclaredClasses()) {
|
||||||
initSection(provider, rootSection, innerClass, saveDefault);
|
initSection(provider, rootSection, innerClass, saveDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Field field : rootClazz.getFields()) {
|
for (Field field : rootClazz.getDeclaredFields()) {
|
||||||
initValue(provider, rootSection, rootClazz, field, saveDefault);
|
initValue(provider, rootSection, rootClazz, field, saveDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,21 +60,22 @@ public class ConfigInitializer {
|
|||||||
provider.setComments(parentSection, comments.value());
|
provider.setComments(parentSection, comments.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Field field : clazz.getFields()) initValue(provider, section, clazz, field, saveDefault);
|
for (Field field : clazz.getDeclaredFields()) initValue(provider, section, clazz, field, saveDefault);
|
||||||
for (Class<?> innerClass : clazz.getDeclaredClasses()) initSection(provider, section, innerClass, saveDefault);
|
for (Class<?> innerClass : clazz.getDeclaredClasses()) initSection(provider, section, innerClass, saveDefault);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initValue(ConfigurationProvider provider, String parentSection, Class<?> clazz, Field field, boolean saveDefault) {
|
private static void initValue(ConfigurationProvider provider, String parentSection, Class<?> clazz, Field field, boolean saveDefault) {
|
||||||
try {
|
try {
|
||||||
|
field.setAccessible(true);
|
||||||
Object object = field.get(clazz);
|
Object object = field.get(clazz);
|
||||||
if (object instanceof ConfigValue<?>) {
|
if (object instanceof ConfigValue<?>) {
|
||||||
initializeValue(
|
initializeValue(
|
||||||
provider, (ConfigValue<?>) object,
|
provider, (ConfigValue<?>) object, saveDefault,
|
||||||
getSectionPath(field.getName(), parentSection, field.getAnnotation(ConfigPath.class)),
|
getSectionPath(field.getName(), parentSection, field.getAnnotation(ConfigPath.class)),
|
||||||
Optional.ofNullable(field.getAnnotation(ConfigComment.class))
|
Optional.ofNullable(field.getAnnotation(ConfigComment.class))
|
||||||
.map(ConfigComment::value).orElse(new String[0]),
|
.map(ConfigComment::value).orElse(new String[0])
|
||||||
saveDefault);
|
);
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException ignored) {
|
} catch (IllegalAccessException ignored) {
|
||||||
}
|
}
|
||||||
@@ -74,7 +83,7 @@ public class ConfigInitializer {
|
|||||||
|
|
||||||
|
|
||||||
public static void initializeValue(@NotNull ConfigurationProvider provider, @NotNull ConfigValue<?> value,
|
public static void initializeValue(@NotNull ConfigurationProvider provider, @NotNull ConfigValue<?> value,
|
||||||
@NotNull String path, @NotNull String[] comments, boolean saveDefault) {
|
boolean saveDefault, @NotNull String path, @NotNull String[] comments) {
|
||||||
value.initialize(provider, path, comments);
|
value.initialize(provider, path, comments);
|
||||||
if (saveDefault && value.getDefaultValue() != null && !provider.getConfiguration().contains(path)) {
|
if (saveDefault && value.getDefaultValue() != null && !provider.getConfiguration().contains(path)) {
|
||||||
value.setDefault();
|
value.setDefault();
|
||||||
@@ -84,16 +93,31 @@ public class ConfigInitializer {
|
|||||||
public static String getSectionPath(@NotNull String name,
|
public static String getSectionPath(@NotNull String name,
|
||||||
@Nullable String parentSection,
|
@Nullable String parentSection,
|
||||||
@Nullable ConfigPath pathAnnotation) {
|
@Nullable ConfigPath pathAnnotation) {
|
||||||
String parent = parentSection != null ? parentSection + "." : "";
|
@NotNull String parent = parentSection != null ? parentSection + "." : "";
|
||||||
if (pathAnnotation != null && pathAnnotation.value().length() > 0) {
|
@NotNull String path = getSectionName(name);
|
||||||
return parent + pathAnnotation.value();
|
boolean root = false;
|
||||||
} else {
|
if (pathAnnotation != null) {
|
||||||
return parent + getSectionName(name);
|
if (pathAnnotation.value().length() > 0) path = pathAnnotation.value();
|
||||||
|
root = pathAnnotation.root();
|
||||||
}
|
}
|
||||||
|
return (root ? "" : parent) + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSectionName(String codeName) {
|
/**
|
||||||
return codeName.toLowerCase().replace("_", "-");
|
* 得到指定元素的配置名称。
|
||||||
|
* 采用 全小写,以“-”链接 的命名规则。
|
||||||
|
*
|
||||||
|
* @param name 源名称
|
||||||
|
* @return 全小写,以“-”链接 的 路径名称
|
||||||
|
*/
|
||||||
|
public static String getSectionName(String name) {
|
||||||
|
return name.replaceAll("[A-Z]", "-$0") // 将驼峰转换为蛇形;
|
||||||
|
.replaceAll("-(.*)", "$1") // 若首字母也为大写,则也会被转换,需要去掉第一个横线
|
||||||
|
.replaceAll("_-([A-Z])", "_$1") // 因为命名中可能包含 _,因此需要被特殊处理一下
|
||||||
|
.replaceAll("([a-z])-([A-Z])", "$1_$2") // 然后将非全大写命名的内容进行转换
|
||||||
|
.replace("-", "") // 移除掉多余的横线
|
||||||
|
.replace("_", "-") // 将下划线替换为横线
|
||||||
|
.toLowerCase(); // 最后转为全小写
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,34 @@
|
|||||||
package cc.carm.lib.configuration.core.annotation;
|
package cc.carm.lib.configuration.core.annotation;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.ConfigInitializer;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于标记对应类或参数的配置路径
|
||||||
|
*/
|
||||||
@Target({ElementType.TYPE, ElementType.FIELD})
|
@Target({ElementType.TYPE, ElementType.FIELD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface ConfigPath {
|
public @interface ConfigPath {
|
||||||
|
|
||||||
String value();
|
/**
|
||||||
|
* 指定路径的值。
|
||||||
|
* 若不指定,则会通过 {@link ConfigInitializer#getSectionName(String)}自动生成当前路径的值。
|
||||||
|
*
|
||||||
|
* @return 路径的值
|
||||||
|
*/
|
||||||
|
String value() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否从根节点开始。
|
||||||
|
* <br>若为 false,则会自动添加上一个路径(如果有)到本节点的路径。
|
||||||
|
* <br>若为 true,则会从根节点开始直接设置本路径。
|
||||||
|
*
|
||||||
|
* @return 是否不继承上一路径,直接从根路径为开始
|
||||||
|
*/
|
||||||
|
boolean root() default false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,30 +11,30 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
public class ConfigBuilder {
|
public class ConfigBuilder {
|
||||||
|
|
||||||
public static <V> @NotNull ConfigValueBuilder<V> asValue(@NotNull Class<V> valueClass) {
|
public <V> @NotNull ConfigValueBuilder<V> asValue(@NotNull Class<V> valueClass) {
|
||||||
return new ConfigValueBuilder<>(valueClass);
|
return new ConfigValueBuilder<>(valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <V> @NotNull ConfigListBuilder<V> asList(@NotNull Class<V> valueClass) {
|
public <V> @NotNull ConfigListBuilder<V> asList(@NotNull Class<V> valueClass) {
|
||||||
return new ConfigListBuilder<>(valueClass);
|
return new ConfigListBuilder<>(valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> asMap(@NotNull Class<K> keyClass,
|
public <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> asMap(@NotNull Class<K> keyClass,
|
||||||
@NotNull Class<V> valueClass) {
|
@NotNull Class<V> valueClass) {
|
||||||
return new ConfigMapBuilder<>(LinkedHashMap::new, keyClass, valueClass);
|
return new ConfigMapBuilder<>(LinkedHashMap::new, keyClass, valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K, V> @NotNull ConfigMapBuilder<HashMap<K, V>, K, V> asHashMap(@NotNull Class<K> keyClass,
|
public <K, V> @NotNull ConfigMapBuilder<HashMap<K, V>, K, V> asHashMap(@NotNull Class<K> keyClass,
|
||||||
@NotNull Class<V> valueClass) {
|
@NotNull Class<V> valueClass) {
|
||||||
return asMap(keyClass, valueClass).supplier(HashMap::new);
|
return asMap(keyClass, valueClass).supplier(HashMap::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> asLinkedMap(@NotNull Class<K> keyClass,
|
public <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> asLinkedMap(@NotNull Class<K> keyClass,
|
||||||
@NotNull Class<V> valueClass) {
|
@NotNull Class<V> valueClass) {
|
||||||
return asMap(keyClass, valueClass);
|
return asMap(keyClass, valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K extends Comparable<K>, V> @NotNull ConfigMapBuilder<TreeMap<K, V>, K, V> asTreeMap(@NotNull Class<K> keyClass,
|
public <K extends Comparable<K>, V> @NotNull ConfigMapBuilder<TreeMap<K, V>, K, V> asTreeMap(@NotNull Class<K> keyClass,
|
||||||
@NotNull Class<V> valueClass) {
|
@NotNull Class<V> valueClass) {
|
||||||
return asMap(keyClass, valueClass).supplier(TreeMap::new);
|
return asMap(keyClass, valueClass).supplier(TreeMap::new);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-7
@@ -22,17 +22,22 @@ public abstract class FileConfigProvider extends ConfigurationProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initializeFile(@Nullable String sourcePath) throws IOException {
|
public void initializeFile(@Nullable String sourcePath) throws IOException {
|
||||||
if (getFile().exists()) return;
|
if (this.file.exists()) return;
|
||||||
if (!getFile().getParentFile().exists() && !getFile().getParentFile().mkdirs()) {
|
|
||||||
|
File parent = this.file.getParentFile();
|
||||||
|
if (parent != null && !parent.exists() && !parent.mkdirs()) {
|
||||||
throw new IOException("Failed to create directory " + file.getParentFile().getAbsolutePath());
|
throw new IOException("Failed to create directory " + file.getParentFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
if (!getFile().createNewFile()) {
|
|
||||||
|
if (!this.file.createNewFile()) {
|
||||||
throw new IOException("Failed to create file " + file.getAbsolutePath());
|
throw new IOException("Failed to create file " + file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
if (sourcePath == null) return;
|
|
||||||
try {
|
if (sourcePath != null) {
|
||||||
saveResource(sourcePath, true);
|
try {
|
||||||
} catch (Exception ignored) {
|
saveResource(sourcePath, true);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package cc.carm.lib.configuration.core.value;
|
package cc.carm.lib.configuration.core.value;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.builder.ConfigBuilder;
|
import cc.carm.lib.configuration.core.builder.ConfigBuilder;
|
||||||
import cc.carm.lib.configuration.core.builder.value.ConfigValueBuilder;
|
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -11,13 +10,9 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public abstract class ConfigValue<T> {
|
public abstract class ConfigValue<T> {
|
||||||
|
|
||||||
public static <V> ConfigValueBuilder<V> builder(Class<V> valueClass) {
|
public static @NotNull ConfigBuilder builder() {
|
||||||
return ConfigBuilder.asValue(valueClass);
|
return new ConfigBuilder();
|
||||||
}
|
|
||||||
|
|
||||||
public static <V> ConfigValue<V> of(Class<V> valueClass) {
|
|
||||||
return builder(valueClass).fromObject().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected @Nullable T defaultValue;
|
protected @Nullable T defaultValue;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cc.carm.lib.configuration.core.value.type;
|
package cc.carm.lib.configuration.core.value.type;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.builder.list.ConfigListBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.configuration.core.value.CachedConfigValue;
|
import cc.carm.lib.configuration.core.value.CachedConfigValue;
|
||||||
@@ -11,6 +12,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ConfiguredList<V> extends CachedConfigValue<List<V>> {
|
public class ConfiguredList<V> extends CachedConfigValue<List<V>> {
|
||||||
|
|
||||||
|
public static <V> @NotNull ConfigListBuilder<V> builder(@NotNull Class<V> valueClass) {
|
||||||
|
return builder().asList(valueClass);
|
||||||
|
}
|
||||||
|
|
||||||
protected final @NotNull Class<V> valueClass;
|
protected final @NotNull Class<V> valueClass;
|
||||||
|
|
||||||
protected final @NotNull ConfigDataFunction<Object, V> parser;
|
protected final @NotNull ConfigDataFunction<Object, V> parser;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ConfiguredMap<K, V> extends CachedConfigValue<Map<K, V>> {
|
|||||||
|
|
||||||
public static <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> builder(@NotNull Class<K> keyClass,
|
public static <K, V> @NotNull ConfigMapBuilder<LinkedHashMap<K, V>, K, V> builder(@NotNull Class<K> keyClass,
|
||||||
@NotNull Class<V> valueClass) {
|
@NotNull Class<V> valueClass) {
|
||||||
return ConfigBuilder.asMap(keyClass, valueClass);
|
return builder().asMap(keyClass, valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final @NotNull Supplier<? extends Map<K, V>> supplier;
|
protected final @NotNull Supplier<? extends Map<K, V>> supplier;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package cc.carm.lib.configuration.core.value.type;
|
package cc.carm.lib.configuration.core.value.type;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.builder.ConfigBuilder;
|
||||||
|
import cc.carm.lib.configuration.core.builder.value.SectionValueBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
@@ -13,6 +15,10 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class ConfiguredSection<V> extends CachedConfigValue<V> {
|
public class ConfiguredSection<V> extends CachedConfigValue<V> {
|
||||||
|
|
||||||
|
public static <V> @NotNull SectionValueBuilder<V> builder(@NotNull Class<V> valueClass) {
|
||||||
|
return builder().asValue(valueClass).fromSection();
|
||||||
|
}
|
||||||
|
|
||||||
protected final @NotNull Class<V> valueClass;
|
protected final @NotNull Class<V> valueClass;
|
||||||
|
|
||||||
protected final @NotNull ConfigValueParser<ConfigurationWrapper, V> parser;
|
protected final @NotNull ConfigValueParser<ConfigurationWrapper, V> parser;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package cc.carm.lib.configuration.core.value.type;
|
package cc.carm.lib.configuration.core.value.type;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.builder.ConfigBuilder;
|
||||||
|
import cc.carm.lib.configuration.core.builder.value.ConfigValueBuilder;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
||||||
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
@@ -11,6 +13,18 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class ConfiguredValue<V> extends CachedConfigValue<V> {
|
public class ConfiguredValue<V> extends CachedConfigValue<V> {
|
||||||
|
|
||||||
|
public static <V> ConfigValueBuilder<V> builder(Class<V> valueClass) {
|
||||||
|
return builder().asValue(valueClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <V> ConfiguredValue<V> of(Class<V> valueClass) {
|
||||||
|
return of(valueClass, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <V> ConfiguredValue<V> of(Class<V> valueClass, @Nullable V defaultValue) {
|
||||||
|
return builder(valueClass).fromObject().defaults(defaultValue).build();
|
||||||
|
}
|
||||||
|
|
||||||
protected final @NotNull Class<V> valueClass;
|
protected final @NotNull Class<V> valueClass;
|
||||||
|
|
||||||
protected final @NotNull ConfigValueParser<Object, V> parser;
|
protected final @NotNull ConfigValueParser<Object, V> parser;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import cc.carm.lib.configuration.core.ConfigInitializer;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class NameTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onTest() {
|
||||||
|
|
||||||
|
System.out.println(ConfigInitializer.getSectionName("LoveGames")); // -> love-games
|
||||||
|
System.out.println(ConfigInitializer.getSectionName("EASY_GAME")); // -> easy-game
|
||||||
|
System.out.println(ConfigInitializer.getSectionName("F")); //-? f
|
||||||
|
System.out.println(ConfigInitializer.getSectionName("Test123123")); // -? test123123123
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+22
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.6</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -35,5 +35,26 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -11,7 +11,7 @@ public class EasyConfiguration {
|
|||||||
YamlConfigProvider provider = new YamlConfigProvider(file);
|
YamlConfigProvider provider = new YamlConfigProvider(file);
|
||||||
try {
|
try {
|
||||||
provider.initializeFile(source);
|
provider.initializeFile(source);
|
||||||
provider.initialize();
|
provider.initializeConfig();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class YamlConfigProvider extends FileConfigProvider {
|
|||||||
super(file);
|
super(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() {
|
public void initializeConfig() {
|
||||||
this.configuration = CommentedYamlConfiguration.loadConfiguration(comments, file);
|
this.configuration = CommentedYamlConfiguration.loadConfiguration(comments, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package config;
|
package config;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.EasyConfiguration;
|
import cc.carm.lib.configuration.EasyConfiguration;
|
||||||
import cc.carm.lib.configuration.core.ConfigInitializer;
|
|
||||||
import cc.carm.lib.configuration.yaml.YamlConfigProvider;
|
import cc.carm.lib.configuration.yaml.YamlConfigProvider;
|
||||||
import config.misc.TestUser;
|
import config.misc.TestUser;
|
||||||
import config.source.TestConfiguration;
|
import config.source.DemoConfiguration;
|
||||||
|
import config.source.ComplexConfiguration;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -19,27 +19,28 @@ public class ConfigTester {
|
|||||||
public void onTest() {
|
public void onTest() {
|
||||||
|
|
||||||
YamlConfigProvider provider = EasyConfiguration.from("target/config.yml", "config.yml");
|
YamlConfigProvider provider = EasyConfiguration.from("target/config.yml", "config.yml");
|
||||||
ConfigInitializer.initialize(provider, TestConfiguration.class, true);
|
provider.initialize(DemoConfiguration.class);
|
||||||
|
provider.initialize(ComplexConfiguration.class);
|
||||||
|
|
||||||
System.out.println("before: " + TestConfiguration.Sub.UUID_CONFIG_VALUE.get());
|
System.out.println("before: " + ComplexConfiguration.Sub.UUID_CONFIG_VALUE.get());
|
||||||
TestConfiguration.Sub.UUID_CONFIG_VALUE.set(UUID.randomUUID());
|
ComplexConfiguration.Sub.UUID_CONFIG_VALUE.set(UUID.randomUUID());
|
||||||
System.out.println("after: " + TestConfiguration.Sub.UUID_CONFIG_VALUE.get());
|
System.out.println("after: " + ComplexConfiguration.Sub.UUID_CONFIG_VALUE.get());
|
||||||
|
|
||||||
|
|
||||||
TestConfiguration.Sub.That.Operators.getNotNull().forEach(System.out::println);
|
ComplexConfiguration.Sub.That.Operators.getNotNull().forEach(System.out::println);
|
||||||
List<UUID> operators = IntStream.range(0, 5).mapToObj(i -> UUID.randomUUID()).collect(Collectors.toList());
|
List<UUID> operators = IntStream.range(0, 5).mapToObj(i -> UUID.randomUUID()).collect(Collectors.toList());
|
||||||
TestConfiguration.Sub.That.Operators.set(operators);
|
ComplexConfiguration.Sub.That.Operators.set(operators);
|
||||||
|
|
||||||
System.out.println(TestConfiguration.USER.get());
|
System.out.println(ComplexConfiguration.USER.get());
|
||||||
TestUser b = new TestUser(UUID.randomUUID().toString().substring(0, 3), UUID.randomUUID());
|
TestUser b = new TestUser(UUID.randomUUID().toString().substring(0, 3), UUID.randomUUID());
|
||||||
TestConfiguration.USER.set(b);
|
ComplexConfiguration.USER.set(b);
|
||||||
|
|
||||||
TestConfiguration.USERS.getNotNull().forEach((k, v) -> System.out.println(k + ": " + v));
|
ComplexConfiguration.USERS.getNotNull().forEach((k, v) -> System.out.println(k + ": " + v));
|
||||||
LinkedHashMap<Integer, UUID> data = new LinkedHashMap<>();
|
LinkedHashMap<Integer, UUID> data = new LinkedHashMap<>();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
data.put((int) (1000 * Math.random()), UUID.randomUUID());
|
data.put((int) (1000 * Math.random()), UUID.randomUUID());
|
||||||
}
|
}
|
||||||
TestConfiguration.USERS.set(data);
|
ComplexConfiguration.USERS.set(data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
provider.save();
|
provider.save();
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package config.misc;
|
package config.misc;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.source.ConfigurationWrapper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TestUser {
|
public class TestUser {
|
||||||
@@ -28,6 +33,23 @@ public class TestUser {
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull Map<String, Object> serialize() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("name", name);
|
||||||
|
Map<String, Object> map2 = new HashMap<>();
|
||||||
|
map2.put("uuid", uuid.toString());
|
||||||
|
map.put("info", map2);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TestUser deserialize(ConfigurationWrapper section) throws Exception {
|
||||||
|
String name = section.getString("name");
|
||||||
|
if (name == null) throw new NullPointerException("name is null");
|
||||||
|
String uuidString = section.getString("info.uuid");
|
||||||
|
if (uuidString == null) throw new NullPointerException("uuid is null");
|
||||||
|
return new TestUser(name, UUID.fromString(uuidString));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TestUser{" +
|
return "TestUser{" +
|
||||||
|
|||||||
+18
-20
@@ -3,9 +3,11 @@ package config.source;
|
|||||||
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
||||||
import cc.carm.lib.configuration.core.annotation.ConfigComment;
|
import cc.carm.lib.configuration.core.annotation.ConfigComment;
|
||||||
import cc.carm.lib.configuration.core.annotation.ConfigPath;
|
import cc.carm.lib.configuration.core.annotation.ConfigPath;
|
||||||
import cc.carm.lib.configuration.core.builder.ConfigBuilder;
|
|
||||||
import cc.carm.lib.configuration.core.util.MapFactory;
|
|
||||||
import cc.carm.lib.configuration.core.value.ConfigValue;
|
import cc.carm.lib.configuration.core.value.ConfigValue;
|
||||||
|
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
|
||||||
|
import cc.carm.lib.configuration.core.value.type.ConfiguredMap;
|
||||||
|
import cc.carm.lib.configuration.core.value.type.ConfiguredSection;
|
||||||
|
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
||||||
import config.misc.TestUser;
|
import config.misc.TestUser;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -13,41 +15,37 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TestConfiguration extends ConfigurationRoot {
|
public class ComplexConfiguration extends ConfigurationRoot {
|
||||||
|
|
||||||
@ConfigComment({"User测试"})
|
@ConfigComment({"User测试"})
|
||||||
public static final ConfigValue<TestUser> USER = ConfigBuilder
|
public static final ConfigValue<TestUser> USER = ConfiguredSection
|
||||||
.asValue(TestUser.class).fromSection()
|
.builder(TestUser.class)
|
||||||
.defaults(new TestUser("Carm", UUID.randomUUID()))
|
.defaults(new TestUser("Carm", UUID.randomUUID()))
|
||||||
.parseValue((section, defaultValue) -> new TestUser(
|
.parseValue((section, defaultValue) -> TestUser.deserialize(section))
|
||||||
section.getString("name"),
|
.serializeValue(TestUser::serialize).build();
|
||||||
UUID.fromString(section.getString("user.uuid", UUID.randomUUID().toString()))
|
|
||||||
)).serializeValue(user -> MapFactory.<String, Object>linkedMap()
|
|
||||||
.put("name", user.getName())
|
|
||||||
.put("user.uuid", user.getUuid().toString())
|
|
||||||
.build()
|
|
||||||
).build();
|
|
||||||
|
|
||||||
@ConfigComment({"[ID-UUID] 对照表", "", "用于测试Map类型的解析与序列化保存"})
|
@ConfigComment({"[ID-UUID] 对照表", "", "用于测试Map类型的解析与序列化保存"})
|
||||||
public static final ConfigValue<Map<Integer, UUID>> USERS = ConfigBuilder
|
public static final ConfigValue<Map<Integer, UUID>> USERS = ConfiguredMap
|
||||||
.asMap(Integer.class, UUID.class).fromString()
|
.builder(Integer.class, UUID.class).fromString()
|
||||||
.parseKey(Integer::parseInt)
|
.parseKey(Integer::parseInt)
|
||||||
.parseValue(v -> Objects.requireNonNull(UUID.fromString(v)))
|
.parseValue(v -> Objects.requireNonNull(UUID.fromString(v)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static class Sub {
|
public static class Sub {
|
||||||
|
|
||||||
@ConfigPath("uuid")
|
@ConfigPath(value = "uuid", root = true)
|
||||||
public static final ConfigValue<UUID> UUID_CONFIG_VALUE = ConfigBuilder
|
public static final ConfigValue<UUID> UUID_CONFIG_VALUE = ConfiguredValue
|
||||||
.asValue(UUID.class).fromString()
|
.builder(UUID.class).fromString()
|
||||||
.parseValue((data, defaultValue) -> UUID.fromString(data))
|
.parseValue((data, defaultValue) -> UUID.fromString(data))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ConfigPath("nothing")
|
@ConfigPath("nothing")
|
||||||
public static class That {
|
public static class That {
|
||||||
|
|
||||||
public static final ConfigValue<List<UUID>> Operators = ConfigBuilder.asList(UUID.class).fromString()
|
public static final ConfigValue<List<UUID>> Operators = ConfiguredList
|
||||||
.parseValue(s -> Objects.requireNonNull(UUID.fromString(s))).build();
|
.builder(UUID.class).fromString()
|
||||||
|
.parseValue(s -> Objects.requireNonNull(UUID.fromString(s)))
|
||||||
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package config.source;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
||||||
|
import cc.carm.lib.configuration.core.annotation.ConfigComment;
|
||||||
|
import cc.carm.lib.configuration.core.annotation.ConfigPath;
|
||||||
|
import cc.carm.lib.configuration.core.value.ConfigValue;
|
||||||
|
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
||||||
|
|
||||||
|
@ConfigPath("database")
|
||||||
|
@ConfigComment({"数据库配置", " 用于提供数据库连接,进行数据库操作。"})
|
||||||
|
public class DemoConfiguration extends ConfigurationRoot {
|
||||||
|
|
||||||
|
@ConfigPath(root = true)
|
||||||
|
@ConfigComment({
|
||||||
|
"有时候,需要在配置文件最上面显示点东西,",
|
||||||
|
"此时就推荐添加一个可以用到但并不重要的参数到最上面",
|
||||||
|
"并给他添加对应的注释。"
|
||||||
|
})
|
||||||
|
protected static final ConfigValue<Double> VERSION = ConfiguredValue.of(Double.class, 1.0D);
|
||||||
|
|
||||||
|
|
||||||
|
@ConfigPath("driver")
|
||||||
|
@ConfigComment({
|
||||||
|
"数据库驱动配置,请根据数据库类型设置。",
|
||||||
|
"- MySQL: com.mysql.cj.jdbc.Driver",
|
||||||
|
"- MariaDB(推荐): org.mariadb.jdbc.Driver",
|
||||||
|
})
|
||||||
|
protected static final ConfigValue<String> DRIVER_NAME = ConfiguredValue.of(
|
||||||
|
String.class, "com.mysql.cj.jdbc.Driver"
|
||||||
|
);
|
||||||
|
|
||||||
|
protected static final ConfigValue<String> HOST = ConfiguredValue.of(String.class, "127.0.0.1");
|
||||||
|
protected static final ConfigValue<Integer> PORT = ConfiguredValue.of(Integer.class, 3306);
|
||||||
|
|
||||||
|
protected static final ConfigValue<String> DATABASE = ConfiguredValue.of(String.class, "minecraft");
|
||||||
|
protected static final ConfigValue<String> USERNAME = ConfiguredValue.of(String.class, "root");
|
||||||
|
protected static final ConfigValue<String> PASSWORD = ConfiguredValue.of(String.class, "password");
|
||||||
|
|
||||||
|
protected static final ConfigValue<String> EXTRA = ConfiguredValue.of(String.class, "?useSSL=false");
|
||||||
|
|
||||||
|
protected static String buildJDBC() {
|
||||||
|
return String.format("jdbc:mysql://%s:%s/%s%s",
|
||||||
|
HOST.get(), PORT.get(), DATABASE.get(), EXTRA.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
something: 123123
|
# Test Header
|
||||||
|
version: 1.0
|
||||||
+22
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.6</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -44,4 +44,25 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -11,7 +11,7 @@ public class EasyConfiguration {
|
|||||||
BungeeConfigProvider provider = new BungeeConfigProvider(file);
|
BungeeConfigProvider provider = new BungeeConfigProvider(file);
|
||||||
try {
|
try {
|
||||||
provider.initializeFile(source);
|
provider.initializeFile(source);
|
||||||
provider.initialize();
|
provider.initializeConfig();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public class BungeeConfigProvider extends FileConfigProvider {
|
|||||||
super(file);
|
super(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() throws IOException {
|
public void initializeConfig() throws IOException {
|
||||||
this.configuration = getLoader().load(file);
|
this.configuration = getLoader().load(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.6</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -35,5 +35,26 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -12,7 +12,7 @@ public class EasyConfiguration {
|
|||||||
SpigotConfigProvider provider = new SpigotConfigProvider(file);
|
SpigotConfigProvider provider = new SpigotConfigProvider(file);
|
||||||
try {
|
try {
|
||||||
provider.initializeFile(source);
|
provider.initializeFile(source);
|
||||||
provider.initialize();
|
provider.initializeConfig();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ public class SpigotConfigProvider extends FileConfigProvider {
|
|||||||
super(file);
|
super(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() {
|
public void initializeConfig() {
|
||||||
this.configuration = CommentedYamlConfiguration.loadConfiguration(comments, file);
|
this.configuration = CommentedYamlConfiguration.loadConfiguration(comments, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.0.0</version>
|
<version>1.0.6</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
|
|
||||||
@@ -123,6 +123,10 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.2</version>
|
||||||
|
<configuration>
|
||||||
|
<useSystemClassLoader>false</useSystemClassLoader>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -247,14 +251,6 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.2</version>
|
|
||||||
<configuration>
|
|
||||||
<useSystemClassLoader>false</useSystemClassLoader>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|||||||
Reference in New Issue
Block a user