1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 10:38:19 +08:00

feat(loader): Refactor loaders and metadata.

This commit is contained in:
2024-01-30 18:01:36 +08:00
parent b912ea369c
commit da3d4d1fd2
114 changed files with 1868 additions and 1772 deletions
+50
View File
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>easyconfiguration-parent</artifactId>
<version>3.9.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
<artifactId>easyconfiguration-feature-file</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>easyconfiguration-core</artifactId>
<version>${project.version}</version>
</dependency>
</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>
@@ -0,0 +1,15 @@
package cc.carm.lib.configuration.option;
import cc.carm.lib.easyoptions.OptionType;
import static cc.carm.lib.easyoptions.OptionType.of;
public class FileConfigOptions {
/**
* Whether to copy files from resource if exists.
*/
OptionType<Boolean> COPY_DEFAULTS = of(true);
}
@@ -0,0 +1,87 @@
//package cc.carm.lib.configuration.core.source.impl;
//
//import org.jetbrains.annotations.NotNull;
//import org.jetbrains.annotations.Nullable;
//
//import java.io.File;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.OutputStream;
//import java.net.URL;
//import java.net.URLConnection;
//import java.nio.file.Files;
//import java.util.Objects;
//
//public abstract class FileConfigProvider<W extends ConfigurationWrapper<?>> extends ConfigurationProvider<W> {
//
// protected final @NotNull File file;
//
// protected FileConfigProvider(@NotNull File file) {
// this.file = file;
// }
//
// public @NotNull File getFile() {
// return file;
// }
//
// public void initializeFile(@Nullable String sourcePath) throws IOException {
// if (this.file.exists()) return;
//
// File parent = this.file.getParentFile();
// if (parent != null && !parent.exists() && !parent.mkdirs()) {
// throw new IOException("Failed to create directory " + file.getParentFile().getAbsolutePath());
// }
//
// if (!this.file.createNewFile()) {
// throw new IOException("Failed to create file " + file.getAbsolutePath());
// }
//
// if (sourcePath != null) {
// try {
// saveResource(sourcePath, true);
// } catch (IllegalArgumentException ignored) {
// }
// }
// }
//
// public void saveResource(@NotNull String resourcePath, boolean replace)
// throws IOException, IllegalArgumentException {
// Objects.requireNonNull(resourcePath, "ResourcePath cannot be null");
// if (resourcePath.isEmpty()) throw new IllegalArgumentException("ResourcePath cannot be empty");
//
// resourcePath = resourcePath.replace('\\', '/');
//
// URL url = this.getClass().getClassLoader().getResource(resourcePath);
// if (url == null) throw new IllegalArgumentException("The resource '" + resourcePath + "' not exists");
//
// File outDir = file.getParentFile();
//
// if (!outDir.exists() && !outDir.mkdirs()) throw new IOException("Failed to create directory " + outDir);
// if (!file.exists() || replace) {
// try (OutputStream out = Files.newOutputStream(file.toPath())) {
// URLConnection connection = url.openConnection();
// connection.setUseCaches(false);
// try (InputStream in = connection.getInputStream()) {
// byte[] buf = new byte[1024];
// int len;
// while ((len = in.read(buf)) > 0) {
// out.write(buf, 0, len);
// }
// }
// }
// }
// }
//
// @Nullable
// public InputStream getResource(@NotNull String filename) {
// try {
// URL url = this.getClass().getClassLoader().getResource(filename);
// if (url == null) return null;
// URLConnection connection = url.openConnection();
// connection.setUseCaches(false);
// return connection.getInputStream();
// } catch (IOException ex) {
// return null;
// }
// }
//}
@@ -0,0 +1,6 @@
package cc.carm.lib.configuration.source;
public class FileConfigSource {
}