This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
232 lines (192 loc) · 7.68 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
* 🥀 hana: API to proxy different APIs like GitHub Sponsors, source code for api.floofy.dev
* Copyright (c) 2020-2022 Noel <cutie@floofy.dev>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import gay.floof.gradle.utils.*
import java.text.SimpleDateFormat
import java.util.Date
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
mavenLocal()
maven {
url = uri("https://maven.floofy.dev/repo/releases")
}
}
dependencies {
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.18.4")
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.13.0")
classpath("gay.floof.utils:gradle-utils:1.3.0")
classpath(kotlin("gradle-plugin", version = "1.6.21"))
classpath(kotlin("serialization", version = "1.6.21"))
}
}
plugins {
kotlin("plugin.serialization") version "1.7.10"
id("com.diffplug.spotless") version "6.13.0"
kotlin("jvm") version "1.7.10"
application
}
apply(plugin = "kotlinx-atomicfu")
val JAVA_VERSION = JavaVersion.VERSION_17
val VERSION = Version(4, 2, 0, 0, ReleaseType.None)
val commitHash by lazy {
val cmd = "git rev-parse --short HEAD".split("\\s".toRegex())
val proc = ProcessBuilder(cmd)
.directory(File("."))
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
proc.waitFor(1, TimeUnit.MINUTES)
proc.inputStream.bufferedReader().readText().trim()
}
group = "gay.floof"
version = "$VERSION"
repositories {
mavenCentral()
mavenLocal()
noel()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://repo.perfectdreams.net/")
}
dependencies {
// Kotlin libraries
implementation(kotlin("reflect"))
implementation(kotlin("stdlib"))
// BOM
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.4.1"))
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4"))
api(platform("software.amazon.awssdk:bom:2.19.28"))
api(platform("io.ktor:ktor-bom:2.2.3"))
// kotlinx.coroutines libraries
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
// kotlinx.serialization libraries
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json")
api("org.jetbrains.kotlinx:kotlinx-serialization-core")
// kotlinx.datetime libraries
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
// Noel Utilities
floof("commons", "commons-slf4j", "1.3.0")
floofy("ktor", "ktor-sentry", "0.0.1")
// Apache Utilities
implementation("org.apache.commons:commons-lang3:3.12.0")
// Ktor Server libraries
implementation("io.ktor:ktor-serialization-kotlinx-json")
implementation("io.ktor:ktor-server-content-negotiation")
implementation("io.ktor:ktor-server-auto-head-response")
implementation("io.ktor:ktor-server-default-headers")
implementation("io.ktor:ktor-server-double-receive")
implementation("io.ktor:ktor-server-call-logging")
implementation("io.ktor:ktor-server-status-pages")
implementation("io.ktor:ktor-serialization")
implementation("io.ktor:ktor-server-netty")
implementation("io.ktor:ktor-server-cors")
// Koin
implementation("io.insert-koin:koin-core:3.3.2")
// Redis (for caching api keys and ratelimits)
implementation("io.lettuce:lettuce-core:6.2.2.RELEASE")
// Logging with logback
implementation("net.logstash.logback:logstash-logback-encoder:7.2")
implementation("ch.qos.logback:logback-classic:1.4.5")
implementation("ch.qos.logback:logback-core:1.4.5")
api("org.slf4j:slf4j-api:2.0.6")
// Conditional logic for logback
implementation("org.codehaus.janino:janino:3.1.9")
// Sentry
implementation("io.sentry:sentry:6.13.0")
implementation("io.sentry:sentry-logback:6.13.0")
// Prometheus (for metrics)
implementation("io.prometheus:simpleclient_hotspot:0.16.0")
implementation("io.prometheus:simpleclient_common:0.16.0")
implementation("io.prometheus:simpleclient:0.16.0")
// Discord Interactions
implementation("net.perfectdreams.discordinteraktions:webserver-ktor-kord:0.0.15")
// Redis (for ratelimiting cache)
implementation("io.lettuce:lettuce-core:6.2.2.RELEASE")
// PostgreSQL (for holding API keys)
api(platform("org.jetbrains.exposed:exposed-bom:0.39.2"))
implementation("org.jetbrains.exposed:exposed-kotlin-datetime")
implementation("org.jetbrains.exposed:exposed-core")
implementation("org.jetbrains.exposed:exposed-jdbc")
implementation("org.jetbrains.exposed:exposed-dao")
implementation("org.postgresql:postgresql:42.5.2")
implementation("com.zaxxer:HikariCP:5.0.1")
// YAML (configuration)
implementation("com.charleskorn.kaml:kaml:0.51.0")
// OkHttp (for ktor client)
implementation("io.ktor:ktor-client-content-negotiation")
implementation("io.ktor:ktor-client-okhttp")
implementation("io.ktor:ktor-client-core")
// Kord
implementation("dev.kord:kord-core:0.8.0-M17")
// JWT
implementation("com.auth0:java-jwt:4.2.2")
// S3
implementation("software.amazon.awssdk:s3")
}
spotless {
kotlin {
trimTrailingWhitespace()
licenseHeaderFile("${rootProject.projectDir}/assets/HEADING")
endWithNewline()
// We can't use the .editorconfig file, so we'll have to specify it here
// issue: https://github.com/diffplug/spotless/issues/142
// ktlint 0.35.0 (default for Spotless) doesn't support trailing commas
ktlint("0.43.0")
.userData(
mapOf(
"no-consecutive-blank-lines" to "true",
"no-unit-return" to "true",
"disabled_rules" to "no-wildcard-imports,colon-spacing",
"indent_size" to "4"
)
)
}
}
application {
mainClass.set("gay.floof.hana.Bootstrap")
}
java {
sourceCompatibility = JAVA_VERSION
targetCompatibility = JAVA_VERSION
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = JAVA_VERSION.toString()
kotlinOptions.javaParameters = true
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
processResources {
filesMatching("build-info.json") {
val date = Date()
val formatter = SimpleDateFormat("EEE, MMM d, YYYY - HH:mm:ss a")
expand(
mapOf(
"version" to rootProject.version,
"commit_sha" to commitHash,
"build_date" to formatter.format(date)
)
)
}
}
}