The Kotlin/Wasm client can be hosted separately from the API. Bearer auth does not use cookies, so a permissive CORS policy is safe and keeps the static bundle deployable anywhere.
130 lines
4.0 KiB
Kotlin
130 lines
4.0 KiB
Kotlin
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
|
|
plugins {
|
|
kotlin("jvm") version "2.1.20"
|
|
kotlin("plugin.serialization") version "2.1.20"
|
|
application
|
|
id("com.gradleup.shadow") version "8.3.6"
|
|
}
|
|
|
|
group = "win.taptap"
|
|
version = "0.1.0"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(21)
|
|
compilerOptions {
|
|
jvmTarget.set(JvmTarget.JVM_21)
|
|
}
|
|
}
|
|
|
|
application {
|
|
mainClass.set("win.taptap.musicmanager.ApplicationKt")
|
|
}
|
|
|
|
dependencies {
|
|
// Ktor
|
|
implementation("io.ktor:ktor-server-core-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-server-netty-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-server-content-negotiation-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-server-partial-content-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-server-status-pages-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-server-call-logging-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-server-auto-head-response-jvm:3.1.2")
|
|
implementation("io.ktor:ktor-server-cors-jvm:3.1.2")
|
|
|
|
// Database
|
|
implementation("org.jetbrains.exposed:exposed-core:0.60.0")
|
|
implementation("org.jetbrains.exposed:exposed-jdbc:0.60.0")
|
|
implementation("org.jetbrains.exposed:exposed-java-time:0.60.0")
|
|
implementation("org.xerial:sqlite-jdbc:3.49.1.0")
|
|
implementation("com.zaxxer:HikariCP:6.2.1")
|
|
implementation("org.flywaydb:flyway-core:11.8.2")
|
|
|
|
// Media
|
|
implementation("net.jthink:jaudiotagger:3.0.1")
|
|
implementation("net.coobird:thumbnailator:0.4.20")
|
|
|
|
// Config & logging
|
|
implementation("org.yaml:snakeyaml:2.7")
|
|
implementation("ch.qos.logback:logback-classic:1.5.17")
|
|
implementation("io.github.oshai:kotlin-logging-jvm:7.0.0")
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
|
|
|
|
// Tests
|
|
testImplementation("io.ktor:ktor-server-test-host-jvm:3.1.2")
|
|
testImplementation(kotlin("test-junit5"))
|
|
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
testLogging {
|
|
events("passed", "skipped", "failed")
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Prepares a local development checkout: creates the media directories and copies
|
|
* the example configs when they are missing. Existing files are never overwritten.
|
|
*/
|
|
val setupLocal by tasks.registering {
|
|
group = "application"
|
|
description = "Create local media folders and copy example configs if missing."
|
|
|
|
doLast {
|
|
project.mkdir("media/music")
|
|
project.mkdir("media/longform")
|
|
|
|
listOf("library", "users").forEach { name ->
|
|
val target = project.file("config/$name.yaml")
|
|
val example = project.file("config/$name.example.yaml")
|
|
if (!target.exists()) {
|
|
target.parentFile.mkdirs()
|
|
example.copyTo(target)
|
|
println("Created config/$name.yaml from config/$name.example.yaml")
|
|
} else {
|
|
println("Keeping existing config/$name.yaml")
|
|
}
|
|
}
|
|
|
|
val libraryConfig = project.file("config/library.yaml")
|
|
if (libraryConfig.exists()) {
|
|
val stale = libraryConfig.readText().lineSequence()
|
|
.map { it.trim() }
|
|
.filter { it.startsWith("path:") }
|
|
.map { it.removePrefix("path:").trim() }
|
|
.filter { it.startsWith("/mnt/media/") }
|
|
.toList()
|
|
if (stale.isNotEmpty()) {
|
|
logger.warn(
|
|
"config/library.yaml still points at /mnt/media paths that are not available " +
|
|
"locally: $stale. Replace it with the local example: " +
|
|
"cp config/library.example.yaml config/library.yaml",
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.named("run") {
|
|
dependsOn(setupLocal)
|
|
}
|
|
|
|
tasks.withType<JavaCompile>().configureEach {
|
|
options.encoding = "UTF-8"
|
|
}
|
|
|
|
tasks.shadowJar {
|
|
archiveClassifier.set("all")
|
|
mergeServiceFiles()
|
|
}
|
|
|
|
tasks.build {
|
|
dependsOn(tasks.shadowJar)
|
|
}
|