forked from Hazebyte/CratePlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
304 lines (267 loc) · 11 KB
/
Copy pathbuild.gradle
File metadata and controls
304 lines (267 loc) · 11 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
plugins {
id 'base'
id 'com.gradleup.shadow' version '9.4.1' apply false
}
ext {
pluginVersion = providers.gradleProperty('pluginVersion').get()
crateApiVersion = providers.gradleProperty('crateApiVersion').get()
utilsVersion = providers.gradleProperty('utilsVersion').get()
javaLanguageVersion = providers.gradleProperty('javaVersion').get().toInteger()
paperMinecraftVersion = providers.gradleProperty('paperMinecraftVersion').get()
paperApiVersion = providers.gradleProperty('paperApiVersion').get()
decentHologramsVersion = '2.9.9'
lombokVersion = '1.18.46'
mapstructVersion = '1.6.3'
daggerVersion = '2.59.2'
}
def localPluginJars = { String pattern ->
files(
fileTree(dir: rootProject.file('libs'), include: pattern),
fileTree(dir: rootProject.file('servers'), include: "**/plugins/${pattern}")
)
}
def includeLocalPluginJars = providers.gradleProperty('includeLocalPluginJars')
.map { it.toBoolean() }
.orElse(true)
allprojects {
group = project.path == ':api' || project.path == ':utils' ? 'com.hazebyte' : 'com.hazebyte.crate'
version = project.path == ':api'
? rootProject.ext.crateApiVersion
: project.path == ':utils'
? rootProject.ext.utilsVersion
: rootProject.ext.pluginVersion
repositories {
mavenCentral()
maven {
name = 'PaperMC'
url = uri('https://repo.papermc.io/repository/maven-public/')
}
maven {
name = 'Aikar'
url = uri('https://repo.aikar.co/content/groups/aikar/')
}
maven {
name = 'ExtendedClip'
url = uri('https://repo.extendedclip.com/content/repositories/placeholderapi/')
}
maven {
name = 'CodeMC'
url = uri('https://repo.codemc.io/repository/maven-public/')
}
maven {
name = 'ElMakers'
url = uri('https://maven.elmakers.com/repository')
}
maven {
name = 'Hazebyte'
url = uri('https://m2.hazebyte.com/repository/maven_releases/')
}
maven {
name = 'JitPack'
url = uri('https://jitpack.io')
}
maven {
name = 'MinecraftLibraries'
url = uri('https://libraries.minecraft.net/')
}
}
}
subprojects {
apply plugin: 'java-library'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(rootProject.ext.javaLanguageVersion)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.release = rootProject.ext.javaLanguageVersion
options.compilerArgs.addAll(['-parameters'])
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
dependencies {
compileOnly "io.papermc.paper:paper-api:${rootProject.ext.paperApiVersion}"
compileOnly "org.projectlombok:lombok:${rootProject.ext.lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${rootProject.ext.lombokVersion}"
testCompileOnly "org.projectlombok:lombok:${rootProject.ext.lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${rootProject.ext.lombokVersion}"
testImplementation platform('org.junit:junit-bom:5.13.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.mockito:mockito-core:5.20.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.20.0'
testImplementation 'org.hamcrest:hamcrest:3.0'
}
}
project(':api') {
dependencies {
compileOnly 'me.clip:placeholderapi:2.12.2'
}
}
project(':common') {
dependencies {
api project(':api')
compileOnly 'com.googlecode.json-simple:json-simple:1.1.1'
testImplementation 'com.googlecode.json-simple:json-simple:1.1.1'
}
}
project(':utils') {
dependencies {
testImplementation 'org.testng:testng:7.11.0'
}
}
project(':bukkit') {
apply plugin: 'com.gradleup.shadow'
def filteredPluginVersion = rootProject.ext.pluginVersion
def filteredPaperApiVersion = rootProject.ext.paperMinecraftVersion
dependencies {
implementation project(':api')
implementation project(':common')
implementation project(':utils')
implementation 'co.aikar:acf-core:0.5.1-SNAPSHOT'
implementation 'co.aikar:acf-bukkit:0.5.1-SNAPSHOT'
implementation 'co.aikar:locales:1.0-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit:3.1.0'
implementation 'com.elmakers.mine.bukkit:EffectLib:10.3'
implementation 'commons-lang:commons-lang:2.6'
implementation "com.google.dagger:dagger:${rootProject.ext.daggerVersion}"
implementation 'javax.inject:javax.inject:1'
implementation "org.mapstruct:mapstruct:${rootProject.ext.mapstructVersion}"
implementation 'de.tr7zw:item-nbt-api:2.15.7'
annotationProcessor "org.mapstruct:mapstruct-processor:${rootProject.ext.mapstructVersion}"
annotationProcessor 'org.projectlombok:lombok-mapstruct-binding:0.2.0'
annotationProcessor "com.google.dagger:dagger-compiler:${rootProject.ext.daggerVersion}"
compileOnly('me.clip:placeholderapi:2.12.2') {
transitive = false
}
compileOnly('net.milkbowl.vault:VaultAPI:1.7') {
transitive = false
}
compileOnly('com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0') {
transitive = false
}
compileOnly("com.github.decentsoftware-eu.decentholograms:decentholograms:${rootProject.ext.decentHologramsVersion}") {
transitive = false
}
compileOnly 'com.mojang:authlib:7.0.63'
compileOnly('com.github.Zrips:CMI-API:9.7.14.3') {
transitive = false
}
compileOnly('com.github.Zrips:CMILib:1.5.8.1') {
transitive = false
}
if (includeLocalPluginJars.get()) {
compileOnly localPluginJars('CMI*.jar')
}
compileOnly 'com.googlecode.json-simple:json-simple:1.1.1'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.29.0'
}
tasks.named('processResources') {
filteringCharset = 'UTF-8'
filesMatching('plugin.yml') {
expand(project: [
version: filteredPluginVersion,
paperApiVersion: filteredPaperApiVersion
])
}
}
tasks.named('shadowJar') {
archiveBaseName.set('CrateReloaded')
archiveClassifier.set('')
archiveVersion.set(project.version.toString())
relocate 'co.aikar.commands', 'com.hazebyte.libs.aikar.acf'
relocate 'co.aikar.locales', 'com.hazebyte.libs.aikar.locales'
relocate 'org.bstats', 'com.hazebyte.bstats'
relocate 'dagger', 'com.hazebyte.libs.dagger'
relocate 'javax.inject', 'com.hazebyte.libs.javax.inject'
relocate 'org.mapstruct', 'com.hazebyte.libs.org.mapstruct'
relocate 'de.tr7zw.changeme.nbtapi', 'com.hazebyte.libs.de.tr7zw'
relocate 'org.apache.commons.lang', 'com.hazebyte.libs.apache.commons.lang'
}
tasks.named('assemble') {
dependsOn tasks.named('shadowJar')
}
}
tasks.register('pluginJar') {
group = 'build'
description = "Builds the shaded CrateReloaded plugin jar for Paper ${rootProject.ext.paperMinecraftVersion}."
dependsOn ':bukkit:shadowJar'
}
def releasePluginVersion = rootProject.ext.pluginVersion
def releasePaperMinecraftVersion = rootProject.ext.paperMinecraftVersion
def releasePaperApiVersion = rootProject.ext.paperApiVersion
def releaseJavaVersion = rootProject.ext.javaLanguageVersion
def releaseJarTask = project(':bukkit').tasks.named('shadowJar')
def releaseReadme = rootProject.file('README.md')
def releasePoms = ['pom.xml', 'bukkit/pom.xml', 'common/pom.xml', 'nms/pom.xml']
.collect { rootProject.file(it) }
tasks.register('verifyRelease') {
group = 'verification'
description = 'Verifies release metadata, jar naming, and Java bytecode compatibility.'
dependsOn ':bukkit:shadowJar'
doLast {
def jarFile = releaseJarTask.get().archiveFile.get().asFile
def expectedJarName = "CrateReloaded-${releasePluginVersion}.jar"
if (jarFile.name != expectedJarName) {
throw new GradleException("Expected ${expectedJarName}, found ${jarFile.name}")
}
def zipFile = new java.util.zip.ZipFile(jarFile)
try {
def pluginEntry = zipFile.getEntry('plugin.yml')
if (pluginEntry == null) {
throw new GradleException('Built jar does not contain plugin.yml')
}
def pluginYaml = zipFile.getInputStream(pluginEntry).getText('UTF-8')
if (!pluginYaml.contains("version: ${releasePluginVersion}")) {
throw new GradleException('plugin.yml version does not match pluginVersion')
}
if (!pluginYaml.contains("api-version: ${releasePaperMinecraftVersion}")) {
throw new GradleException('plugin.yml api-version does not match paperMinecraftVersion')
}
def classEntry = zipFile.getEntry('com/hazebyte/crate/cratereloaded/CorePlugin.class')
if (classEntry == null) {
throw new GradleException('Built jar does not contain CorePlugin.class')
}
def classHeader = new byte[8]
def classStream = zipFile.getInputStream(classEntry)
try {
if (classStream.read(classHeader) != classHeader.length) {
throw new GradleException('Could not read CorePlugin.class header')
}
} finally {
classStream.close()
}
def classMajorVersion = ((classHeader[6] & 0xff) << 8) | (classHeader[7] & 0xff)
def expectedClassMajorVersion = 44 + releaseJavaVersion
if (classMajorVersion != expectedClassMajorVersion) {
throw new GradleException(
"Expected Java ${releaseJavaVersion} class version "
+ "${expectedClassMajorVersion}, found ${classMajorVersion}")
}
} finally {
zipFile.close()
}
def readme = releaseReadme.getText('UTF-8')
[
releasePluginVersion,
releasePaperApiVersion,
"Java ${releaseJavaVersion}"
].each { expectedValue ->
if (!readme.contains(expectedValue.toString())) {
throw new GradleException("README.md is missing release value: ${expectedValue}")
}
}
releasePoms.each { pomFile ->
if (!pomFile.getText('UTF-8')
.contains("<version>${releasePluginVersion}</version>")) {
throw new GradleException("${pomFile} does not reference plugin version "
+ releasePluginVersion)
}
}
}
}
tasks.named('check') {
dependsOn tasks.named('verifyRelease')
}