-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
234 lines (194 loc) · 7.1 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
233
234
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
embeddedKotlin("jvm")
embeddedKotlin("plugin.serialization")
id("org.jetbrains.dokka") version "1.9.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.gitlab.arturbosch.detekt") version "1.23.1"
`maven-publish`
`java-library`
jacoco
}
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://repo.papermc.io/repository/maven-public/")
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://jitpack.io")
}
dependencies {
val kotlinSerializableVersion = "1.6.0"
val kamlVersion = "0.55.0"
val coroutineVersion = "1.6.4"
val loggingVersion = "3.0.5"
val koinVersion = "3.4.3"
val mccoroutineVersion = "2.13.0"
val paperVersion = "1.20-R0.1-SNAPSHOT"
val mockBukkitVersion = "3.19.1"
val junitVersion = "5.10.0"
val mockkVersion = "1.12.5"
val fastboardVersion = "2.0.0"
val kotestVersion = "5.6.2"
val icu4jVersion = "73.2"
api(kotlin("stdlib"))
api(kotlin("stdlib-jdk8"))
api(kotlin("reflect"))
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinSerializableVersion")
api("com.charleskorn.kaml:kaml:$kamlVersion")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
api("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutineVersion")
api("io.github.microutils:kotlin-logging:$loggingVersion")
// Plural translation
api("com.ibm.icu:icu4j:$icu4jVersion")
// Injection framework
api("io.insert-koin:koin-core:$koinVersion")
api("io.insert-koin:koin-logger-slf4j:$koinVersion")
// MC coroutine framework
api("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:$mccoroutineVersion")
api("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:$mccoroutineVersion")
// Minecraft server framework
"io.papermc.paper:paper-api:$paperVersion".let {
compileOnly(it)
testImplementation(it)
}
// Scoreboard framework
api("fr.mrmicky:fastboard:$fastboardVersion")
api("com.github.Rushyverse:core:6ae31a9250")
// Tests
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:$mockBukkitVersion")
testImplementation(kotlin("test-junit5"))
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutineVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-json:$kotestVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
testImplementation("io.insert-koin:koin-test:$koinVersion") {
exclude("org.jetbrains.kotlin", "kotlin-test-junit")
}
testImplementation("io.mockk:mockk:$mockkVersion")
}
val javaVersion get() = JavaVersion.VERSION_17
val javaVersionString get() = javaVersion.toString()
val javaVersionInt get() = javaVersionString.toInt()
kotlin {
explicitApi = org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Strict
jvmToolchain(javaVersionInt)
sourceSets {
compilerOptions {
freeCompilerArgs = listOf("-Xcontext-receivers")
}
all {
languageSettings {
optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalStdlibApi")
optIn("kotlinx.serialization.ExperimentalSerializationApi")
optIn("kotlin.contracts.ExperimentalContracts")
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
}
}
}
}
val dokkaOutputDir = "${rootProject.projectDir}/dokka"
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = javaVersionString
}
withType<JavaCompile> {
sourceCompatibility = javaVersionString
targetCompatibility = javaVersionString
}
test {
useJUnitPlatform()
}
clean {
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 deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
group = "documentation"
delete(dokkaOutputDir)
}
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)
dependsOn(deleteDokkaOutputDir, 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("[email protected]")
url.set("https://github.com/Quentixx")
}
developer {
name.set("Distractic")
email.set("[email protected]")
url.set("https://github.com/Distractic")
}
}
scm {
connection.set("scm:git:$projectGitUrl.git")
developerConnection.set("scm:git:[email protected]:$projectOrganizationPath.git")
url.set(projectGitUrl)
}
distributionManagement {
downloadUrl.set("$projectGitUrl/releases")
}
}
}
}
}