-
-
Notifications
You must be signed in to change notification settings - Fork 374
/
build.gradle
292 lines (267 loc) · 9.16 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
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
plugins {
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'com.github.hierynomus.license' version '0.16.1'
id 'maven-publish'
id 'java'
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ["-source", "1.8", "-target", "1.8"]
}
allprojects {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://papermc.io/repo/repository/maven-public/' }
maven { url 'https://ci.emc.gs/nexus/content/groups/aikar/' }
}
}
dependencies {
shadow group: 'io.papermc', name: 'paperlib', version: '1.0.6'
implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.17-R0.1-SNAPSHOT'
implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.2.600'
implementation group: 'com.google.code.findbugs', name: 'findbugs', version: '3.0.1'
implementation group: 'com.sk89q.worldguard', name: 'worldguard-legacy', version: '7.0.0-SNAPSHOT'
implementation group: 'com.github.marcelo-mason', name: 'PreciousStones', version: '24e3d4bf67'
implementation group: 'net.milkbowl.vault', name: 'Vault', version: '1.7.1', {
exclude group: 'org.bstats', module: 'bstats-bukkit'
}
implementation fileTree(dir: 'lib', include: '*.jar')
}
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
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
}
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'))
}
relocate 'io.papermc.lib', 'ch.njol.skript.paperlib'
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
}
from 'skript-worldguard6/build/classes/java/main'
}
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
}
}
}
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.create('testNaming') {
doLast {
// Regression tests
for (def file : project.file('src/test/skript/tests/regressions').listFiles()) {
def name = file.getName()
if (name.toLowerCase() != 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) {
// Compile Skript and check test naming
dependsOn jar, testNaming
doFirst {
if (devMode) {
standardInput = System.in
}
javaexec {
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
]
}
}
}
}
// Register different Skript testing tasks
createTestTask('quickTest', 'src/test/skript/environments/main/paper-1.16.5.json', false)
createTestTask('skriptTest', 'src/test/skript/environments/main', false)
createTestTask('skriptTestFull', 'src/test/skript/environments/', false)
createTestTask('skriptTestDev', 'src/test/skript/environments/main/' + (project.property('testEnv') == null
? 'paper-1.17.json' : project.property('testEnv') + '.json'), 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'
)
}
from 'skript-worldguard6/build/classes/java/main'
}
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'
)
}
from 'skript-worldguard6/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' : '' + 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'
)
}
from 'skript-worldguard6/build/classes/java/main'
}