forked from SkriptLang/Skript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
465 lines (402 loc) · 14.3 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
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
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.apache.tools.ant.filters.ReplaceTokens
import java.time.LocalTime
buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
}
dependencies {
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
plugins {
id 'net.minecraftforge.gradle' version '5.1.+'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.hierynomus.license' version '0.16.1'
id 'maven-publish'
id 'java'
}
apply plugin: 'org.spongepowered.mixin'
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "100000"
}
}
}
minecraft {
// The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// official MCVersion Official field/method names from Mojang mapping files
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
//
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
// Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.19.2'
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug'
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'easy-lang'
mods {
easylang {
source sourceSets.main
}
}
}
clientAlt {
parent runs.client
args '--username', "DevAlt"
taskName "runClientAlt"
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'easy-lang'
mods {
easylang {
source sourceSets.main
}
}
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'easy-lang'
mods {
easylang {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'easylang', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
easylang {
source sourceSets.main
}
}
}
}
}
mixin {
add sourceSets.main, "easy-lang.refmap.json"
config "easy-lang.mixins.json"
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
allprojects {
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://ci.emc.gs/nexus/content/groups/aikar/' }
}
}
dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.19.2-43.2.0'
implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.2.700'
implementation group: 'com.google.code.findbugs', name: 'findbugs', version: '3.0.1'
implementation fileTree(dir: 'lib', include: '*.jar')
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
java {
archivesBaseName = 'easy-lang'
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
task checkAliases {
description 'Checks for the existence of the aliases.'
doLast {
def aliasFolder = project.file('skript-aliases')
if (!aliasFolder.exists() || aliasFolder.listFiles().length == 0) {
throw new InvalidUserDataException('Aliases are missing from \'skript-aliases\' folder. Consider fetching submodules with \'git submodule update --init\'.')
}
}
}
task jar(overwrite: true, type: ShadowJar) {
dependsOn checkAliases
archiveName jarName ? 'Skript.jar' : jarName
from sourceSets.main.output
manifest {
attributes([
"Specification-Title" : "easylang",
"Specification-Vendor" : "Qboi123",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "Qboi123",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
jar.finalizedBy('reobfJar')
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
task build(overwrite: true, type: ShadowJar) {
archiveName jarName ? 'Skript.jar' : jarName
from sourceSets.main.output
}
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = "sources"
}
tasks.withType(ShadowJar) {
dependsOn relocateShadowJar
configurations = [
project.configurations.shadow
]
dependencies {
include(dependency('io.papermc:paperlib'))
include(dependency('org.bstats:bstats-bukkit'))
include(dependency('org.bstats:bstats-base'))
}
relocate 'io.papermc.lib', 'ch.njol.skript.paperlib'
relocate 'org.bstats', 'ch.njol.skript.bstats'
manifest {
attributes(
'Name': 'ch/njol/skript',
'Automatic-Module-Name': 'ch.njol.skript',
'Sealed': 'true'
)
}
from 'skript-aliases', {
into 'aliases-english' // Change this if we get aliases in other languages
}
}
processResources {
filter ReplaceTokens, tokens: [
'version' : project.property('version'),
'today' : 'unknown', // Don't leak information about system this was built on
'release-flavor' : 'selfbuilt-unknown', // Note: 'selfbuilt' prefix makes updater report a custom build
'release-channel' : 'none', // No updates, so anything else wouldn't make sense
'release-updater' : 'ch.njol.skript.update.NoUpdateChecker', // Disable update checking
'release-source' : '',
'release-download': 'null'
]
}
publishing {
publications {
maven(MavenPublication) {
groupId "com.github.SkriptLang"
artifactId "Skript"
version project.version
artifact sourceJar
artifact tasks.jar
}
}
repositories {
maven {
name = "repo"
url = "https://repo.skriptlang.org/releases"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
license {
header file('licenseheader.txt')
exclude('**/Metrics.java') // Not under GPLv3
exclude('**/BurgerHelper.java') // Not exclusively GPLv3
exclude('**/*.sk') // Sample scripts and maybe aliases
exclude('**/*.lang') // Language files do not have headers (still under GPLv3)
exclude('**/*.json') // JSON files do not have headers
}
// Task to check that test scripts are named correctly
tasks.register('testNaming') {
doLast {
// Regression tests
for (def file : project.file('src/test/skript/tests/regressions').listFiles()) {
def name = file.getName()
if (name.toLowerCase(Locale.ENGLISH) != name) {
throw new InvalidUserDataException('invalid test name: ' + name)
}
}
// Syntax tests
for (def dir : project.file('src/test/skript/tests/syntaxes').listFiles()) {
for (def file : dir.listFiles()) {
def name = file.getName()
if (!name.startsWith('.') && !Character.isJavaIdentifierStart(name.codePointAt(0))) {
throw new InvalidUserDataException('invalid test name: ' + name)
}
}
}
}
}
// Create a test task with given name, environments dir/file, dev mode and java version.
void createTestTask(String name, String environments, boolean devMode, int javaVersion, boolean genDocs) {
tasks.register(name, JavaExec) {
dependsOn jar, testNaming
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(javaVersion)
}
if (devMode) {
standardInput = System.in
}
group = 'execution'
classpath = files([
'build' + File.separator + 'libs' + File.separator + 'Skript.jar',
project.configurations.runtimeClasspath.find { it.name.startsWith('gson') },
sourceSets.main.runtimeClasspath
])
main = 'ch.njol.skript.tests.platform.PlatformMain'
args = [
'test_runners',
'src/test/skript/tests',
'src/test/resources/runner_data',
environments,
devMode,
genDocs
]
}
}
def latestEnv = 'java17/paper-1.19.3.json'
def latestJava = 17
def oldestJava = 17
// Register different Skript testing tasks
createTestTask('quickTest', 'src/test/skript/environments/' + latestEnv, false, latestJava, false)
createTestTask('skriptTestJava17', 'src/test/skript/environments/java17', false, latestJava, false)
createTestTask('skriptTestJava8', 'src/test/skript/environments/java8', false, oldestJava, false)
createTestTask('skriptTestDev', 'src/test/skript/environments/' + (project.property('testEnv') == null
? latestEnv : project.property('testEnv') + '.json'), true, Integer.parseInt(project.property('testEnvJavaVersion') == null
? latestJava : project.property('testEnvJavaVersion')), false)
tasks.register('skriptTest') {dependsOn skriptTestJava8, skriptTestJava17}
createTestTask('genDocs', 'src/test/skript/environments/' + (project.property('testEnv') == null
? latestEnv : project.property('testEnv') + '.json'), false, Integer.parseInt(project.property('testEnvJavaVersion') == null
? latestJava : project.property('testEnvJavaVersion')), true)
// Build flavor configurations
task githubResources(type: ProcessResources) {
from 'src/main/resources', {
include '**'
version = project.property('version')
def channel = 'stable'
if (version.contains('alpha'))
channel = 'alpha'
else if (version.contains('beta'))
channel = 'beta'
filter ReplaceTokens, tokens: [
'version' : version,
'today' : '' + LocalTime.now(),
'release-flavor' : 'skriptlang-github', // SkriptLang build, distributed on Github
'release-channel' : channel, // Release channel, see above
'release-updater' : 'ch.njol.skript.update.GithubChecker', // Github API client
'release-source' : 'https://api.github.com/repos/SkriptLang/Skript/releases', // Github API URL
'release-download': 'null' // Update checker will figure it out
]
}
into 'build/resources/main'
}
task githubRelease(type: ShadowJar) {
from sourceSets.main.output
dependsOn githubResources
archiveName = 'Skript-github.jar'
manifest {
attributes(
'Name': 'ch/njol/skript',
'Automatic-Module-Name': 'ch.njol.skript',
'Sealed': 'true'
)
}
}
task spigotResources(type: ProcessResources) {
from 'src/main/resources', {
include '**'
version = project.property('version')
def channel = 'stable'
if (version.contains('alpha'))
channel = 'alpha'
else if (version.contains('beta'))
channel = 'beta'
filter ReplaceTokens, tokens: [
'version' : version,
'today' : '' + LocalTime.now(),
'release-flavor' : 'skriptlang-spigot', // SkriptLang build, distributed on Spigot resources
'release-channel' : channel, // Release channel, see above
'release-updater' : 'ch.njol.skript.update.GithubChecker', // Github API client
'release-source' : 'https://api.github.com/repos/SkriptLang/Skript/releases', // Github API URL
'release-download': '\'http://example.com\'' // TODO insert Spigot URL
]
}
into 'build/resources/main'
}
task spigotRelease(type: ShadowJar) {
from sourceSets.main.output
dependsOn spigotResources
archiveName = 'Skript-spigot.jar'
manifest {
attributes(
'Name': 'ch/njol/skript',
'Automatic-Module-Name': 'ch.njol.skript',
'Sealed': 'true'
)
}
}
task nightlyResources(type: ProcessResources) {
from 'src/main/resources', {
include '**'
def hash = 'git rev-parse --short HEAD'.execute().text.trim()
version = project.property('version') + '-nightly-' + hash
filter ReplaceTokens, tokens: [
'version' : version,
'today' : '' + LocalTime.now(),
'release-flavor' : 'skriptlang-nightly', // SkriptLang build, automatically done by CI
'release-channel' : 'alpha', // No update checking, but these are VERY unstable
'release-updater' : 'ch.njol.skript.update.NoUpdateChecker', // No autoupdates for now
'release-source' : '',
'release-download': 'null'
]
}
into 'build/resources/main'
}
task nightlyRelease(type: ShadowJar) {
from sourceSets.main.output
dependsOn nightlyResources, licenseMain
archiveName = 'Skript-nightly.jar'
manifest {
attributes(
'Name': 'ch/njol/skript',
'Automatic-Module-Name': 'ch.njol.skript',
'Sealed': 'true'
)
}
}