-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
61 lines (50 loc) · 1.94 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
plugins {
// You can update this to the newest Kotlin version, if you want
kotlin("jvm") version "1.7.0"
// This plugin is used for (de)serialization
kotlin("plugin.serialization") version "1.7.0"
// This is a built-in plugin used for running, building and testing!
application
}
group = "com.example" // Put your name here!
version = "1.0"
// Declares the main class. Change this value if you rename Battlesnake.kt!
val mainName = "com.example.battlesnake.BattlesnakeKt"
// Declares usage of the Maven Central repository
// Do not remove!
repositories {
mavenCentral()
}
dependencies {
// kotlinx.serialization dependencies
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3")
// Ktor dependencies
serverImplementation("core", "netty", "content-negotiation", "default-headers")
ktorImplementation("serialization-kotlinx-json")
// Logging library used by Ktor
// Remove this if you don't want logging
implementation("ch.qos.logback:logback-classic:1.2.11")
}
// Utility functions for declaring dependencies
// This can be simplified by typing out the full Ktor module names,
// but because of the modular structure of Ktor, this will probably work a little bit better for most people
fun DependencyHandlerScope.serverImplementation(vararg names: String) =
names.forEach { ktorImplementation("server-$it") }
fun DependencyHandlerScope.ktorImplementation(name: String) = implementation(
group = "io.ktor",
name = "ktor-$name",
version = "2.0.1"
)
// Declares the creation of a "fat jar"
tasks {
withType<Jar>().configureEach {
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest { attributes("Main-Class" to mainName) }
}
}
// Allows you to run using gradlew
// Specifies the main class we specified earlier
application {
mainClass.set(mainName)
}