-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
406 lines (351 loc) · 15.1 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
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
//file:noinspection SpellCheckingInspection
//file:noinspection GroovyAssignabilityCheck
import com.github.spotbugs.snom.SpotBugsTask
import java.text.SimpleDateFormat
import org.gradle.crypto.checksum.Checksum
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.5.3'
id "org.cadixdev.licenser" version "0.6.1"
// id "com.github.sherter.google-java-format" version "0.9"
id 'xyz.jpenilla.run-paper' version '2.0.1'
// id "com.github.spotbugs" version "5.0.13"
id 'com.gorylenko.gradle-git-properties' version '2.4.1'
// id 'com.palantir.git-version' version '1.0.0'
id "com.moonlitdoor.git-version" version "0.1.1"
id 'name.remal.common-ci' version '1.5.0'
id "com.github.spotbugs" version "5.0.13"
id "com.diffplug.spotless" version "6.17.0"
id 'org.gradle.crypto.checksum' version '1.4.0'
id 'java'
id 'jacoco'
id 'idea'
id 'checkstyle'
// id 'signing'
}
// Thanks BanManager, but your log message is now my property
logger.lifecycle("""
*******************************************
You are building TownyPlus!
If you encounter trouble:
1) Try running 'build' in a separate Gradle run
2) Use gradlew and not gradle
3) If you still need help, ask on Discord #tickets! https://2v1.me/discord
Output files will be in /build/libs
*******************************************
""")
apply from: "$rootDir/gradle/jacoco.gradle"
apply from: "$rootDir/gradle/publish.gradle"
if (project.hasProperty("local_script")) {
apply from: file(local_script + "/build.local.gradle")
}
static def getTime() {
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd-HHmm")
sdf.setTimeZone(TimeZone.getTimeZone("UTC"))
return sdf.format(new Date()).toString()
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
group project.property("group")
//def details = versionDetails()
//spotbugs {
// ignoreFailures = false
// showStackTraces = true
// showProgress = true
// effort = "max"
// reportLevel = 'default'
//}
spotbugs {
ignoreFailures = true
showStackTraces = true
showProgress = true
effort = 'default'
reportLevel = 'default'
}
// CI channels will clash if you change the version within build.gradle, this is only for local builds
gitProperties {
failOnNoGitDirectory = false
customProperty 'git.mcVersion', { project.property("mcVersion") }
customProperty 'git.build.time', { new Date().getTime() }
extProperty = 'gitProps' // git properties will be put in a map at project.ext.gitProps
}
generateGitProperties.outputs.upToDateWhen { false } // make sure the generateGitProperties task always executes (even when git.properties is not changed)
ext {
mcVersion = project.property("mcVersion")
}
// Automatically apply Java versioning conventions and have it comply with Semantic Versioning
// Our versioning scheme is: MAJOR.MINOR.PATCH-QUALIFIER
// MAJOR: Major changes to the plugin, such as a complete rewrite
// MINOR: Minor changes to the plugin, such as new features
// PATCH: Bug fixes
// QUALIFIER: A qualifier to the version, such as alpha, beta, or release candidate
// The version is governed from our CI server, and is automatically incremented.
// The CI should never run this.
if (System.getenv("CI") == null && project.property("DO_NOT_CHANGE_VERSION") != "true") {
if (version == null || version == "") {
version = "SNAPSHOT"
} else if (gitBranchName.contains("alpha") || gitBranchName.contains("beta") || gitBranchName.contains("rc")) {
version = version + "-SNAPSHOT"
} else {
version = version
}
}
println("Version: " + version)
// The current version based on the most recent tag on the current git branch.
// Doesn't mean anything, just a nice to have.
println("Git Version: " + gitVersion)
println("Branch: " + gitBranchName)
println("Is CI detected? " + System.getenv("CI") != null)
task generateFiles {
// Generates some files.
}
task createChecksums(type: Checksum, dependsOn: 'build') {
inputFiles.setFrom(build)
checksumAlgorithm.set(Checksum.Algorithm.SHA512)
appendFileNameToChecksum.set(true)
}
checkstyle {
// toolVersion '10.6.0'
// maxWarnings = 0
}
tasks.withType(Checkstyle) {
reports {
xml.required = true
html.required = true
}
}
tasks.withType(SpotBugsTask) {
reports {
xml {
required.set(true)
}
html {
required.set(true)
}
}
}
def gitHubRepo = "https://github.com/BrycensRanch/TownyPlus"
bukkit {
// Plugin main class (required)
main = project.property("packageName") + ".TownyPlusMain"
// API version (should be set for 1.13+)
apiVersion = project.property("apiVersion")
// Other possible properties from plugin.yml (optional)
load = 'POSTWORLD' // or 'POSTWORLD'
name = project.property("pluginName")
description = project.property("description")
depend = ['Towny']
softDepend = ['DiscordSRV', 'TownyChat', 'VentureChat', 'ProtocolLib', 'PlaceholderAPI']
defaultPermission = 'NOT_OP' // 'TRUE', 'FALSE', 'OP' or 'NOT_OP'
website = gitHubRepo
// commands {
// test {
// description = 'This is a test command!'
// aliases = ['t']
// permission = 'testplugin.test'
// usage = 'Just run the command!'
// // permissionMessage = 'You may not test this command!'
// }
// // ...
// }
// permissions {
// 'testplugin.*' {
// children = ['testplugin.test'] // Defaults permissions to true
// // You can also specify the values of the permissions
// childrenMap = ['testplugin.test': false]
// }
// 'testplugin.test' {
// description = 'Allows you to run the test command'
// setDefault('OP') // 'TRUE', 'FALSE', 'OP' or 'NOT_OP'
// }
// }
}
compileJava {
options.fork = true
}
publish {
dependsOn 'clean'
dependsOn 'build'
tasks.findByName('build').mustRunAfter 'clean'
}
assemble {
dependsOn(shadowJar)
}
archivesBaseName = project.property("pluginName")
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url = 'https://jitpack.io' }
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://repo.papermc.io/repository/maven-public/' }
maven { url = 'https://hub.jeff-media.com/nexus/repository/jeff-media-public/' }
maven { url = 'https://libraries.minecraft.net/' }
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url = 'https://repo.spongepowered.org/maven/' }
maven { url = 'https://nexus.scarsz.me/content/groups/public/' }
maven { url = 'https://repo.glaremasters.me/repository/towny/' }
maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
}
}
dependencies {
// Keep in mind: you can never have too many dependencies!
// If you're using a dependency that isn't listed here, add it!
// using spigot-api
// notice how we arent using bukkit-api. i honestly think the plugin won't work with bukkit-api due to the shitload of opinionated dependencies we use
compileOnly "org.spigotmc:spigot-api:${mcVersion}-R0.1-SNAPSHOT" // The Spigot API with no shadowing. Requires the OSS repo.
// or using paper-api
// compileOnly "io.papermc.paper:paper-api:${mcVersion}-R0.1-SNAPSHOT"
// Library dependencies mean they're loaded on server boot instead of being in the jar
//
// Spigot has inspired me to convert every dependency I use to dynamically load them from Maven Central.
// I'm sorry.
// Any dependencies that don't complain about being loaded dynamically shaded into the jar instead.
// We went from 5MB to 1.4MB, so it's a win-win.
// Command Handling! https://commandframework.cloud
library 'cloud.commandframework:cloud-core:1.8.2'
library 'cloud.commandframework:cloud-annotations:1.8.2'
annotationProcessor('cloud.commandframework:cloud-annotations:1.8.2')
library 'cloud.commandframework:cloud-paper:1.8.2'
library 'cloud.commandframework:cloud-minecraft-extras:1.8.3'
// Dependency for our way of command handling
library 'me.lucko:commodore:2.2'
library 'org.projectlombok:lombok:1.18.26'
library 'com.fasterxml.jackson.core:jackson-annotations:2.14.2'
library 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
// The following is required for the @Command annotation to work, probably...
// I just got errors without it.
library 'io.leangen.geantyref:geantyref:1.3.14'
annotationProcessor('org.projectlombok:lombok:1.18.26')
annotationProcessor('com.fasterxml.jackson.core:jackson-annotations:2.14.2')
library 'com.fasterxml.jackson.dataformat:jackson-dataformat-properties:2.14.2'
library 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2'
// For handling multi platform configuration, simply amazing
// library "org.spongepowered:configurate-yaml:4.1.2"
// Spigot/GitHub Releases Update checker. Am I that lazy? Yes.
implementation 'com.jeff_media:SpigotUpdateChecker:3.0.2'
// Just a reminder: compileOnly means that we're not shading this dependency into our jar. This is usually when we're using a dependency that is already provided by the server. Aka, when it's already in the server's classpath.
// implementation means that we're shading this dependency into our jar. This is usually when we're using a dependency that is not provided by the server. Aka, when it's not in the server's classpath.
// Towny
compileOnly 'com.palmergames.bukkit.towny:towny:0.98.6.19'
compileOnly 'com.palmergames.bukkit:TownyChat:0.45'
// PlaceholderAPI
compileOnly 'me.clip:placeholderapi:2.11.2'
// Towny's implementation of CommentedConfiguration, which we use for our config.yml and lang_en.yml
implementation 'io.github.townyadvanced.commentedconfiguration:CommentedConfiguration:1.0.1'
// Inventory Framework we use for our GUIs /tplus chest
implementation 'com.github.stefvanschie.inventoryframework:IF:0.10.8'
// Telemetry
implementation 'org.bstats:bstats-bukkit:3.0.1'
// better http server than spark
library "io.javalin:javalin-bundle:5.4.2"
// DiscordSRV, optional dependency
compileOnly 'com.discordsrv:discordsrv:1.24.0'
// Semver version parsing for auto updating
library 'com.vdurmont:semver4j:3.1.0'
// // JDA for DiscordSRV
// Apparently, this is already included in DiscordSRV.
// implementation("net.dv8tion:JDA:5.0.0-beta.5") {
// exclude module: 'opus-java'
// }
// VentureChat support for chat listening
compileOnly("mineverse.aust1n46:venturechat:3.5.0")
// ProtocolLib (required by venturechat)
compileOnly "com.comphenix.protocol:ProtocolLib:4.8.0"
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.3'
// library 'org.hibernate:hibernate-core:5.6.5.Final'
implementation 'dev.vankka:mcdiscordreserializer:4.3.0'
// Database stuff
library 'com.zaxxer:HikariCP:5.0.1'
library 'com.h2database:h2:2.1.214'
library 'org.xerial:sqlite-jdbc:3.41.0.0'
library 'org.postgresql:postgresql:42.5.4'
// compileOnly 'org.h2.Driver:Driver:1.4.200'
// compileOnly 'com.mysql.jdbc.Driver:Driver:8.0.26'
// Adventure
library "net.kyori:adventure-api:4.13.0"
library "net.kyori:adventure-platform-bukkit:4.3.0"
library "net.kyori:adventure-text-minimessage:4.13.0"
// Adventure logger that takes advantage of Adventure's text components
library "net.kyori:adventure-text-logger-slf4j:4.13.0"
// Test dependencies
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
// testCompileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.3'
// testImplementation("org.projectlombok:lombok:1.18.26")
// testImplementation("com.fasterxml.jackson.core:jackson-annotations:2.14.2")
// testImplementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
// testImplementation("io.javalin:javalin-bundle:5.3.2")
// testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
// testImplementation 'org.mockito:mockito-core:5.1.1'
// testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.145.0'
// testImplementation 'org.assertj:assertj-core:3.24.2'
}
shadowJar {
archiveClassifier.set("")
dependencies {
// These are sorted by internal dependencies to ones for compatability/functionatlity related to other plugins
// include(dependency('net.kyori::'))
include(dependency('org.bstats::'))
include(dependency('io.github.townyadvanced.commentedconfiguration::'))
include(dependency('com.github.stefvanschie.inventoryframework::'))
// include(dependency('com.zaxxer::'))
// include(dependency('com.h2database::'))
include(dependency('dev.vankka::'))
include(dependency('com.jeff_media::'))
// include(dependency('me.lucko::'))
// include(dependency('cloud.commandframework::'))
// include(dependency('com.palmergames.bukkit::'))
// include(dependency('com.discordsrv::'))
// include(dependency('github.scarsz.discordsrv::'))
// include(dependency('mineverse.aust1n46::'))
// include(dependency('com.comphenix.protocol::'))
}
// relocate 'cloud.commandframework', "${packageName}.libs.commands"
// relocate 'me.lucko', "${packageName}.libs.lucko"
relocate 'com.jeff_media', "${packageName}.libs.jeff_media"
relocate 'org.bstats', "${packageName}.libs.bstats"
// relocate 'net.kyori', "${packageName}.libs.kyori"
relocate 'mineverse.aust1n46', "${packageName}.libs.aust1n46"
relocate 'com.comphenix.protocol', "${packageName}.libs.protocol"
relocate 'com.discordsrv', "${packageName}.libs.discordsrv"
relocate 'io.github.townyadvanced.commentedconfiguration', "${packageName}.libs.commentedconfiguration"
relocate 'com.github.stefvanschie.inventoryframework', "${packageName}.inventoryframework"
// relocate 'com.zaxxer', "${packageName}.libs.zaxxer"
relocate 'dev.vankka', "${packageName}.libs.vankka"
// Exclude signatures, maven/ and proguard/ from META-INF
exclude("META-INF/*.SF")
exclude("META-INF/*.DSA")
exclude("META-INF/*.RSA")
exclude("META-INF/maven/**")
exclude("META-INF/proguard/**")
}
license {
include '**/*.java'
matching('**/*.java') {
header = file('HEADER.txt')
}
}
sourcesJar.enabled = true
tasks.build.dependsOn(shadowJar)
// tasks.test.dependsOn(shadowJar)
runServer {
// Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin.
// Your plugin's jar (or shadowJar if present) will be used automatically.
minecraftVersion(project.property("testServerMCVersion"))
}
processResources {
project.properties.put("version", version)
expand project.properties
}
defaultTasks 'build'