-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
207 lines (171 loc) · 6.19 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import com.google.gradle.osdetector.OsDetector
val kotlinVersion: String by project
val logbackVersion: String by project
val ktorVersion: String by project
plugins {
kotlin("jvm") version "2.0.20"
kotlin("plugin.serialization") version "2.0.20"
id("io.ktor.plugin") version "2.3.12"
id("org.openapi.generator") version "7.8.0"
id("com.google.protobuf") version "0.9.4"
}
group = "com.stabledata"
version = "0.0.1"
application {
mainClass.set("com.stabledata.ApplicationKt")
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}
repositories {
mavenCentral()
}
sourceSets {
main {
java.srcDirs("src/main/kotlin/chores")
proto {
srcDir("src/main/resources/proto") // Specify the proto files location
}
}
}
protobuf {
protoc {
artifact = if (project.extensions.getByType(OsDetector::class).os == "osx") {
"com.google.protobuf:protoc:3.14.0:osx-x86_64"
} else {
"com.google.protobuf:protoc:3.14.0"
}
}
plugins {
create("grpc"){
artifact = "io.grpc:protoc-gen-grpc-java:1.52.1"
}
// create("grpckt") {
// artifact = "com.google.protobuf:protoc-gen-kotlin:3.17.3"
// }
}
generateProtoTasks {
all().forEach { task ->
task.plugins {
create("grpc")
// create("grpckt")
}
// task.builtins {
// create("kotlin")
// }
}
}
}
tasks.register<JavaExec>("migrate") {
group = "Execution"
description = "Run Flyway commands from gradle"
classpath = sourceSets.getByName("main").runtimeClasspath
mainClass.set("com.stabledata.chores.Migrations")
val task = if (project.hasProperty("task")) {
project.property("task") as String
} else {
"migrate" // Default to help if no task is provided
}
// Pass this to the application as an argument
args = listOf(task)
}
tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
openApiValidate {
inputSpec.set("$rootDir/src/main/resources/openapi/doc.yaml")
}
openApiGenerate {
inputSpec.set("$rootDir/src/main/resources/openapi/doc.yaml")
outputDir.set("$rootDir/client")
generatorName.set("typescript")
templateDir.set("$rootDir/src/main/resources/openapi/templates")
additionalProperties.putAll(
mapOf(
"npmPackageName" to "@stabledata/synchro-client",
"npmPackageVersion" to version,
"useObjectParameters" to "true"
)
)
}
tasks.register("generatePackageJson") {
val version = project.findProperty("version")?.toString()
?: throw Exception("Specify a version to build client via -Pversion=123")
doLast {
val packageJsonFile = file("$rootDir/client/package.json")
packageJsonFile.writeText("""
{
"name": "@stabledata/synchro-client",
"version": "$version",
"description": "This client is generated with the open api typescript-fetch template during synchro builds",
"main": "index.ts",
"scripts": {
"build": "tsc"
},
"dependencies": {
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"typescript": "^4.0.0"
}
}
""".trimIndent())
}
}
tasks.named("openApiGenerate").configure {
finalizedBy("generatePackageJson")
}
dependencies {
// ktor core
implementation("io.ktor:ktor-server-core-jvm")
implementation("io.ktor:ktor-server-netty-jvm")
implementation("io.ktor:ktor-server-content-negotiation:2.2.4")
implementation("io.ktor:ktor-server-openapi:$ktorVersion")
implementation("io.ktor:ktor-server-cors:$ktorVersion")
implementation("io.ktor:ktor-server-status-pages:2.0.0")
implementation("io.ktor:ktor-server-auth:$ktorVersion")
implementation("io.ktor:ktor-server-auth-jwt:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
// serialization + json + validation
implementation("io.ktor:ktor-serialization-kotlinx-json:2.2.4")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
implementation("io.github.optimumcode:json-schema-validator:0.2.3")
implementation("io.ktor:ktor-serialization-gson:2.3.1")
implementation("com.google.code.gson:gson:2.9.0")
// grpc
implementation("io.grpc:grpc-netty-shaded:1.48.1")
// FIXME: this is still vulnerable!
// https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-735f-pc8j-v9w8
implementation("io.grpc:grpc-protobuf:1.68.0")
implementation("io.grpc:grpc-stub:1.68.0")
implementation("javax.annotation:javax.annotation-api:1.3.2")
implementation("io.grpc:grpc-services:1.42.1")
// db
implementation("org.postgresql:postgresql:42.7.2")
implementation("com.zaxxer:HikariCP:5.0.1")
implementation("org.jetbrains.exposed:exposed-core:0.40.1")
implementation("org.jetbrains.exposed:exposed-dao:0.40.1")
implementation("org.jetbrains.exposed:exposed-jdbc:0.40.1")
// db chores
implementation("org.flywaydb:flyway-core:10.4.1")
runtimeOnly("org.flywaydb:flyway-database-postgresql:10.17.3")
// misc
implementation("io.github.cdimascio:dotenv-kotlin:6.4.1")
implementation("com.fasterxml.uuid:java-uuid-generator:5.1.0")
// ably
implementation("io.ably:ably-java:1.2.40")
// log
implementation("ch.qos.logback:logback-classic:1.5.7")
implementation("io.github.oshai:kotlin-logging-jvm:5.1.4")
// tests
testImplementation("io.ktor:ktor-server-test-host-jvm")
testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
testImplementation("io.ktor:ktor-server-test-host:$ktorVersion")
testImplementation("io.kotest:kotest-runner-junit5:5.9.0")
testImplementation("io.kotest:kotest-framework-engine:5.9.0")
testImplementation("io.github.serpro69:kotlin-faker:1.16.0")
testImplementation("io.mockk:mockk:1.13.4")
testImplementation("io.grpc:grpc-testing:1.68.0")
}