forked from Blad3Mak3r/Killjoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
170 lines (139 loc) · 4.93 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.language.jvm.tasks.ProcessResources
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
kotlin("jvm") version "1.5.30"
id("com.github.johnrengelman.shadow") version "7.0.0"
application
java
idea
}
val jdaVersion = "4.3.0_323"
val exposedVersion = "0.36.1"
val ktorVersion = "1.6.7"
val coroutinesVersion = "1.6.0"
val logbackVersion = "1.2.10"
val prometheusVersion = "0.14.1"
val sentryVersion = "5.5.1"
val commonsLang = "3.12.0"
group = "dev.killjoy"
val versionObj = Version(0, 15, 10)
version = versionObj.build()
repositories {
mavenCentral()
maven("https://m2.dv8tion.net/releases")
maven("https://dl.bintray.com/kotlin/kotlinx")
maven("https://jitpack.io")
}
dependencies {
//Kotlin
implementation(kotlin("stdlib", "1.5.30"))
implementation(kotlin("serialization", "1.5.30"))
implementation(kotlin("reflect", "1.5.30"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion")
//Reflections
implementation("org.reflections:reflections:0.10.2")
//JDA
implementation("net.dv8tion:JDA:$jdaVersion") { exclude(module = "opus-java") }
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation("io.sentry:sentry:$sentryVersion")
implementation("com.github.minndevelopment:jda-ktx:d460e2a")
//Database
implementation("com.zaxxer:HikariCP:5.0.0")
runtimeOnly("com.impossibl.pgjdbc-ng:pgjdbc-ng:0.8.9")
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-java-time:$exposedVersion")
//Webhooks
implementation("club.minnced:discord-webhooks:0.7.4")
//HugeBot dependencies
implementation("net.hugebot:RateLimiter:1.1")
//HTTP Clients
implementation("com.squareup.okhttp3:okhttp:4.9.3")
//Prometheus
implementation("io.ktor:ktor-server-netty:$ktorVersion")
implementation("io.prometheus:simpleclient:$prometheusVersion")
implementation("io.prometheus:simpleclient_hotspot:$prometheusVersion")
implementation("io.prometheus:simpleclient_common:$prometheusVersion")
//Config
implementation("com.typesafe:config:1.4.1")
implementation("org.json:json:20211205")
implementation("com.xenomachina:kotlin-argparser:2.0.7")
implementation("org.jsoup:jsoup:1.14.3")
//Cache
implementation("org.redisson:redisson:3.16.7") {
exclude(module = "byte-buddy")
exclude(module = "jodd-bean")
exclude(module = "cache-api")
exclude(module = "reactor-core")
exclude(module = "rxjava")
}
//Test
testImplementation("junit:junit:4.13.2")
}
abstract class GenerateAgentsContent : DefaultTask() {
@TaskAction
fun execute() {
println("Generating agents contents...")
}
}
tasks {
named<ShadowJar>("shadowJar") {
println("Building version ${project.version}")
manifest {
attributes["Main-Class"] = "dev.killjoy.Launcher"
}
archiveBaseName.set("Killjoy")
archiveClassifier.set("")
archiveVersion.set("")
dependsOn("processResources")
}
named<ProcessResources>("processResources") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
val tokens = mapOf(
"project.version" to project.version,
"project.revision" to (gitRevision() ?: "NO COMMIT"),
"project.build_number" to (getBuildCI() ?: "NO BUILD NUMBER")
)
from("src/main/resources") {
include("app.properties")
filter<ReplaceTokens>("tokens" to tokens)
}
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
register<GenerateAgentsContent>("generateAgentsContent")
}
class Version(
private val major: Int,
private val minor: Int,
private val patch: Int? = null
) {
private fun getVersion(): String {
return if (patch == null) "$major.$minor"
else "$major.$minor.$patch"
}
fun build(): String = getVersion()
}
fun getBuildCI(): String? {
return System.getenv("BUILD_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?: null
}
fun gitRevision(): String? {
return try {
val gitVersion = org.apache.commons.io.output.ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = gitVersion
}
gitVersion.toString(Charsets.UTF_8).trim()
} catch (e: java.lang.Exception) {
return System.getenv("GITHUB_SHA")?.trim() ?: return null
}
}
application {
mainClass.set("dev.killjoy.Launcher")
}