96 lines
2.9 KiB
Kotlin
96 lines
2.9 KiB
Kotlin
plugins {
|
|
kotlin("jvm") version "2.0.21"
|
|
id("org.jetbrains.kotlin.plugin.compose") version "2.0.21"
|
|
id("org.jetbrains.compose") version "1.7.3"
|
|
}
|
|
|
|
group = "com.shonar"
|
|
version = "0.1.0"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(17)
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
kotlin {
|
|
// Portable provider/recording sources vendored into this
|
|
// project (the Android-only files were removed; this app is
|
|
// standalone desktop).
|
|
srcDir("../shared")
|
|
srcDir("src/main/kotlin")
|
|
}
|
|
}
|
|
test {
|
|
kotlin {
|
|
srcDir("src/test/kotlin")
|
|
}
|
|
}
|
|
}
|
|
|
|
// Bake the source commit + build time into the jar so the in-app
|
|
// check-for-updates can tell "this build is current" from "the repo has
|
|
// newer work". Lives on outputs so a new commit invalidates it.
|
|
val generateBuildInfo = tasks.register("generateBuildInfo") {
|
|
val outDir = layout.buildDirectory.dir("generated/shonar/resources")
|
|
outputs.dir(outDir)
|
|
val commit = providers.exec {
|
|
commandLine("git", "-C", rootProject.projectDir.absolutePath,
|
|
"rev-parse", "--short", "HEAD")
|
|
}.standardOutput.asText.map { it.trim() }
|
|
// Register the commit as a task input: without this Gradle calls the
|
|
// task UP-TO-DATE after a new commit and the jar keeps the STALE baked
|
|
// commit (the in-app update check then never reports "up to date").
|
|
inputs.property("commit", commit)
|
|
doLast {
|
|
val dir = outDir.get().asFile
|
|
dir.mkdirs()
|
|
File(dir, "shonar-build.properties").writeText(
|
|
"commit=${commit.get().ifBlank { "unknown" }}\n" +
|
|
"builtAt=${System.currentTimeMillis()}\n",
|
|
)
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
resources.srcDir(generateBuildInfo)
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(compose.desktop.currentOs)
|
|
implementation(compose.material3)
|
|
implementation(compose.materialIconsExtended)
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.9.0")
|
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
|
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
// Real org.json for JVM (Android stubs throw "not mocked").
|
|
implementation("org.json:json:20240303")
|
|
|
|
testImplementation("junit:junit:4.13.2")
|
|
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
|
|
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
|
|
}
|
|
|
|
compose.desktop {
|
|
application {
|
|
mainClass = "com.shonar.desktop.MainKt"
|
|
nativeDistributions {
|
|
targetFormats(org.jetbrains.compose.desktop.application.dsl.TargetFormat.Dmg)
|
|
targetFormats(org.jetbrains.compose.desktop.application.dsl.TargetFormat.Msi)
|
|
targetFormats(org.jetbrains.compose.desktop.application.dsl.TargetFormat.Deb)
|
|
packageName = "shonar-desktop"
|
|
packageVersion = "0.1.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.withType<Test> {
|
|
useJUnit()
|
|
}
|