-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
127 lines (107 loc) · 4.23 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
val ktorVersion: String by project
val kotlinVersion: String by project
val logbackVersion: String by project
val exposedVersion: String by project
val postgresqlDriverVersion: String by project
val kotestVersion: String by project
val mockkVersion: String by project
// Plugin versions are maintained in settings.gradle.kts, pluginManagement section
plugins {
kotlin("jvm")
id("io.ktor.plugin")
id("org.jetbrains.kotlin.plugin.serialization")
jacoco
}
group = "io.github.terickson87"
version = "0.0.1"
application {
mainClass.set("io.github.terickson87.ktorpostgresdemo.ApplicationKt")
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}
repositories {
mavenCentral()
}
dependencies {
implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-core-jvm:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-cors-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-call-logging-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-metrics-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-call-id-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
// Testing
testImplementation("io.ktor:ktor-server-tests-jvm:$ktorVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
// Ktor client
testImplementation("io.ktor:ktor-client-core:$ktorVersion")
testImplementation("io.ktor:ktor-client-logging:$ktorVersion")
testImplementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
// Kotest
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
testImplementation("io.kotest:kotest-property:$kotestVersion")
// MockK
testImplementation("io.mockk:mockk:$mockkVersion")
// TestContainers
testImplementation("org.testcontainers:postgresql:1.19.5")
// DB
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-crypt:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-java-time:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-json:$exposedVersion")
implementation("org.postgresql:postgresql:$postgresqlDriverVersion")
}
ktor {
docker {
jreVersion.set(JavaVersion.VERSION_21)
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}
tasks.clean {
delete("website")
}
val frontEndNpmInstall = task<Exec>("frontEndNpmInstall") {
group = "FrontEnd"
displayIsRunning()
workingDir("fullstack-frontend-demo-react-vite")
commandLine("npm", "install")
}
val frontEndNpmBuild = task<Exec>("frontEndNpmBuild") {
group = "FrontEnd"
displayIsRunning()
workingDir("fullstack-frontend-demo-react-vite")
commandLine("npm", "run", "build")
}
val frontEndCopyDist = task<Copy>("frontEndCopyDist") {
group = "FrontEnd"
displayIsRunning()
from("fullstack-frontend-demo-react-vite/dist")
into("website")
}
val frontEndClearWebsite = task("frontEndClearWebsite") {
group = "FrontEnd"
displayIsRunning()
doFirst { delete("website") }
}
val frontEndRebuildAndCopy = task("frontEndRebuildAndCopy") {
group = "FrontEnd"
dependsOn(frontEndClearWebsite, frontEndNpmInstall, frontEndNpmBuild, frontEndCopyDist)
frontEndNpmBuild.mustRunAfter(frontEndNpmInstall)
frontEndCopyDist.mustRunAfter(frontEndClearWebsite)
frontEndCopyDist.mustRunAfter(frontEndNpmBuild)
}
fun Task.displayIsRunning() = doFirst { println("Running gradle task: '$name'") }