1
0
Aglaea/build.gradle.kts
Jannik Reimers 61c9fa6731
All checks were successful
Build & Publish / build (push) Successful in 3m45s
banger
2025-04-03 22:44:28 +02:00

133 lines
3.1 KiB
Plaintext

import dev.kordex.gradle.plugins.docker.file.*
import dev.kordex.gradle.plugins.kordex.DataCollection
plugins {
distribution
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.detekt)
alias(libs.plugins.kordex.docker)
alias(libs.plugins.kordex.plugin)
}
group = "dev.jansel.aglaea"
version = "7.2.7"
dependencies {
detektPlugins(libs.detekt)
implementation(libs.kotlin.stdlib)
implementation(libs.kx.ser)
implementation(libs.twitch4j)
implementation(libs.events4j)
implementation(libs.kx.coroutines)
implementation(libs.kmongo)
// Logging dependencies
implementation(libs.groovy)
implementation(libs.jansi)
implementation(libs.logback)
implementation(libs.logback.groovy)
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 {
// https://github.com/gradle/gradle/issues/31383
kordExVersion = libs.versions.kordex.asProvider()
bot {
// See https://docs.kordex.dev/data-collection.html
dataCollection(DataCollection.Standard)
mainClass = "dev.jansel.aglaea.AppKt"
}
i18n {
classPackage = "dev.jansel.aglaea.i18n"
translationBundle = "aglaea.strings"
}
}
detekt {
buildUponDefaultConfig = true
config.from(rootProject.files("detekt.yml"))
}
// Automatically generate a Dockerfile. Set `generateOnBuild` to `false` if you'd prefer to manually run the
// `createDockerfile` task instead of having it run whenever you build.
docker {
// Create the Dockerfile in the root folder.
file(rootProject.file("Dockerfile"))
commands {
// Each function (aside from comment/emptyLine) corresponds to a Dockerfile instruction.
// See: https://docs.docker.com/reference/dockerfile/
from("openjdk:21-jdk-slim")
emptyLine()
comment("Create required directories")
runShell("mkdir -p /bot/plugins")
runShell("mkdir -p /bot/data")
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()
comment("Run the distribution start script")
entryPointExec("/dist/out/${project.name}-${project.version}/bin/$name")
}
}