From 3a9bf95d773e170a0be95da38a24db6a90d0dffa Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 15 Mar 2025 13:40:49 +0100 Subject: [PATCH] Add deployment tool --- settings.gradle.kts | 21 +++--- tools/deployment/build.gradle.kts | 68 +++++++++++++++++++ .../de/oliver/deployment/Configuration.java | 14 ++++ .../main/java/de/oliver/deployment/Main.java | 14 ++++ 4 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 tools/deployment/build.gradle.kts create mode 100644 tools/deployment/src/main/java/de/oliver/deployment/Configuration.java create mode 100644 tools/deployment/src/main/java/de/oliver/deployment/Main.java diff --git a/settings.gradle.kts b/settings.gradle.kts index 8278b8b3..ef793ba8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,12 +11,15 @@ include(":libraries:common") include(":libraries:jdb") include(":libraries:plugin-tests") -include("libraries:packets:api") -include("libraries:packets:factories") -include("libraries:packets:implementations") -include("libraries:packets:implementations:1_20_6") -include("libraries:packets:implementations:1_21") -include("libraries:packets:implementations:1_21_1") -include("libraries:packets:implementations:1_21_3") -include("libraries:packets:implementations:1_21_4") -include("libraries:packets:test_plugin") \ No newline at end of file +include(":libraries:packets:api") +include(":libraries:packets:factories") +include(":libraries:packets:implementations") +include(":libraries:packets:implementations:1_20_6") +include(":libraries:packets:implementations:1_21") +include(":libraries:packets:implementations:1_21_1") +include(":libraries:packets:implementations:1_21_3") +include(":libraries:packets:implementations:1_21_4") +include(":libraries:packets:test_plugin") + + +include(":tools:deployment") \ No newline at end of file diff --git a/tools/deployment/build.gradle.kts b/tools/deployment/build.gradle.kts new file mode 100644 index 00000000..673a8939 --- /dev/null +++ b/tools/deployment/build.gradle.kts @@ -0,0 +1,68 @@ +import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin.Companion.shadowJar + +plugins { + id("java") + id("maven-publish") + id("com.gradleup.shadow") +} + +group = "de.oliver" +description = "Tool to deploy Minecraft plugins" + +java { + toolchain.languageVersion.set(JavaLanguageVersion.of(23)) +} + +repositories { + mavenCentral() + maven("https://repo.papermc.io/repository/maven-public/") + maven("https://repo.fancyplugins.de/releases") +} + +dependencies { + compileOnly("com.google.code.gson:gson:2.11.0") + implementation("org.jetbrains:annotations:26.0.2") + + implementation("de.oliver.FancyAnalytics:java-sdk:0.0.2") + implementation("de.oliver.FancyAnalytics:logger:0.0.6") + + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.3") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.1") + testImplementation("com.google.code.gson:gson:2.11.0") +} + +tasks { + jar { + manifest { + attributes["Main-Class"] = "de.oliver.deployment.Main" + } + } + + shadowJar{ + archiveClassifier.set("") + } + + compileJava { + options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything + + // Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable. + // See https://openjdk.java.net/jeps/247 for more information. + options.release.set(23) + } + + java { + withSourcesJar() + withJavadocJar() + } + + javadoc { + options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything + } + processResources { + filteringCharset = Charsets.UTF_8.name() // We want UTF-8 for everything + } + + test { + useJUnitPlatform() + } +} diff --git a/tools/deployment/src/main/java/de/oliver/deployment/Configuration.java b/tools/deployment/src/main/java/de/oliver/deployment/Configuration.java new file mode 100644 index 00000000..58c63e3b --- /dev/null +++ b/tools/deployment/src/main/java/de/oliver/deployment/Configuration.java @@ -0,0 +1,14 @@ +package de.oliver.deployment; + +import com.google.gson.annotations.SerializedName; + +public record Configuration( + @SerializedName("project_id") String projectID, + @SerializedName("plugin_jar_path") String pluginJarPath, + String version, + @SerializedName("supported_versions") String[] supportedVersions, + String channel, + @SerializedName("loaders") String[] loaders, + boolean featured +) { +} diff --git a/tools/deployment/src/main/java/de/oliver/deployment/Main.java b/tools/deployment/src/main/java/de/oliver/deployment/Main.java new file mode 100644 index 00000000..20f8db86 --- /dev/null +++ b/tools/deployment/src/main/java/de/oliver/deployment/Main.java @@ -0,0 +1,14 @@ +package de.oliver.deployment; + +import com.google.gson.Gson; + +public class Main { + + private static final Gson GSON = new Gson(); + + public static void main(String[] args) { + String configFilePath = args[0]; + Configuration configuration = GSON.fromJson(configFilePath, Configuration.class); + } + +}