-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
105 lines (91 loc) · 3.03 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
105 lines (91 loc) · 3.03 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import com.github.gradle.node.npm.task.NpmTask
val ktorVersion: String by project
val kotlinVersion: String by project
val logbackVersion: String by project
val comprehensionVersion: String by project
plugins {
application
kotlin("jvm") version "2.0.0"
id("io.ktor.plugin") version "2.3.11"
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.0"
id("com.github.node-gradle.node") version "7.0.2"
id("com.github.johnrengelman.shadow") version "8.1.1"
}
group = "icu.takeneko"
version = comprehensionVersion
application {
mainClass = "icu.takeneko.comprehension.ApplicationKt"
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation("io.ktor:ktor-server-core-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-auth-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-auto-head-response-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-call-logging-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-cors-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-caching-headers-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-resources:$ktorVersion")
testImplementation("io.ktor:ktor-server-tests:$ktorVersion")
}
val yarnBuild = task<NpmTask>("yarnBuild") {
workingDir = file("frontend/comprehension")
args.set(listOf("run", "build"))
}
val copyDistFolder = tasks.register<Copy>("copyDistFolder") {
delete(file("src/main/resources/dist"))
from(file("frontend/comprehension/dist"))
into(file("src/main/resources/dist"))
}
var env = System.getProperty("env") ?: "production"
tasks.processResources {
outputs.upToDateWhen { false }
filesMatching("*.conf") {
when (env) {
"development" -> {
expand(
"KTOR_ENV" to "dev",
"KTOR_PORT" to "8081",
"KTOR_MODULE" to "build",
"KTOR_AUTORELOAD" to "true"
)
}
"production" -> {
expand(
"KTOR_ENV" to "production",
"KTOR_PORT" to "80",
"KTOR_MODULE" to "",
"KTOR_AUTORELOAD" to "false"
)
}
}
}
}
val setDev = tasks.register("setDev") {
env = "development"
}
tasks {
"run" {
dependsOn(setDev)
}
"copyDistFolder" {
dependsOn(yarnBuild)
}
"processResources" {
dependsOn(copyDistFolder)
}
shadowJar {
}
kotlin {
jvmToolchain(17)
}
}