-
Notifications
You must be signed in to change notification settings - Fork 45
/
build.gradle.kts
239 lines (201 loc) · 7.32 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
235
236
237
238
239
plugins {
id("java-library")
id("maven-publish")
alias(libs.plugins.mountiplex)
alias(libs.plugins.shadow)
}
val buildNumber = System.getenv("BUILD_NUMBER") ?: "NO-CI"
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
// Repo for TeamBergerhealer plugins, modules and several of its (soft) dependencies. Also used for:
// - Milkbowl Vault
// - Comphenix ProtocolLib
// - Aikar minecraft-timings
// - Myles ViaVersion
maven("https://ci.mg-dev.eu/plugin/repository/everything/")
// Used to access a server JAR for testing
// TODO Use Paperclip instead
mavenLocal {
content {
includeGroup("org.spigotmc")
includeGroup("com.mojang")
includeGroup("com.bergerkiller.mountiplex")
}
}
}
// Configuration for shaded dependencies which should not be added to the published Maven .pom
val internal = configurations.create("internal")
configurations {
compileOnly {
extendsFrom(internal)
}
}
dependencies {
//
// Server dependencies
//
// Spigot API includes the Bukkit API and is what plugins generally use
compileOnly(libs.spigot.api)
// We also depend on netty for the network logic, which is available in public repo
compileOnly(libs.netty.all)
// Log4j that is used inside the server
compileOnly(libs.log4j.api)
compileOnly(libs.log4j.core)
//
// Publish a BKCommonLib-bom that tells projects using this library what versions of cloud to bring in
// These still require remapping done by the user, but having the version makes it easier for them to stay up to date
// This now allows specifying the cloud library without specifying a version
//
api(platform(project(":BKCommonLib-bom")))
internal(platform(project(":BKCommonLib-bom")))
//
// Dependencies shaded into the library for internal use
//
// Mountiplex is included in BKCommonLib at the same package
api(libs.mountiplex)
// Region change tracker is included in BKCommonLib for the region block change event
api(libs.regionchangetracker)
// SoftDependency lib is included in BKCommonLib for its handy API
api(libs.softdependency)
// Aikar's minecraft timings library, https://github.com/aikar/minecraft-timings
internal(libs.timings) {
isTransitive = false
}
// GSON isn't available in spigot versions prior to 1.8.1, shade it in order to keep 1.8 compatibility
internal(libs.gson)
// Color conversion helper library, https://github.com/bergerhealer/BKCommonLib-ColorConversionHelper
api(libs.colorconversionhelper)
//
// Optional provided dependencies that BKCommonLib can talk with
//
// ViaVersion API
compileOnly(libs.viaversion)
// Vault hook for special permissions handling
compileOnly(libs.vault) {
exclude("org.bukkit", "bukkit")
}
compileOnly(libs.luckperms)
// ProtocolLib hook for protocol handling
compileOnly(libs.protocollib)
//
// Cloud command framework
// Is relocated - requires appropriate relocation in plugins using it
// Versions are part of BKCommonLib-bom and are made available automatically
//
internal("org.incendo:cloud-paper")
internal("org.incendo:cloud-annotations")
internal("org.incendo:cloud-minecraft-extras")
internal(libs.commodore) {
isTransitive = false
}
internal(libs.adventure.api)
internal(libs.adventure.platform.bukkit)
//
// Test dependencies
//
testImplementation(libs.spigot)
testImplementation(libs.mockito.core)
testImplementation(libs.junit)
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
repositories {
maven("https://ci.mg-dev.eu/plugin/repository/everything") {
name = "MGDev"
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
}
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}
mountiplex {
generateTemplateHandles()
remapAnnotationStrings()
}
tasks {
generateTemplateHandles {
source.set("com/bergerkiller/templates/init.txt")
target.set("com/bergerkiller/generated")
variables.put("version", libs.versions.template.minecraft.version);
}
assemble {
dependsOn(shadowJar)
}
withType<JavaCompile>().configureEach {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
withType<Test>().configureEach {
testLogging {
showStandardStreams = true
}
// Used to preload classes under test
systemProperty("main.classes.dir", sourceSets["main"].output.classesDirs.asPath)
// Uncomment to enable SIMD optimizations, to test performance of color conversion
//jvmArgs("--add-modules", "jdk.incubator.vector");
}
// This keeps calling testPreloadTemplatesDeadlock in new instances until it fails
// We use this to identify class loading deadlocks
register("testPreloadTemplatesDeadlock") {
doLast {
while (true) {
exec {
commandLine("./gradlew", "test", "--tests", "com.bergerkiller.bukkit.common.TemplateTest.testPreloadTemplatesDeadlock", "--rerun-tasks")
}
}
}
}
javadoc {
options.encoding = "UTF-8"
isFailOnError = true
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:all,-missing", "-quiet")
}
processResources {
inputs.property("version", version)
inputs.property("build", buildNumber)
from("src/main/templates")
filesMatching(listOf("plugin.yml", "paper-plugin.yml")) {
expand(
"version" to version,
"build" to buildNumber,
"url" to "https://github.com/bergerhealer/BKCommonLib",
"authors" to "bergerkiller, lenis0012, timstans, bubba1234119, KamikazePlatypus, mg_1999, Friwi"
)
}
}
shadowJar {
val prefix = "com.bergerkiller.bukkit.common.dep"
relocate("co.aikar.timings.lib", "$prefix.timingslib")
relocate("com.google.gson", "$prefix.gson")
// Cloud command framework and its dependencies
relocate("org.incendo.cloud", "$prefix.cloud")
relocate("io.leangen.geantyref", "$prefix.typetoken")
relocate("me.lucko.commodore", "$prefix.me.lucko.commodore")
relocate("net.kyori", "$prefix.net.kyori")
// Mountiplex and its dependencies
val mountiplexPrefix = "com.bergerkiller.mountiplex.dep"
relocate("org.objectweb.asm", "$mountiplexPrefix.org.objectweb.asm")
relocate("org.objenesis", "$mountiplexPrefix.org.objenesis")
relocate("javassist", "$mountiplexPrefix.javassist")
configurations.add(internal)
dependencies {
exclude(dependency("org.apiguardian:apiguardian-api"))
exclude(dependency("org.checkerframework:checker-qual"))
}
mergeServiceFiles()
destinationDirectory.set(layout.buildDirectory)
archiveFileName.set("${project.name}-${project.version}-$buildNumber.jar")
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
}