-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle
307 lines (243 loc) · 9.85 KB
/
build.gradle
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
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.0.0-beta6"
}
group = 'org.skills'
version = '19.6.1'
description = 'An RPG plugin for players to grind with!'
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))
}
// Cause: warning: source release 17 requires target release 17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
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()
}
dependencies {
api project(':server')
api project(':server:old')
api project(':server:new')
api 'com.github.ben-manes.caffeine:caffeine:2.9.0'
api 'com.github.cryptomorin:XSeries:13.0.0'
// mvn install:install-file "-Dfile=king.jar" -DgroupId=com.github.cryptomorin -DartifactId=kingdoms -Dversion=1.17.4-ALPHA -Dpackaging=jar -DgeneratePom=true
compileOnly 'com.github.cryptomorin:kingdoms:1.17.4-ALPHA'
compileOnly 'org.spigotmc:spigot-api:1.21.4-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'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
// https://docs.discordsrv.com/#developers
// https://nexus.scarsz.me/content/groups/public/com/discordsrv/discordsrv/
compileOnly 'com.discordsrv:discordsrv:1.30.0-SNAPSHOT'
// 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.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 {
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("com.cryptomorin.xseries", "org.skills.utils.xseries")
relocate("com.github.benmanes.caffeine", "org.skills.utils.caffeine")
relocate("org.checkerframework", "org.skills.utils.caffeine.checkerframework")
relocate("com.google.errorprone", "org.skills.utils.errorprone")
}
build {
finalizedBy(shadowJar)
}
}
tasks.register("copyToServer", Copy) {
//noinspection ConfigurationAvoidance
Provider<RegularFile> file = (tasks.findByName("shadowJar") as Jar).archiveFile
setTimeout(Duration.ofSeconds(30))
from(file)
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("while gathering tasks $prev->$next", ex)
}
}
}