From bf93c329b7b296b79c51633094697cdd52be967e Mon Sep 17 00:00:00 2001 From: Jannik Reimers Date: Mon, 16 Jun 2025 02:20:25 +0200 Subject: [PATCH] finish dependency update, also use the newer docker file template haha --- .idea/kotlinc.xml | 2 +- build.gradle.kts | 71 ++++++++++++++++++++++++++++----------- gradle/libs.versions.toml | 11 +++++- 3 files changed, 62 insertions(+), 22 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index bb44937..1e16934 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 56d7e6a..1dff957 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,17 +2,17 @@ import dev.kordex.gradle.plugins.docker.file.* import dev.kordex.gradle.plugins.kordex.DataCollection plugins { - kotlin("jvm") - kotlin("plugin.serialization") + distribution - id("com.github.johnrengelman.shadow") + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.kotlin.serialization) - id("dev.kordex.gradle.docker") - id("dev.kordex.gradle.kordex") + alias(libs.plugins.kordex.plugin) + alias(libs.plugins.kordex.docker) } group = "dev.jansel" -version = "1.1-SNAPSHOT" +version = "1.2-SNAPSHOT" dependencies { @@ -31,9 +31,26 @@ dependencies { implementation(libs.logging) } +// Configure distributions plugin +distributions { + main { + distributionBaseName = project.name + + contents { + // Copy the LICENSE file into the distribution + from("LICENSE") + + // Exclude src/main/dist/README.md + exclude("README.md") + } + } +} + + kordEx { kordExVersion = "2.3.1-SNAPSHOT" jvmTarget = 21 + ignoreIncompatibleKotlinVersion = true bot { // See https://docs.kordex.dev/data-collection.html @@ -58,37 +75,51 @@ docker { // Each function (aside from comment/emptyLine) corresponds to a Dockerfile instruction. // See: https://docs.docker.com/reference/dockerfile/ - from("azul/zulu-openjdk-alpine:21-jre-headless-latest") + from("openjdk:21-jdk-slim") emptyLine() + comment("Create required directories") runShell("mkdir -p /bot/plugins") runShell("mkdir -p /bot/data") - - emptyLine() - - copy("build/libs/$name-*-all.jar", "/bot/bot.jar") + runShell("mkdir -p /dist/out") emptyLine() // Add volumes for locations that you need to persist. This is important! + comment("Declare required volumes") volume("/bot/data") // Storage for data files volume("/bot/plugins") // Plugin ZIP/JAR location emptyLine() + comment("Copy the distribution files into the container") + copy("build/distributions/${project.name}-${project.version}.tar", "/dist") + + emptyLine() + + comment("Extract the distribution files, and prepare them for use") + runShell("tar -xf /dist/${project.name}-${project.version}.tar -C /dist/out") + + if (file("src/main/dist/plugins").isDirectory) { + runShell("mv /dist/out/${project.name}-${project.version}/plugins/* /bot/plugins") + } + + runShell("chmod +x /dist/out/${project.name}-${project.version}/bin/$name") + + emptyLine() + + comment("Clean up unnecessary files") + runShell("rm /dist/${project.name}-${project.version}.tar") + + emptyLine() + + comment("Set the correct working directory") workdir("/bot") emptyLine() - entryPointExec( - "java", "-Xmx2G", - "-jar", "/bot/bot.jar" - ) + comment("Run the distribution start script") + entryPointExec("/dist/out/${project.name}-${project.version}/bin/$name") } } - -tasks.wrapper { - gradleVersion = "8.14.2" - distributionType = Wrapper.DistributionType.BIN -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ecd302d..4766e0d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "2.1.0" # Note: Plugin versions must be updated in the settings.gradle.kts too +kotlin = "2.1.21" # Note: Plugin versions must be updated in the settings.gradle.kts too groovy = "3.0.25" jansi = "2.4.2" @@ -11,6 +11,7 @@ twitch4j = "1.25.0" events4j = "0.12.2" kx-coroutines = "1.10.2" kmongo = "5.2.1" +kordex-gradle = "1.7.1" [libraries] groovy = { module = "org.codehaus.groovy:groovy", version.ref = "groovy" } @@ -24,3 +25,11 @@ logging = { module = "io.github.oshai:kotlin-logging", version.ref = "logging" } twitch4j = { module = "com.github.twitch4j:twitch4j", version.ref = "twitch4j" } events4j = { module = "com.github.philippheuer.events4j:events4j-handler-reactor", version.ref = "events4j" } kmongo = { module="org.litote.kmongo:kmongo-coroutine-serialization", version.ref = "kmongo" } + + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } + +kordex-docker = { id = "dev.kordex.gradle.docker", version.ref = "kordex-gradle" } +kordex-plugin = { id = "dev.kordex.gradle.kordex", version.ref = "kordex-gradle" }