diff options
| author | Linnea Gräf <nea@nea.moe> | 2023-12-14 18:11:17 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2023-12-14 18:11:17 +0100 |
| commit | a453cc833f52cf1ccd52288edb73c6f0fbc0c7cc (patch) | |
| tree | 27704f77968903b7fb38debf42cefda7ed85b705 /plugin/src/main/kotlin/moe/nea/archenemy/util | |
| parent | 9058126b0d77c315436226a589ade0748d8a2905 (diff) | |
| download | archenemy-a453cc833f52cf1ccd52288edb73c6f0fbc0c7cc.tar.gz archenemy-a453cc833f52cf1ccd52288edb73c6f0fbc0c7cc.tar.bz2 archenemy-a453cc833f52cf1ccd52288edb73c6f0fbc0c7cc.zip | |
Add support for jar merging
Diffstat (limited to 'plugin/src/main/kotlin/moe/nea/archenemy/util')
3 files changed, 50 insertions, 0 deletions
diff --git a/plugin/src/main/kotlin/moe/nea/archenemy/util/DigestUtils.kt b/plugin/src/main/kotlin/moe/nea/archenemy/util/DigestUtils.kt index 4f50000..d2de936 100644 --- a/plugin/src/main/kotlin/moe/nea/archenemy/util/DigestUtils.kt +++ b/plugin/src/main/kotlin/moe/nea/archenemy/util/DigestUtils.kt @@ -1,5 +1,6 @@ package moe.nea.archenemy.util +import org.gradle.api.artifacts.ModuleDependency import java.security.MessageDigest fun MessageDigest.updateField(text: String, value: String) { @@ -11,4 +12,11 @@ fun MessageDigest.updateField(text: String, value: String) { fun MessageDigest.update(text: String) { this.update(text.encodeToByteArray()) +} + +fun MessageDigest.updateGMV(name: String, moduleDependency: ModuleDependency) { + this.updateField( + name, + (moduleDependency.group ?: "") + ":" + moduleDependency.name + ":" + (moduleDependency.version ?: "") + ) }
\ No newline at end of file diff --git a/plugin/src/main/kotlin/moe/nea/archenemy/util/EnvType.kt b/plugin/src/main/kotlin/moe/nea/archenemy/util/EnvType.kt new file mode 100644 index 0000000..72d18b6 --- /dev/null +++ b/plugin/src/main/kotlin/moe/nea/archenemy/util/EnvType.kt @@ -0,0 +1,9 @@ +package moe.nea.archenemy.util + +enum class EnvType(val classifier: String?, val mcp: Int) { + CLIENT("client", 0), + SERVER("server", 1), + COMBINED(null, 2), + DATAGEN("server", 1) + ; +}
\ No newline at end of file diff --git a/plugin/src/main/kotlin/moe/nea/archenemy/util/FSUtil.kt b/plugin/src/main/kotlin/moe/nea/archenemy/util/FSUtil.kt new file mode 100644 index 0000000..0b2f70e --- /dev/null +++ b/plugin/src/main/kotlin/moe/nea/archenemy/util/FSUtil.kt @@ -0,0 +1,33 @@ +package moe.nea.archenemy.util + +import java.io.InputStream +import java.net.URI +import java.nio.file.FileSystem +import java.nio.file.FileSystems +import java.nio.file.Path +import java.util.zip.ZipInputStream +import java.util.zip.ZipOutputStream +import kotlin.io.path.createDirectories +import kotlin.io.path.exists +import kotlin.io.path.inputStream +import kotlin.io.path.outputStream + +// TODO: Figure out license shit with unimined cause i copied some of these utils? +fun Path.zipFs(): FileSystem { + if (!exists()) { + parent.createDirectories() + ZipOutputStream(this.outputStream()).use { } + } + return FileSystems.newFileSystem(URI.create("jar:${toUri()}"), mapOf("create" to true), null) +} + +fun Path.readZipFs(reader: (String, InputStream) -> Unit) { + ZipInputStream(this.inputStream()).use { stream -> + for (entry in generateSequence { stream.nextEntry }) { + if (entry.isDirectory) { + continue + } + reader(entry.name, stream) + } + } +} |
