This repository has been archived by the owner on Oct 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
363 lines (297 loc) · 10.2 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
buildscript {
repositories {
mavenCentral()
maven {
name = "AerialWorks"; url = "https://aerialworks.ddns.net/maven"
}
}
dependencies {
classpath 'org.asf.cyan.cornflower:Cornflower:1.0.0.A48'
}
}
plugins {
id 'java'
id 'maven-publish'
}
sourceCompatibility = '1.11'
targetCompatibility = '1.11'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.asf.cyan.cornflower'
apply from: 'asf.mvn.publish.gradle'
// Project information
group="org.asf.mods"
version="1.0.0.A14"
// Automatically assigned
def mod_id = "mc2fa"
def mod_group = "servertools"
// Loader information
def gameVersion = "1.17.1"
def cyanVersion = "1.0.0.A14"
def modkitVersion = "1.2"
def protocolHooksVersion = "1.2"
if (project.hasProperty("overrideGameVersion"))
gameVersion = project.getProperty("overrideGameVersion")
def majorVersion = gameVersion
if (majorVersion.split("\\.").length > 2)
majorVersion = majorVersion.substring(0, majorVersion.lastIndexOf("."))
version = version + "-" + gameVersion
sourceSets {
main {
java.srcDirs = [ "src/main/java/$majorVersion", "src/main/java/shared" ]
resources.srcDirs = [ "src/main/resources" ]
}
}
// Mod information
def mod_class_name = "Server2FAMod"
def mod_package_name = "org.asf.mods.mc2fa"
def mod_display_name = "MC2FA"
// The mod description language key
def modDescLanguageKey = "${mod_group}.${mod_id}.description" // Uses the group and id for language
// Fallback description
def modDescription = '''
MC2FA - Two-factor Authentication Server Mod.
'''
// Repository configuration
repositories {
mavenCentral()
}
// Dependency configuration
dependencies {
//
// Selects modloader dependencies:
// 2 = Base Moddidng (API_BASE_MODDING)
// 4 = Core Modding (includes modding) (API_CORE_MODDING)
// 8 = FLUID (API_FLUID)
// 16 = CyanCore (API_CYANCORE)
// 32 = MTK (API_MTK)
// 64 = ClassTrust (API_CLASSTRUST)
//
// 128 = Full CyanLoader (unrecommended, use of base/core modding is preferred)
//
implementation Modloader.forModloader("cyan", cyanVersion, API_BASE_MODDING)
// Selects game dependencies
implementation Game.forGame("Minecraft", gameVersion)
// Adds the ModKit API, Cyan 1.0.0.A14 provides specification 1.0, 1.1 and 1.2
implementation API.forAPI("ModKit", modkitVersion)
// ProtocolHooks
implementation Mod.byId("protocol:hooks", protocolHooksVersion + "-" + gameVersion)
// Mod dependencies:
//
// implementation Mod.byId("group:id", "version") // required dependency
// implementation Mod.byId("group:id", "version", true) // optional dependency
//
// Using Mod.byId registers the mod id in the modfile manifest, adds all dependencies and respositories
// and downloads the mod CMF or CCMF to the mods directory of the debug environments.
}
// Platform configuration
platforms {
// Needs to be present as FIRST entry when using other modding platforms.
// Minecraft VANILLA platform, configures the base version.
VANILLA {
// Game version
version gameVersion
}
if (majorVersion.equals("1.16")) {
// MCP Platform, for forge support
MCP {
// YYYYMMDD.HHMMSS, should match upstream forge
version "20210115.111550"
// Forge version
modloader "36.1.35"
}
} else if (gameVersion.startsWith("1.17.")) {
// MCP Platform, for forge support
MCP {
// YYYYMMDD.HHMMSS, should match upstream forge
version "20210706.113038"
// Forge version
modloader "37.0.27"
}
}
// Intermediary Platform, for fabric support
INTERMEDIARY {
// Intermediary version.
// It should match the game version.
version gameVersion
// Fabric version
// For latest, use getLatestFabricVersion("game-version")
// However it is recommended to use getSupportedFabricVersion("game-version", "cyan-version")
modloader getSupportedFabricVersion(gameVersion, cyanVersion)
}
// Spigot Platform, for paper support
SPIGOT {
//
// Paper version, only use paper version compatible with the mappings,
//
// Use getPaperVersion("mappings-version") to retrieve the latest paper version that has been
// registered as 'compatible with mappings' in the generic version manifest of CYAN.
//
// Use getPaperVersionByDate("game-vesion", "mappings-version") to retrieve the paper version with date
// aproximatly matching the mappings publish date. (USE AT YOUR OWN RISK, SCRAPES SPIGOT WEB PAGE FOR DATE
// AND RECURSES THROUGH PAPER VERSIONS TO FIND THE UPDATE, PLEASE STORE VALUE AND USE AS LEAST AS POSSIBLE)
//
//
// We strongly recommed for you to use getSupportedPaperVersion("game-version", "cyan-version")
// and getSpigotMappingsByPaperVersion("game-version", "paper-version") to get the mappings.
//
// Paper version:
//
def paperVersion = getSupportedPaperVersion(gameVersion, cyanVersion)
modloader paperVersion
//
// Paper mappings version, it is best to only use mappings that have been given a green light by the Cyan team.
//
// Use getSpigotMappingsByPaperVersion("game-version", "paper-version") for the mappings used
// together with the paper version during cyan's compilation and testing process (most recommended)
//
// Use getRecommendedSpigotMappings("game-version") for the mappings that have been given a green light
// Use getLatestSpigotMappings("game-version") for mappings in pre-release testing stage
// Use getTestingSpigotMappings("game-version") for mappings in early testing stage (unrecommended, can really break things)
//
// With paper 1.17, using the remote versions is impossible.
//
//
// Commit hash and paper build for mappings version (commit:PB_build)
version getSpigotMappingsByPaperVersion(gameVersion, paperVersion)
}
}
// Adds RIFT tasks for the platforms
addPlatformRiftTasks {
platform platforms
from tasks.jar.getArchiveFile()
}
cmf {
manifest {
modfileManifest {
// Sets the id and group
modid mod_id
modgroup mod_group
// Sets the mod class and package
mod_class mod_class_name
mod_package mod_package_name
// Sets the version and name
display_name mod_display_name
mod_version project.version
// The following sets the description, the first parameter is the language key
// for translation, the second is the actual description.
mod_description modDescLanguageKey, modDescription
platform platforms
// Sets the code sources
jar tasks.jar.getArchiveFile(), DEOBFUSCATED
jar riftTasks
// Sets the remote dependencies
maven_dependency remoteDependencies
// Sets the game version
game_version gameVersion.replace(".", "\\."), "only " + gameVersion
//
// Add dependencies like this:
// dependency 'modgroup:modid', '>=greater-than-version'
// dependency 'modgroup:modid', 'specific-version'
// dependency 'modgroup:modid', '<=less-than-version'
// dependency 'modgroup:modid', '=~version-regex'
// dependency 'modgroup:modid', '>=greater-than & <=not-less-than-this'
// dependency 'modgroup:modid', '>=greater-than | or-exactly'
//
// Optional dependencies are added like:
// optional_dependency 'modgroup:modid', '>=greater-than-version'
// optional_dependency 'modgroup:modid', 'specific-version'
// optional_dependency 'modgroup:modid', '<=less-than-version'
// optional_dependency 'modgroup:modid', '=~version-regex'
// optional_dependency 'modgroup:modid', '>=greater-than & <=not-less-than-this'
// optional_dependency 'modgroup:modid', '>=greater-than | or-exactly'
//
//
// In the mod main class, you can use the @ModSupportHandler("group:id") annotation to create a
// support handler. Methods annotated with that should have ONE parameter of any of the following types:
//
// Supported types: AbstractMod, AbstractCoremod, IMod, ICoremod and Direct mod instances
// (direct references might malfunction with optional dependencies)
//
// To avoid a ClassNoDefError with optional dependencies, you can use the ModProvider<ModInstance> type.
// The ModProvider interface uses type erasure to work around this potential issue.
//
// Auto-updater
updateserver "https://aerialworks.ddns.net/cyan/trust/download"
}
}
archiveVersion = project.version
archiveExtension = 'cmf'
destinationDirectory = file("$buildDir/cmf")
}
// Processes resource files
processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from sourceSets.main.resources.srcDirs
// The variables to set
def props = new HashMap([
// Project information
'version': project.version,
'minecraft': gameVersion,
'cyanVersion': cyanVersion,
'name': project.name,
// Escape characters for json
'description': modDescription.replace("\\", "\\\\").replace("\b", "\\b").replace("\n", "\\n").replace("\t", "\\t").replace("\"", "\\\"").replace("\r", "\\r"),
// Set the description language key
'descriptionKey': modDescLanguageKey
])
// Expand the variables in files
expand props
// Add the variables as input properties
props.forEach { key, val -> inputs.property key, val }
}
rift.dependsOn jar
build.finalizedBy rift
rift.finalizedBy cmf
task javaDocs(type: Javadoc) {
title "MC2FA: $version"
classpath = sourceSets.main.runtimeClasspath
source = sourceSets.main.allJava
exclude "**/internal/**"
exclude "**/org/asf/mods/**"
}
javadoc {
title "MC2FA: $version"
exclude "**/internal/**"
exclude "**/org/asf/mods/**"
}
task javadocJar(type: Jar, dependsOn: 'javaDocs') {
from javadoc
classifier = 'javadoc'
destinationDirectory = file("$buildDir/Javadocs")
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
exclude "**/extra/**"
destinationDirectory = file("$buildDir/Source jars")
}
artifacts {
archives javadocJar
archives sourcesJar
}
rift.dependsOn jar
build.finalizedBy rift
rift.finalizedBy cmf
configurePublish {
pretty_name "MC2FA"
description "$modDescription"
page "https://aerialworks.ddns.net/maven"
address "https://aerialworks.ddns.net/maven"
license {
license_name "Cyan Modding License"
}
author {
name "AerialWorks Software Foundation"
id "ASF"
}
artifact {
name project.name
artifact_version "${project.version}"
task tasks.cmf
task tasks.jar
task tasks.sourcesJar
task tasks.javadocJar
}
}
initializeASFMVNPublish()