-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
230 lines (191 loc) · 7.05 KB
/
build.gradle.kts
File metadata and controls
230 lines (191 loc) · 7.05 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
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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
embeddedKotlin("jvm")
embeddedKotlin("plugin.serialization")
id("org.jetbrains.dokka") version "1.8.20"
id("com.google.devtools.ksp") version "1.9.0-1.0.13"
id("io.gitlab.arturbosch.detekt") version "1.23.1"
`java-library`
`maven-publish`
jacoco
}
val javaVersion get() = JavaVersion.VERSION_17
val javaVersionString get() = javaVersion.toString()
val javaVersionInt get() = javaVersionString.toInt()
detekt {
// Allows having different behavior for CI.
// When building a branch, we want to fail the build if detekt fails.
// When building a PR, we want to ignore failures to report them in sonar.
val envIgnoreFailures = System.getenv("DETEKT_IGNORE_FAILURES")?.toBooleanStrictOrNull() ?: false
ignoreFailures = envIgnoreFailures
config.from(file("config/detekt/detekt.yml"))
}
jacoco {
reportsDirectory.set(file("${layout.buildDirectory.get()}/reports/jacoco"))
}
repositories {
mavenCentral()
maven("https://jitpack.io")
}
dependencies {
val ktorVersion = "2.3.3"
val ktSerializationVersion = "1.5.1"
val coroutinesCoreVersion = "1.7.3"
val loggingVersion = "3.0.5"
val mockkVersion = "1.13.5"
val junitVersion = "5.10.0"
val testContainersVersion = "1.18.3"
val lettuceVersion = "6.2.3.RELEASE"
val mojangApi = "v1.0.1"
val nettyCodecVersion = "4.1.96.Final"
val assertJcoreVersion = "3.24.2"
val komapperVersion = "1.12.0"
val kotestVersion = "5.7.1"
api(kotlin("stdlib"))
api(kotlin("reflect"))
api("com.github.Rushyverse:mojang-api:$mojangApi")
// Ktor to interact with external API through HTTP
api("io.ktor:ktor-client-core:$ktorVersion")
api("io.ktor:ktor-client-cio:$ktorVersion")
api("io.ktor:ktor-client-serialization:$ktorVersion")
api("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
api("io.ktor:ktor-client-content-negotiation:$ktorVersion")
// Kotlin Serialization to serialize data for database and cache
api("org.jetbrains.kotlinx:kotlinx-serialization-json:$ktSerializationVersion")
api("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$ktSerializationVersion")
// Interact with database
platform("org.komapper:komapper-platform:$komapperVersion").let {
api(it)
ksp(it)
}
api("org.komapper:komapper-starter-r2dbc")
api("org.komapper:komapper-dialect-postgresql-r2dbc")
ksp("org.komapper:komapper-processor")
// Redis cache
api("io.lettuce:lettuce-core:$lettuceVersion")
api("io.netty:netty-codec:$nettyCodecVersion")
// Logging information
api("io.github.microutils:kotlin-logging:$loggingVersion")
testImplementation(kotlin("test-junit5"))
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesCoreVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-json:$kotestVersion")
// Create fake instance (mock) of components for tests
testImplementation("io.mockk:mockk:$mockkVersion")
// Junit to run tests
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
testImplementation("org.assertj:assertj-core:$assertJcoreVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testImplementation("org.testcontainers:junit-jupiter:$testContainersVersion")
testImplementation("org.testcontainers:postgresql:$testContainersVersion")
testImplementation("org.komapper:komapper-dialect-postgresql-jdbc")
}
kotlin {
explicitApi = org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Strict
jvmToolchain(javaVersionInt)
sourceSets {
main {
kotlin {
srcDir("build/generated")
}
}
all {
languageSettings {
optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalStdlibApi")
optIn("kotlin.contracts.ExperimentalContracts")
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
optIn("io.lettuce.core.ExperimentalLettuceCoroutinesApi")
}
}
}
}
val dokkaOutputDir = "${rootProject.projectDir}/dokka"
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = javaVersionString
}
test {
useJUnitPlatform()
}
clean {
delete(dokkaOutputDir)
}
val deleteDokkaOutputDir by register<Delete>("deleteDokkaOutputDirectory") {
group = "documentation"
delete(dokkaOutputDir)
}
dokkaHtml.configure {
// CompileJava should be executed to build library in Jitpack
dependsOn(deleteDokkaOutputDir, compileJava.get())
outputDirectory.set(file(dokkaOutputDir))
}
jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(true)
csv.required.set(false)
}
}
}
val sourcesJar by tasks.registering(Jar::class) {
group = "build"
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javadocJar = tasks.register<Jar>("javadocJar") {
group = "documentation"
dependsOn(tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
publishing {
val projectName = project.name
publications {
val projectOrganizationPath = "Rushyverse/$projectName"
val projectGitUrl = "https://github.com/$projectOrganizationPath"
create<MavenPublication>(projectName) {
from(components["kotlin"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
pom {
name.set(projectName)
description.set(project.description)
url.set(projectGitUrl)
issueManagement {
system.set("GitHub")
url.set("$projectGitUrl/issues")
}
ciManagement {
system.set("GitHub Actions")
}
licenses {
license {
name.set("MIT")
url.set("https://mit-license.org")
}
}
developers {
developer {
name.set("Quentixx")
email.set("Quentixx@outlook.fr")
url.set("https://github.com/Quentixx")
}
developer {
name.set("Distractic")
email.set("Distractic@outlook.fr")
url.set("https://github.com/Distractic")
}
}
scm {
connection.set("scm:git:$projectGitUrl.git")
developerConnection.set("scm:git:git@github.com:$projectOrganizationPath.git")
url.set(projectGitUrl)
}
distributionManagement {
downloadUrl.set("$projectGitUrl/releases")
}
}
}
}
}