forked from Minehut/Skript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
366 lines (311 loc) · 10.7 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
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id "com.github.hierynomus.license" version "0.14.0"
id "com.github.johnrengelman.shadow" version "5.2.0"
}
apply plugin: 'java'
apply plugin: 'maven-publish'
ext {
paperVersion = '1.16.4-R0.1-SNAPSHOT' // NOTICE: Edit this when updating to a new MC Version
}
// Substitute dependencies' versions of Bukkit with latest Paper API
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module('org.bukkit:bukkit') with module("com.destroystokyo.paper:paper-api:${paperVersion}")
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
url 'http://maven.sk89q.com/repo'
}
maven {
url 'https://papermc.io/repo/repository/maven-public/'
}
maven {
url 'http://ci.emc.gs/nexus/content/groups/aikar/'
}
maven {
url 'https://jitpack.io'
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url 'https://repo.codemc.org/repository/maven-public'
}
}
configurations {
ecj
shade
implementation.extendsFrom(shade)
}
dependencies {
ecj 'org.eclipse.jdt:ecj:3.15.0'
}
sourceCompatibility = 1.8
compileJava {
options.fork = true
options.encoding = 'UTF-8'
options.compilerArgs = ['-properties', '.settings/org.eclipse.jdt.core.prefs', '-encoding', 'UTF-8',
'-warn:-tasks(TODO|FIXME|REMIND)']
options.forkOptions.with {
executable = 'java'
jvmArgs = ['-classpath', project.configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main']
}
}
}
dependencies {
implementation "com.destroystokyo.paper:paper-api:${paperVersion}"
implementation 'org.eclipse.jdt:org.eclipse.jdt.annotation:1.1.0'
implementation 'com.google.code.findbugs:findbugs:3.0.1'
implementation 'com.sk89q.worldguard:worldguard-legacy:7.0.0-SNAPSHOT'
implementation 'com.github.marcelo-mason:PreciousStones:24e3d4bf67b7240ae36b32be10e99d4091938c5c'
implementation('net.milkbowl.vault:Vault:1.7.1') {
exclude group: 'org.bstats', module: 'bstats-bukkit'
}
shade 'io.papermc:paperlib:1.0.5'
testImplementation 'junit:junit:4.12'
testImplementation 'org.easymock:easymock:3.6'
implementation fileTree(dir: 'lib', include: '*.jar')
}
processResources {
filter ReplaceTokens, tokens: [
"version": System.getenv("SKRIPT_VERSION") == null ? project.property("version") : System.getenv("SKRIPT_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"
]
}
task jar(overwrite: true, type: ShadowJar) {
archiveName System.getenv('SKRIPT_JAR_NAME') == null ? 'Skript.jar' : System.getenv("SKRIPT_JAR_NAME")
from sourceSets.main.output
}
task build(overwrite: true, type: ShadowJar) {
archiveName System.getenv('SKRIPT_JAR_NAME') == null ? 'Skript.jar' : System.getenv("SKRIPT_JAR_NAME")
from sourceSets.main.output
}
//jar.dependsOn shadowJar
tasks.withType(ShadowJar) {
configurations = [project.configurations.shade]
dependencies {
include (dependency('io.papermc:paperlib'))
}
relocate 'io.papermc.lib', 'ch.njol.skript.paperlib'
manifest {
attributes("Name": "ch/njol/skript",
"Sealed": "true")
}
from('skript-aliases') {
into('aliases-english') // Change this if we get aliases in other languages
}
// Include all modules of Skript
from 'skript-worldguard6/build/classes/java/main'
from 'skript-worldguard7fawe/build/classes/java/main'
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
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 checkAliases {
description 'Checks for the existence of the aliases.'
doLast {
def aliasFolder = new 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'.")
}
}
}
jar.dependsOn checkAliases
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId "ch.njol"
artifactId "skript"
version project.property("version")
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
repositories {
maven {
url "file:///itemapi_repo/"
}
}
}
// Set compile encoding to UTF-8 (#850)
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
// Task to check that test scripts are named correctly
tasks.create('testNaming') {
doLast {
// Regression tests
for (def file : project.file('src/test/skript/tests/regressions').listFiles()) {
def name = file.getName()
if (!name.toLowerCase().equals(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 and is it development mode task
void createTestTask(String name, String environments, boolean devMode) {
tasks.create(name, Exec) {
// Execute JUnit tests, compile Skript and check test naming
dependsOn(test, jar, testNaming)
if (devMode) {
standardInput = System.in
}
commandLine 'java', '-cp',
"build${File.separator}libs${File.separator}Skript.jar${File.pathSeparator}" +
project.configurations.runtimeClasspath.find {it.name.startsWith('gson')},
'ch.njol.skript.tests.platform.PlatformMain',
'test_runners', 'src/test/skript/tests', 'src/test/resources/runner_data', environments, "" + devMode
}
}
// Register different Skript testing tasks
createTestTask('quickTest', 'src/test/skript/environments/main/paper-1.16.3.json', false)
createTestTask('skriptTest', 'src/test/skript/environments/main', false)
createTestTask('skriptTestFull', 'src/test/skript/environments/', false)
createTestTask('skriptTestDev', 'src/test/skript/environments/main/' + (System.getProperty('skript.testEnv') == null
? 'paper-1.16.3.json' : System.getProperty('skript.testEnv') + '.json'), true)
// Build flavor configurations
task githubResources(type: ProcessResources) {
from ('src/main/resources') {
include '**'
version = System.getenv("SKRIPT_VERSION") == null ? project.property("version") : System.getenv("SKRIPT_VERSION")
def channel = "stable"
if (version.contains("alpha")) {
channel = "alpha"
} else if (version.contains("beta")) {
channel = "beta"
}
filter ReplaceTokens, tokens: [
"version": version,
"today": "" + LocalDate.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",
"Sealed": "true")
}
from('skript-aliases') {
into('aliases-english')
}
// Include all modules of Skript
from 'skript-worldguard6/build/classes/java/main'
from 'skript-worldguard7fawe/build/classes/java/main'
}
task spigotResources(type: ProcessResources) {
from ('src/main/resources') {
include '**'
version = System.getenv("SKRIPT_VERSION") == null ? project.property("version") : System.getenv("SKRIPT_VERSION")
def channel = "stable"
if (version.contains("alpha")) {
channel = "alpha"
} else if (version.contains("beta")) {
channel = "beta"
}
filter ReplaceTokens, tokens: [
"version": version,
"today": "" + LocalDate.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",
"Sealed": "true")
}
from('skript-aliases') {
into('aliases-english')
}
// Include all modules of Skript
from 'skript-worldguard6/build/classes/java/main'
from 'skript-worldguard7fawe/build/classes/java/main'
}
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": "" + LocalDate.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
dependsOn licenseMain
archiveName = 'Skript-nightly.jar'
manifest {
attributes("Name": "ch/njol/skript",
"Sealed": "true")
}
from('skript-aliases') {
into('aliases-english')
}
// Include all modules of Skript
from 'skript-worldguard6/build/classes/java/main'
from 'skript-worldguard7fawe/build/classes/java/main'
}