mia/build.gradle.kts

186 lines
5.5 KiB
Plaintext
Raw Normal View History

2024-10-19 18:49:44 +00:00
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2024-10-28 23:23:43 +00:00
import org.jetbrains.compose.internal.de.undercouch.gradle.tasks.download.Download
2024-11-02 17:08:33 +00:00
import org.gradle.internal.os.OperatingSystem
2024-10-19 18:49:44 +00:00
plugins {
2024-10-28 00:46:18 +00:00
val kotlinVersion = "2.0.21"
2024-10-28 23:23:43 +00:00
2024-10-28 00:46:18 +00:00
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
2024-10-19 18:49:44 +00:00
id("org.jetbrains.compose")
id("org.jetbrains.kotlin.plugin.compose")
}
group = "xyz.r0r5chach"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
google()
}
dependencies {
// Core
2024-10-19 18:49:44 +00:00
implementation(compose.desktop.currentOs)
2024-10-25 19:52:47 +00:00
// ConstrainLayout
implementation("tech.annexflow.compose:constraintlayout-compose-multiplatform:0.4.0")
// Material Design
implementation(compose.materialIconsExtended)
2024-10-28 23:23:43 +00:00
//Java Native Access
val jnaVersion = "5.15.0"
implementation("net.java.dev.jna:jna:$jnaVersion")
implementation("net.java.dev.jna:jna-platform:$jnaVersion")
//Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
2024-10-19 18:49:44 +00:00
// Voyager
2024-10-28 23:23:43 +00:00
val voyagerVersion = "1.1.0-beta02"
implementation("cafe.adriel.voyager:voyager-navigator:$voyagerVersion")
implementation("cafe.adriel.voyager:voyager-screenmodel:$voyagerVersion")
implementation("cafe.adriel.voyager:voyager-bottom-sheet-navigator:$voyagerVersion")
implementation("cafe.adriel.voyager:voyager-tab-navigator:$voyagerVersion")
implementation("cafe.adriel.voyager:voyager-transitions:$voyagerVersion")
2024-10-28 23:23:43 +00:00
// Speech to Text
implementation("com.alphacephei:vosk:0.3.45")
// Deep Java Library
2024-10-28 23:23:43 +00:00
val djlVersion = "0.30.0"
implementation("ai.djl:api:$djlVersion")
implementation("ai.djl.huggingface:tokenizers:$djlVersion")
implementation("ai.djl.pytorch:pytorch-engine:$djlVersion")
implementation("ai.djl.pytorch:pytorch-jni:2.4.0-$djlVersion")
// Semantic Kernel
implementation("com.microsoft.semantic-kernel:semantickernel-api:1.3.0")
2024-10-25 19:52:47 +00:00
// Logging
2024-10-26 18:07:40 +00:00
implementation("io.github.oshai:kotlin-logging-jvm:7.0.0")
implementation("ch.qos.logback:logback-classic:1.5.11")
2024-10-28 23:23:43 +00:00
// Json
val serializationVersion = "1.5.1"
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
2024-11-02 17:08:33 +00:00
//FileKit
val fileKitVersion = "0.8.7"
implementation("io.github.vinceglb:filekit-core:$fileKitVersion")
implementation("io.github.vinceglb:filekit-compose:$fileKitVersion")
2024-10-19 18:49:44 +00:00
}
2024-11-02 17:08:33 +00:00
val currentOs = OperatingSystem.current()
2024-10-19 18:49:44 +00:00
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
2024-11-02 17:08:33 +00:00
linux {
modules("jdk.security.auth")
}
targetFormats(
*listOf(
TargetFormat.Dmg.takeIf { currentOs.isMacOsX },
TargetFormat.Msi.takeIf { currentOs.isWindows },
TargetFormat.Deb.takeIf { currentOs.isLinux }
).filterNotNull().toTypedArray()
)
2024-10-19 18:49:44 +00:00
packageName = "mia"
packageVersion = "1.0.0"
}
}
}
2024-10-28 23:23:43 +00:00
2024-11-02 17:08:33 +00:00
tasks.register("packageLiteInstaller") {
group = "package project"
2024-10-28 23:23:43 +00:00
description = "Build program with the small vosk STT model"
2024-11-02 17:08:33 +00:00
dependsOn("prepareLiteResources", "package")
2024-10-28 23:23:43 +00:00
}
2024-11-02 17:08:33 +00:00
tasks.register("packageFullInstaller") {
group = "package project"
2024-10-28 23:23:43 +00:00
description = "Build program with the large vosk STT model"
2024-11-02 17:08:33 +00:00
dependsOn("prepareFullResources", "package")
2024-10-28 23:23:43 +00:00
}
tasks.register("generateSemanticModel") {
2024-11-02 17:08:33 +00:00
group = "package project"
2024-10-28 23:23:43 +00:00
description = "Run DJL to generate Semantic model from HuggingFace (all-roberta-large-v1)"
val modelName = "sentence-transformers/all-roberta-large-v1"
val djlOutputDir = project.file("src/main/resources/Semantic-model")
doFirst {
djlOutputDir.deleteRecursively()
}
doLast {
val os = System.getProperty("os.name")
val executable = when {
2024-11-02 17:08:33 +00:00
currentOs.isWindows -> project.file("djl/windows.exe")
currentOs.isMacOsX -> project.file("djl/mac")
currentOs.isLinux -> project.file("djl/linux")
2024-10-28 23:23:43 +00:00
else -> throw GradleException("Unsupported OS: $os")
}
exec {
commandLine = listOf(executable.absolutePath, modelName, djlOutputDir.absolutePath)
}
}
}
val sttOutputDir = project.file("src/main/resources/STT-model")
val modelUrl = "https://alphacephei.com/vosk/models"
val zipFile = layout.buildDirectory.file("STT-model.zip")
tasks.register<Download>("prepareLiteResources") {
2024-11-02 17:08:33 +00:00
group = "package project"
2024-10-28 23:23:43 +00:00
description = "Download small vosk model to resources"
val modelName = "vosk-model-small-en-us-0.15"
doFirst {
sttOutputDir.deleteRecursively()
dependsOn("generateSemanticModel")
}
src("$modelUrl/$modelName.zip")
dest(zipFile)
doLast {
project.copy {
from(project.zipTree(zipFile))
into(sttOutputDir)
}
}
}
tasks.register<Download>("prepareFullResources") {
2024-11-02 17:08:33 +00:00
group = "package project"
2024-10-28 23:23:43 +00:00
description = "Download large vosk model to resources"
val modelName = "vosk-model-en-us-0.22"
doFirst {
sttOutputDir.deleteRecursively()
dependsOn("generateSemanticModel")
}
src("$modelUrl/$modelName.zip")
dest(zipFile)
doLast {
project.copy {
from(project.zipTree(zipFile))
into(sttOutputDir)
}
}
}