-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathbuild.gradle
More file actions
506 lines (458 loc) · 19.2 KB
/
Copy pathbuild.gradle
File metadata and controls
506 lines (458 loc) · 19.2 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
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
/*
* Adapt is Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import io.freefair.gradle.plugins.lombok.LombokPlugin
import io.github.slimjar.resolver.data.Mirror
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.WriteProperties
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.tasks.Jar
import java.nio.file.Files
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
buildscript {
repositories {
mavenCentral()
maven { url = uri('https://jitpack.io') }
}
dependencies {
classpath('com.github.VolmitSoftware.VolmLib:packaging:master-SNAPSHOT')
}
}
plugins {
id 'java-library'
alias(libs.plugins.lombok)
alias(libs.plugins.shadow)
alias(libs.plugins.idea)
alias(libs.plugins.slimjar)
}
apply plugin: 'art.arcane.volmit-packaging'
version = '2.0.5-26.2'
def apiVersion = '26.1'
def main = 'art.arcane.adapt.Adapt'
String paperDevBundleVersion = providers.gradleProperty('paperDevBundleVersion')
.orElse('26.1.2.build.74-stable')
.get()
String volmLibCoordinate = providers.gradleProperty('volmLibCoordinate')
.orElse('com.github.VolmitSoftware:VolmLib:master-SNAPSHOT')
.get()
String hiddenOreCoordinate = providers.gradleProperty('hiddenOreCoordinate')
.orElse('com.github.VolmitSoftware:HiddenOre:master-SNAPSHOT')
.get()
String irisCoordinate = providers.gradleProperty('irisCoordinate')
.orElse('com.github.VolmitSoftware:Iris:unification-SNAPSHOT')
.get()
def platformUtilsConfiguration = configurations.create('platformUtilsLibrary')
def advancementConfiguration = configurations.create('advancementLibrary')
def shadowJarTask = tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar)
tasks.named('slimJar').get()
String languageSourceRevision = 'master'
List<File> languageSourceFiles = fileTree('src/main/resources') {
include('*.toml')
}.files.toList().sort { File left, File right -> left.name <=> right.name }
List<String> languageSourceLocales = languageSourceFiles.collect { File source ->
source.name.substring(0, source.name.length() - '.toml'.length())
}
def languageSourceManifestTask = tasks.register('generateLanguageSourceManifest', WriteProperties) {
destinationFile.set(layout.buildDirectory.file('generated/language-source/adapt-language-source.properties'))
property('revision', languageSourceRevision)
property('locales', languageSourceLocales.join(','))
}
def strippedPlatformUtils = tasks.register('strippedPlatformUtils', Jar) {
archiveClassifier = 'platform-utils'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from({ platformUtilsConfiguration.collect { File dependency -> zipTree(dependency) } })
exclude('net/kyori/**')
exclude('META-INF/services/net.kyori.**')
}
def strippedAdvancementLibrary = tasks.register('strippedAdvancementLibrary', Jar) {
archiveClassifier = 'advancement-library'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from({ advancementConfiguration.collect { File dependency -> zipTree(dependency) } })
exclude('com/fren_gor/ultimateAdvancementAPI/nms/v*/**')
exclude('com/fren_gor/ultimateAdvancementAPI/nms/util/ReflectionUtil.class')
exclude('com/fren_gor/ultimateAdvancementAPI/util/Versions.class')
}
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
// ======================== WINDOWS =============================
registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins')
registerCustomOutputTask('Psycho', 'C://Dan/MinecraftDevelopment/Server/plugins')
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.20/plugins')
registerCustomOutputTask('Nowhere', 'E://Desktop/server/plugins')
registerCustomOutputTask('CrazyDev22', 'C://Users/Julian/Desktop/server/plugins')
registerCustomOutputTask('Pixel', 'D://Iris Dimension Engine//1.20.4 - Development//plugins')
registerCustomOutputTask('SwiftSwamp', 'C://VolmitSoftware/BUILDS')
// ========================== UNIX ==============================
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Developer/RemoteGit/[Minecraft Server]/consumers/plugin-consumers/dropins/plugins')
registerCustomOutputTaskUnix('the456gamer', '/home/the456gamer/projects/minecraft/adapt-testserver/plugins/update/', false)
// ==============================================================
/**
* Expand properties into plugin yml
*/
tasks.named('processResources').configure {
dependsOn(languageSourceManifestTask)
exclude('*.toml')
from(languageSourceManifestTask)
def pluginProperties = [
name : rootProject.name,
version : project.version,
main : main,
apiVersion: apiVersion,
]
inputs.properties(pluginProperties)
filesMatching('**/plugin.yml') {
expand(pluginProperties)
}
}
def verifyLanguagePackagingTask = tasks.register('verifyLanguagePackaging') {
group = 'verification'
description = 'Verifies that locales are absent from the jar and its download reference matches the build.'
dependsOn(shadowJarTask)
doLast {
File runtimeJar = shadowJarTask.get().archiveFile.get().asFile
Set<String> embeddedLocales = new LinkedHashSet<>()
new ZipFile(runtimeJar).withCloseable { ZipFile jar ->
Enumeration<? extends ZipEntry> entries = jar.entries()
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement()
if (!entry.isDirectory() && entry.name.toLowerCase(Locale.ROOT).endsWith('.toml')) {
embeddedLocales.add(entry.name)
}
}
}
if (!embeddedLocales.isEmpty()) {
throw new GradleException("Runtime jar contains locale TOMLs: ${embeddedLocales}")
}
new ZipFile(runtimeJar).withCloseable { ZipFile jar ->
ZipEntry manifestEntry = jar.getEntry('adapt-language-source.properties')
if (manifestEntry == null) {
throw new GradleException('Runtime jar is missing adapt-language-source.properties.')
}
Properties manifest = new Properties()
jar.getInputStream(manifestEntry).withCloseable { InputStream input -> manifest.load(input) }
if (manifest.getProperty('revision') != languageSourceRevision) {
throw new GradleException('Runtime jar language revision does not match the build revision.')
}
if (manifest.getProperty('locales') != languageSourceLocales.join(',')) {
throw new GradleException('Runtime jar language locale set does not match the source set.')
}
}
}
}
allprojects {
apply plugin: 'java'
apply plugin: LombokPlugin
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
}
repositories {
mavenLocal()
mavenCentral()
maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') }
maven { url = uri('https://repo.papermc.io/repository/maven-public/') }
maven { url = uri('https://repo.codemc.org/repository/maven-public') }
maven { url = uri('https://nexus.frengor.com/repository/public/') }
maven {
url = uri('https://repo.extendedclip.com/content/repositories/placeholderapi/')
content { includeGroup 'me.clip' }
}
maven {
url = uri('https://central.sonatype.com/repository/maven-snapshots/')
content { includeGroup 'com.griefdefender' }
}
maven { url = uri('https://maven.enginehub.org/repo/') }
maven { url = uri('https://repo.oraxen.com/releases') }
maven { url = uri('https://repo.alessiodp.com/releases') }
maven { url = uri('https://jitpack.io') }
}
/**
* We need parameter meta for the decree command system
*/
tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add('-parameters')
options.encoding = 'UTF-8'
options.debugOptions.debugLevel = 'none'
options.release.set(25)
}
}
dependencies {
implementation('com.github.VolmitSoftware.VolmLib:native-api:master-SNAPSHOT') {
transitive = false
}
implementation('com.github.VolmitSoftware.VolmLib:native-common:master-SNAPSHOT') {
transitive = false
}
implementation('com.github.VolmitSoftware.VolmLib:native-v26_2_R1:master-SNAPSHOT') {
transitive = false
}
implementation('com.github.VolmitSoftware.VolmLib:native-v26_3_R1:master-SNAPSHOT') {
transitive = false
}
implementation(volmLibCoordinate) {
changing = true
transitive = false
}
compileOnly(hiddenOreCoordinate) {
changing = true
transitive = false
}
compileOnly(irisCoordinate) {
changing = true
transitive = false
}
implementation('de.crazydev22.slimjar.helper:spigot:2.1.9')
add('platformUtilsLibrary', libs.platformUtils) {
transitive = false
}
implementation(files(strippedPlatformUtils.flatMap { Jar task -> task.archiveFile }))
compileOnly("io.papermc.paper:paper-api:${paperDevBundleVersion}")
// Cancer
slimApi(libs.fukkit) {
exclude(group: 'org.spigotmc', module: 'spigot-api')
}
slimApi(libs.amulet)
slimApi(libs.chrono)
slimApi(libs.spatial)
slimApi(libs.kotlin.coroutines)
// Dynamically Loaded
slim(libs.bstats)
slimApi(libs.adventure.minimessage)
slimApi(libs.adventure.platform)
slimApi(libs.adventure.gson)
slimApi(libs.adventure.legacy)
slimApi(libs.lettuce)
slimApi(libs.particle)
add('advancementLibrary', libs.ultimateAdvancementApi) {
transitive = false
}
compileOnly(libs.ultimateAdvancementApi)
api(files(strippedAdvancementLibrary.flatMap { Jar task -> task.archiveFile }))
slimApi(libs.customBlockData)
slimApi(libs.lur)
slimApi(libs.lang3)
slimApi(libs.effectLib)
slimApi(libs.gson)
slimApi(libs.toml4j)
slimApi(libs.fastutil)
slimApi(libs.caffeine)
//Random Api's
compileOnlyApi('me.clip:placeholderapi:2.11.6')
compileOnly('com.github.MilkBowl:VaultAPI:1.7') {
transitive = false
}
compileOnlyApi('com.github.DeadSilenceIV:AdvancedChestsAPI:2.9-BETA')
compileOnlyApi('com.sk89q.worldguard:worldguard-bukkit:7.0.8')
compileOnlyApi('com.github.FrancoBM12:API-MagicCosmetics:2.2.8')
compileOnlyApi('com.massivecraft:Factions:1.6.9.5-U0.6.21')
compileOnlyApi('com.github.angeschossen:ChestProtectAPI:3.9.1')
compileOnlyApi('com.github.TechFortress:GriefPrevention:16.18.1')
compileOnlyApi('com.griefdefender:api:2.1.1-SNAPSHOT')
compileOnlyApi(fileTree('libs') { include('*.jar') })
testImplementation("io.papermc.paper:paper-api:${paperDevBundleVersion}")
testImplementation('me.clip:placeholderapi:2.11.6') {
transitive = false
}
testImplementation('com.github.MilkBowl:VaultAPI:1.7') {
transitive = false
}
testImplementation('org.junit.jupiter:junit-jupiter:5.11.4')
testImplementation('org.mockito:mockito-core:5.14.2')
testImplementation('org.mockito:mockito-junit-jupiter:5.14.2')
testImplementation('org.assertj:assertj-core:3.26.3')
testImplementation(irisCoordinate) {
changing = true
transitive = false
}
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
}
tasks.named('test', Test) {
useJUnitPlatform()
jvmArgs('-Dnet.bytebuddy.experimental=true')
maxParallelForks = Math.max(1, Runtime.runtime.availableProcessors().intdiv(2))
testLogging {
events('failed')
showStandardStreams = false
exceptionFormat = 'full'
}
}
tasks.register('verifyPaper263Compatibility') {
group = 'verification'
description = 'Compiles main and test sources with -PpaperDevBundleVersion=26.3.build.25-alpha.'
dependsOn(tasks.named('compileJava'), tasks.named('compileTestJava'))
doLast {
if (paperDevBundleVersion != '26.3.build.25-alpha') {
throw new GradleException('Run verifyPaper263Compatibility with -PpaperDevBundleVersion=26.3.build.25-alpha.')
}
}
}
def lib = 'art.arcane.adapt.util'
slimJar {
mirrors = [
new Mirror(
uri('https://maven-central.storage-download.googleapis.com/maven2').toURL(),
uri('https://repo.maven.apache.org/maven2/').toURL()
)
]
relocate('manifold', "${lib}.manifold")
relocate('art.arcane.volmlib', "${lib}.arcane.volmlib")
relocate('Fukkit.extensions', "${lib}.extensions")
relocate('Amulet.extensions', "${lib}.extensions")
relocate('com.fren_gor.ultimateAdvancementAPI', "${lib}.advancements")
relocate('net.byteflux.libby', "${lib}.libby")
relocate('com.jeff_media.customblockdata', "${lib}.customblocks")
relocate('org.bstats', "${lib}.bstats")
}
/**
* Configure Adapt for shading
*/
shadowJarTask.configure {
manifest.attributes('paperweight-mappings-namespace': 'mojang')
minimize {
exclude(dependency('de.crazydev22.slimjar.helper:.*:.*'))
exclude(dependency('com.github.VolmitSoftware.VolmLib:.*:.*'))
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude('net/kyori/**')
exclude('com/google/gson/**')
exclude('com/fren_gor/ultimateAdvancementAPI/nms/v*/**')
exclude { FileTreeElement entry ->
String nativePrefix = 'art/arcane/volmlib/nativelib/'
String path = entry.path
if (!path.startsWith(nativePrefix) || !path.endsWith('.class')) {
return false
}
String relative = path.substring(nativePrefix.length())
return relative.contains('/') && !relative.matches('(?:common/|v26_[23]_R1/)?(?:player|entity|advancement)/.*')
}
}
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor(0, 'seconds')
resolutionStrategy.cacheDynamicVersionsFor(0, 'seconds')
}
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_25)) {
System.err.println()
System.err.println('=========================================================================================================')
System.err.println('You must run gradle on Java 25 or newer. You are using ' + JavaVersion.current())
System.err.println()
System.err.println('=== For IDEs ===')
System.err.println('1. Configure the project for Java 25')
System.err.println('2. Configure the bundled gradle to use Java 25 in settings')
System.err.println()
System.err.println('=== For Command Line (gradlew) ===')
System.err.println('1. Install JDK 25 from https://adoptium.net/temurin/releases/?version=25')
System.err.println('2. Set JAVA_HOME environment variable to the new jdk installation folder such as C:/Program Files/Java/jdk-25')
System.err.println('3. Open a new command prompt window to get the new environment variables if need be.')
System.err.println('=========================================================================================================')
System.err.println()
System.exit(69)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
tasks.named('build').configure {
dependsOn(shadowJarTask)
}
sourceSets {
gameplayFixture {
java.srcDir('src/test/gameplay/fixture/java')
resources.srcDir('src/test/gameplay/fixture/resources')
compileClasspath += sourceSets.main.output + sourceSets.main.compileClasspath
}
}
tasks.register('gameplayFixtureJar', Jar) {
group = 'verification'
description = 'Builds the isolated Paper gameplay observer and arena fixture.'
dependsOn(tasks.named('gameplayFixtureClasses'))
from(sourceSets.gameplayFixture.output)
archiveFileName = 'AdaptGameplayFixture.jar'
}
tasks.register('gameplayContractTest', Exec) {
group = 'verification'
commandLine('node', '--test', 'src/test/gameplay/contract.test.mjs')
}
tasks.named('check').configure {
dependsOn(tasks.named('gameplayContractTest'))
dependsOn(tasks.named('gameplayFixtureJar'))
}
tasks.named('check').configure {
dependsOn(verifyLanguagePackagingTask)
}
tasks.register('adapt', Copy) {
from(shadowJarTask.flatMap { it.archiveFile })
into(layout.buildDirectory)
rename { String ignored -> "Adapt-${version}.jar" }
}
void registerCustomOutputTask(String name, String path, boolean doRename = true) {
if (!System.getProperty('os.name').toLowerCase().contains('windows')) {
return
}
createOutputTask(name, path, doRename)
}
void registerCustomOutputTaskUnix(String name, String path, boolean doRename = true) {
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
return
}
createOutputTask(name, path, doRename)
}
void createOutputTask(String name, String path, boolean doRename = true) {
def shadowJarTask = tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar)
tasks.register("build${name}", Copy) {
group = 'development'
outputs.upToDateWhen { false }
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(shadowJarTask)
from(shadowJarTask.flatMap { it.archiveFile })
into(file(path))
if (doRename) {
rename { String ignored -> 'Adapt.jar' }
}
if (name == 'PsychoLT') {
doLast {
project.copy {
from(shadowJarTask.get().archiveFile.get().asFile)
into(project.file('../PluginOuts'))
rename { String ignored -> "Adapt-${project.version}.jar" }
}
}
}
}
}
pluginPackaging {
artifacts {
create('distribution') {
taskName = 'shadowJar'
policyName = 'Adapt'
prunePrefixes = ['art/arcane/adapt/util/arcane/volmlib/']
keepPrefixes = ['art/arcane/adapt/util/arcane/volmlib/util/matter/slices/',
'art/arcane/adapt/util/arcane/volmlib/nativelib/']
shrinkRules = [file('packaging/shrink.pro')]
shrinkDontwarn = ['org.sqlite.**', 'net.minecraft.**', 'org.bukkit.craftbukkit.**']
shrinkRelocations = [
'manifold': "${lib}.manifold",
'Fukkit.extensions': "${lib}.extensions",
'Amulet.extensions': "${lib}.extensions",
'net.byteflux.libby': "${lib}.libby",
'com.jeff_media.customblockdata': "${lib}.customblocks",
'org.bstats': "${lib}.bstats"
]
}
}
}