52 lines
1.4 KiB
Kotlin
52 lines
1.4 KiB
Kotlin
import io.ktor.plugin.features.DockerImageRegistry
|
|
|
|
val ktor_version: String = "3.3.0"
|
|
val kotlin_version: String = "2.2.0"
|
|
|
|
plugins {
|
|
kotlin("jvm") version "2.2.0"
|
|
application
|
|
id("io.ktor.plugin") version "3.3.1"
|
|
}
|
|
|
|
group = "org.example"
|
|
version = "1.0-SNAPSHOT"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
application {
|
|
mainClass.set("MainKt")
|
|
}
|
|
|
|
dependencies {
|
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
|
|
implementation("io.ktor:ktor-server-core:$ktor_version")
|
|
implementation("io.ktor:ktor-server-netty:$ktor_version")
|
|
implementation("io.ktor:ktor-server-sessions:${ktor_version}")
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
}
|
|
kotlin {
|
|
jvmToolchain(21)
|
|
}
|
|
|
|
tasks {
|
|
val fatJar = register<Jar>("fatJar") {
|
|
dependsOn.addAll(listOf("compileJava", "compileKotlin", "processResources")) // We need this for Gradle optimization to work
|
|
archiveClassifier.set("standalone") // Naming the jar
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
manifest { attributes(mapOf("Main-Class" to application.mainClass)) } // Provided we set it up in the application plugin configuration
|
|
val sourcesMain = sourceSets.main.get()
|
|
val contents = configurations.runtimeClasspath.get()
|
|
.map { if (it.isDirectory) it else zipTree(it) } +
|
|
sourcesMain.output
|
|
from(contents)
|
|
}
|
|
build {
|
|
dependsOn(fatJar) // Trigger fat jar creation during build
|
|
}
|
|
} |