-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.gradle
More file actions
344 lines (275 loc) · 11.6 KB
/
build.gradle
File metadata and controls
344 lines (275 loc) · 11.6 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
import org.apache.tools.ant.filters.ReplaceTokens
import javax.swing.filechooser.FileSystemView
import java.nio.file.Paths
import java.time.Duration
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
// dependencies {
// classpath 'org.fusesource.jansi:jansi:2.4.1'
// }
}
plugins {
id 'java-library'
id("com.gradleup.shadow") version "9.2.2"
}
group = 'org.skills'
version = '19.6.4'
description = 'An RPG plugin for players to grind with!'
repositories {
mavenLocal()
maven {
name = "sk89q-repo"
// url = uri('https://maven.sk89q.com/repo/')
url = uri('https://maven.enginehub.org/repo/')
}
maven {
url = uri('https://repo.mypet-plugin.de/')
}
maven {
url = uri('https://maven.citizensnpcs.co/repo')
}
maven {
url = uri('https://ci.ender.zone/plugin/repository/everything/')
}
maven {
url = uri('https://repo.extendedclip.com/content/repositories/placeholderapi/')
}
maven {
url = uri('https://mvn.lumine.io/repository/maven-public/')
}
maven {
url = uri('https://nexus.scarsz.me/content/groups/public/')
}
maven {
url = uri('https://repo.inventivetalent.org/content/groups/public/')
}
maven {
url = uri('https://repo.codemc.org/repository/nms/')
}
maven {
url = uri('https://libraries.minecraft.net/')
}
maven {
url = uri('https://jitpack.io')
}
mavenCentral()
}
// Handle Guava transitive dependency conflict between Spigot and WorldEdit/WorldGuard.
configurations.configureEach {
resolutionStrategy {
// Align versions across the board (replaces constraints)
force 'com.google.guava:guava:33.3.1-jre'
// Substitute problematic variants to the JRE one
dependencySubstitution {
// If plain guava (no suffix) causes issues, map it too
substitute module('com.google.guava:guava') using module('com.google.guava:guava:33.3.1-jre')
}
// Select JRE variant for the guava capability (handles metadata strictness)
capabilitiesResolution.withCapability("com.google.guava:guava") {
select(candidates.find { it.variantName.contains("jreRuntimeElements") })
}
}
}
dependencies {
implementation files(file('local-libs' + File.separatorChar + 'XCommons-3.0.2.jar'))
implementation 'com.github.ben-manes.caffeine:caffeine:2.9.0'
implementation 'com.github.cryptomorin:XSeries:13.5.1'
implementation project(':services:kingdomsx')
// implementation files(file('local-libs' + File.separatorChar + 'XSeries-13.3.1.jar'))
//noinspection DifferentStdlibGradleVersion - We don't use Kotlin for the plugin itself. The dependencies need it.
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.20'
// https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/
//noinspection VulnerableLibrariesLocal
compileOnly 'org.spigotmc:spigot:1.21.10-R0.1-SNAPSHOT'
// compileOnly 'com.mojang:authlib:6.0.54' // Required for using XSkull
///////////////////////////// Mobs /////////////////////////////
// https://arcaneplugins.gitbook.io/levelledmobs-the-ultimate-mob-levelling-solution/levelledmobs-v4.0/for-developers
// https://mvnrepository.com/artifact/io.github.arcaneplugins/levelledmobs-plugin
// compileOnly 'com.github.lokka30:levelledmobs:4.0.3.1'
compileOnly 'io.github.arcaneplugins:levelledmobs-plugin:4.0.3.1'
// https://magmaguy.com/wiki.html#lang=en&article=elitemobs+info.md§ion=custom-content
// mvn install:install-file "-Dfile=EliteMobs.jar" -DgroupId=com.magmaguy -DartifactId=elitemobs -Dversion=9.1.12 -Dpackaging=jar -DgeneratePom=true
compileOnly 'com.magmaguy:elitemobs:9.1.12'
// https://wiki.mypet-plugin.de/
// https://github.com/MyPetORG/MyPet/releases
// https://repo.keyle.de/ -> https://repo.mypet-plugin.de/
// mvn install:install-file "-Dfile=pet.jar" -DgroupId=de.keyle.MyPet -DartifactId=mypet -Dversion=3.12 -Dpackaging=jar -DgeneratePom=true
// Doesn't look like using GitHub Packages is possible without a PAT? What kind of fucking feature is this?
compileOnly 'de.keyle.MyPet:mypet:3.12'
// compileOnly 'de.keyle:mypet:3.12'
// https://www.spigotmc.org/resources/lorinthsrpgmobs.53568/
compileOnly 'me.lorinth:lorinthsrpgmobs:1.10.0'
// https://git.mythiccraft.io/mythiccraft/MythicMobs/-/wikis/API
compileOnly 'io.lumine:Mythic-Dist:5.6.1'
compileOnly 'org.mcmonkey:sentinel:2.8.0-SNAPSHOT'
compileOnly('net.citizensnpcs:citizens-main:2.0.32-SNAPSHOT') { transitive = false } // net.byteflux:libby-bukkit
///////////////////////////// Factions /////////////////////////////
compileOnly 'com.bekvon:residence:5.0.0'
compileOnly 'com.massivecraft:massivecore:2.14.0'
compileOnly('com.massivecraft:Factions:1.6.9.5-U0.6.0') { transitive = false }
compileOnly 'com.massivecraft:massivefactions:2.14.0'
///////////////////////////// Others /////////////////////////////
compileOnly 'me.clip:placeholderapi:2.11.6'
compileOnly 'be.maximvdw:MVdWPlaceholderAPI:3.1.1-SNAPSHOT'
//noinspection VulnerableLibrariesLocal
compileOnly('com.github.MilkBowl:VaultAPI:1.7') { setTransitive(false) }
// https://docs.discordsrv.com/#developers
// https://nexus.scarsz.me/content/groups/public/com/discordsrv/discordsrv/
compileOnly 'com.discordsrv:discordsrv:1.29.0'
// compileOnly('net.dv8tion:JDA:5.2.1') { transitive = false } // DiscordSRV 1.18.0+ no longer includes JDA.
// https://worldedit.enginehub.org/en/latest/api/index.html
// https://maven.enginehub.org/repo/com/sk89q/worldedit/worldedit-bukkit/
// https://maven.enginehub.org/repo/com/sk89q/worldguard/worldguard-bukkit/
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT'
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.4.0-SNAPSHOT'
}
java {
// Disables disallowing dependencies that are compiled with a more recent Java version
// from being used in a project with a lower Java version.
// (Specifically for WorldEdit+WorldGuard)
disableAutoTargetJvm()
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
// We can't use a different version for sourceCompatibility
// Cause: warning: source release 21 requires target release 21
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
java.nio.file.Path serverPath = Paths.get("\${user.home}/Test Server/1.21"
.replace("\${user.home}", FileSystemView.getFileSystemView().getHomeDirectory().absolutePath))
logger.lifecycle("Server Path: " + serverPath.toAbsolutePath().toString())
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc).configureEach {
options.encoding = 'UTF-8'
}
tasks {
// How the fuck do we fix this:
// Cannot resolve resource filtering of MatchingCopyAction. IDEA may fail to build project. Consider using delegated build (enabled by default).
// https://youtrack.jetbrains.com/issue/IDEA-296490
processResources {
filter(ReplaceTokens, tokens: ['$': '={'], beginToken: '=', endToken: '{')
// Gradle will sometimes cache the results, so a "clean" task is required.
def props = [
project: [
name : "SkillsPro",
version : project.version,
description: project.description
]
]
filesMatching("plugin.yml") {
expand(props)
}
}
shadowJar {
relocate("kotlin", "org.skills.kotlin")
relocate("com.cryptomorin.xseries", "org.skills.utils.xseries")
relocate("com.cryptomorin.commons", "org.skills.utils.xcommons")
relocate("org.kingdoms.nbt", "org.skills.utils.nbt")
relocate("com.github.benmanes.caffeine", "org.skills.utils.caffeine")
exclude("META-INF/maven/**")
exclude("META-INF/jandex.idx") // Where the hell is this coming from?
dependencies {
exclude(dependency("com.google.errorprone:.*"))
exclude(dependency("org.checkerframework:.*"))
exclude(dependency("org.intellij.lang:.*"))
exclude(dependency("org.jetbrains:annotations:.*"))
}
minimize {
exclude(dependency("com.github.ben-manes.caffeine:.*"))
}
}
}
tasks.register("copyToServer", Copy) {
//noinspection ConfigurationAvoidance
dependsOn(build)
setTimeout(Duration.ofSeconds(30))
from(tasks.shadowJar.archiveFile)
rename { "${project.name}-${project.version}.jar" }
into(serverPath.resolve("plugins"))
}
class Globals {
static Process lastProcess
}
java.nio.file.Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"))
java.nio.file.Path tempFile = tempDir.resolve("gradle-runServer-taskpid.tmp")
String pidOfPid(ProcessHandle handle) {
String pids = handle.pid().toString()
if (handle.children().count() > 0) {
pids += "," + handle.children()
.map { pidOfPid(it) }
.collect().join(",")
}
return pids
}
tasks.register("runServer") {
doLast {
var activeDir = serverPath
ProcessBuilder procBuilder = new ProcessBuilder(
"cmd", "/c", "start", "cmd", "/c", "Run.bat")
.directory(activeDir.toFile())
// procBuilder.environment().put("gradled", "true")
def lastProcess = Globals.lastProcess = procBuilder.start()
println("Executed ${lastProcess.pid()} in $activeDir (temp: " + tempFile.toAbsolutePath() + ")")
}
}
String infoOfInfo(ProcessHandle proc, int nest = 0) {
if (nest >= 10) return ""
def inf = proc.info()
String value = " ".repeat(nest) + proc.pid() + ":"
inf.command().ifPresent { value += it }
inf.commandLine().ifPresent { value += "|" + it }
inf.arguments().ifPresent { value += " " + it }
value += "\n" + proc.children().map { infoOfInfo(it, nest + 1) }.collect().join("")
return value
}
tasks.register("stopServerIfRunning") {
doLast {
if (Globals.lastProcess != null) {
List<Long> pids = Globals.lastProcess.descendants().collect { it.pid() }
// Old method
// Runtime.getRuntime().exec("taskkill /F /PID " + pidStr)
// Doesn't work properly because it requires admin privs
// to see the commandLine info.
// ProcessHandle.allProcesses().forEach { x ->
// println(infoOfInfo(x))
// }
for (final def pid in pids) {
def proc = ProcessHandle.of(pid)
if (proc.isPresent()) {
println("Stopping server process with PID: " + pid)
proc.get().destroy()
} else println("No server process found with PID: " + pid)
}
Globals.lastProcess = null
} else {
println("No server processes found.")
}
}
}
tasks.register("everything") {
def taskSeq = [
"stopServerIfRunning", "build", "copyToServer", "runServer"
]
dependsOn(taskSeq)
for (i in 0..<taskSeq.size()) {
if ((i + 1) >= taskSeq.size()) break
def prev = taskSeq[i]
def next = taskSeq[i + 1]
try {
//noinspection ConfigurationAvoidance
tasks.findByName(next).mustRunAfter(tasks.named(prev))
} catch (Exception ex) {
throw new RuntimeException("Error while gathering tasks $prev->$next", ex)
}
}
}