103 lines
3.2 KiB
Kotlin
103 lines
3.2 KiB
Kotlin
plugins {
|
|
alias(libs.plugins.convention.backend.app)
|
|
alias(libs.plugins.ktor)
|
|
alias(libs.plugins.sqldelight)
|
|
alias(libs.plugins.serialization)
|
|
alias(libs.plugins.convention.koin)
|
|
}
|
|
|
|
sqldelight {
|
|
databases {
|
|
create("AppDatabase") {
|
|
packageName.set("ru.shadowsparky.gigawear.backend")
|
|
dialect("app.cash.sqldelight:postgresql-dialect:2.3.2")
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":apps:giga-wear:common"))
|
|
implementation(project(":libs:backend-base"))
|
|
implementation(project(":libs:base"))
|
|
implementation(project(":libs:http-client"))
|
|
implementation(project(":feature:updater:updater-common"))
|
|
implementation(project(":feature:updater:updater-backend"))
|
|
implementation(project(":feature:chat:chat-common"))
|
|
implementation(project(":feature:chat:chat-backend"))
|
|
|
|
implementation(libs.ktor.server.core.jvm)
|
|
implementation(libs.ktor.server.host.common.jvm)
|
|
implementation(libs.ktor.server.status.pages.jvm)
|
|
implementation(libs.ktor.server.content.negotiation.jvm)
|
|
implementation(libs.ktor.serialization.kotlinx.json.jvm)
|
|
implementation(libs.ktor.server.netty.jvm)
|
|
implementation(libs.ktor.server.auth)
|
|
implementation(libs.ktor.server.auth.jwt)
|
|
implementation(libs.ktor.server.websockets.jvm)
|
|
implementation(libs.ktor.server.cors)
|
|
|
|
implementation(libs.androidx.datastore.preferences.core)
|
|
implementation(libs.jdbc.driver)
|
|
implementation(libs.postgresql)
|
|
implementation(libs.coroutines.extensions)
|
|
}
|
|
|
|
java {
|
|
sourceCompatibility = JavaVersion.toVersion(libs.versions.proj.server.java.get())
|
|
targetCompatibility = JavaVersion.toVersion(libs.versions.proj.server.java.get())
|
|
}
|
|
|
|
group = "ru.shadowsparky.gigawear"
|
|
version = "1.0"
|
|
|
|
val mainClassName = "ru.shadowsparky.gigawear.backend.MainKt"
|
|
|
|
application {
|
|
mainClass.set(mainClassName)
|
|
|
|
val isDevelopment: Boolean = project.ext.has("development")
|
|
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
|
|
}
|
|
|
|
ktor {
|
|
fatJar {
|
|
archiveFileName.set("server-fat.jar")
|
|
}
|
|
}
|
|
|
|
tasks {
|
|
named("build") {
|
|
dependsOn("buildFatJar")
|
|
}
|
|
register<Exec>("deployRemote") {
|
|
dependsOn("buildFatJar")
|
|
commandLine(
|
|
getCommandLine(
|
|
"docker context use remote",
|
|
"docker build . -t gigawear-server",
|
|
"docker context use default"
|
|
)
|
|
)
|
|
notCompatibleWithConfigurationCache("This task uses Exec which is not compatible with configuration cache")
|
|
}
|
|
register<Exec>("deployLocal") {
|
|
dependsOn("buildFatJar")
|
|
commandLine(
|
|
getCommandLine(
|
|
"docker compose down",
|
|
"docker compose up -d --build --force-recreate"
|
|
)
|
|
)
|
|
notCompatibleWithConfigurationCache("This task uses Exec which is not compatible with configuration cache")
|
|
}
|
|
}
|
|
|
|
private fun getCommandLine(vararg commands: String): List<String> {
|
|
val osName = System.getProperty("os.name").lowercase()
|
|
return if (osName.contains("win")) {
|
|
listOf("cmd", "/c") + commands.joinToString(" && ")
|
|
} else {
|
|
listOf("sh", "-c") + commands.joinToString(" && ")
|
|
}
|
|
}
|