forked from ModificationStation/StationAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
347 lines (301 loc) · 12 KB
/
build.gradle
File metadata and controls
347 lines (301 loc) · 12 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
import net.fabricmc.loom.util.GroovyXmlUtil
plugins {
id "maven-publish"
id 'babric-loom' version '1.1.7'
}
@SuppressWarnings('unused') // Shut up, it IS used.
static def getSubprojectVersion(project, ver) {
return "${project.mod_version}-$ver"
}
@SuppressWarnings('unused')
def moduleDependencies(Project project, String... projectNames) {
project.with {
def modules = projectNames.collect { dependencies.project(path: ":$it", configuration: 'dev') }
dependencies {
modules.each {
implementationOnly it
}
}
publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml {
addDependency(it, 'implementation', *modules)
}
}
}
}
}
}
void addDependency(XmlProvider xml, String scope, Object... dependencies) {
def dependenciesNode = GroovyXmlUtil.getOrCreateNode(xml.asNode(), "dependencies")
dependencies.each {dependency ->
dependenciesNode.appendNode('dependency').with {
appendNode('groupId', dependency.group)
appendNode('artifactId', dependency.name)
appendNode('version', dependency.version)
appendNode('scope', scope)
}
}
}
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'babric-loom'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
repositories {
maven {
name = 'Froge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
maven {
name = 'Glass Snapshots'
url = 'https://maven.glass-launcher.net/snapshots'
}
maven {
name = 'Glass Releases'
url = 'https://maven.glass-launcher.net/releases'
}
maven {
name = 'Jitpack'
url = 'https://jitpack.io/'
}
mavenCentral()
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
}
configurations {
implementationOnly //A non-transitive implementation
runtimeClasspath.extendsFrom implementationOnly
compileClasspath.extendsFrom implementationOnly
// Required cause loom 0.14 for some reason doesn't remove asm-all 4.1. Ew.
all*.exclude group: 'org.ow2.asm', module: "asm-debug-all"
all*.exclude group: 'org.ow2.asm', module: "asm-all"
}
dependencies {
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation 'org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2'
implementation "org.apache.logging.log4j:log4j-core:2.17.2"
implementation "com.google.guava:guava:31.1-jre"
implementation "com.google.code.gson:gson:2.9.0"
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.glasslauncher:bin:${project.yarn_mappings}"
modImplementation "babric:fabric-loader:${project.loader_version}"
implementationOnly 'org.apache.commons:commons-lang3:3.12.0'
implementationOnly 'commons-io:commons-io:2.11.0'
implementation "net.jodah:typetools:${project.typetools_version}"
implementation "com.github.mineLdiver:expressions:${project.expressions_version}"
implementation "com.github.mineLdiver:UnsafeEvents:${project.unsafeevents_version}"
implementation "it.unimi.dsi:fastutil:${project.fastutil_version}"
//noinspection GradlePackageUpdate
implementation "com.github.ben-manes.caffeine:caffeine:${project.caffeine_version}"
implementation "com.mojang:datafixerupper:${project.dfu_version}"
implementation "maven.modrinth:spasm:${project.spasm_version}"
// convenience stuff
// adds some useful annotations for data classes. does not add any dependencies
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
// adds some useful annotations for miscellaneous uses. does not add any dependencies, though people without the lib will be missing some useful context hints.
implementationOnly 'org.jetbrains:annotations:23.0.0'
modLocalRuntime("com.github.calmilamsy:ModMenu:${project.modmenu_version}") {
transitive false
}
implementation "blue.endless:jankson:1.2.1"
modLocalRuntime("net.glasslauncher.mods:GlassConfigAPI:${project.gcapi_version}") {
transitive false
}
modLocalRuntime("net.glasslauncher:HowManyItems-Fabric-Unofficial:${project.hmi_version}") {
transitive false
}
}
loom {
gluedMinecraftJar()
customMinecraftManifest.set("https://babric.github.io/manifest-polyfill/${minecraft_version}.json")
}
sourceSets {
test {
compileClasspath += main.compileClasspath + main.output
runtimeClasspath += main.runtimeClasspath + main.output
}
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
// Include license inside of the mod jar
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Makes gradle shut up
compileJava {
options.compilerArgs << '-XDignore.symbol.file'
options.fork = true
options.forkOptions.executable = System.getProperty("java.home") + "/bin/javac" + (System.getProperty("os.name").startsWith("Windows")? ".exe" : "")
}
publishing {
repositories {
if (project.hasProperty("glass_maven_url")) {
maven {
url = "${project.glass_maven_url}"
credentials {
username "${project.glass_maven_username}"
password "${project.glass_maven_password}"
}
}
}
}
publications {
mavenJava(MavenPublication) {
afterEvaluate {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
pom {
withXml {
//noinspection GroovyImplicitNullArgumentCall Not an implicit null, you fuck
def depsNode = asNode().appendNode("dependencies")
// Jank solution to an annoying issue
ArrayList<String[]> deps = new ArrayList<>()
deps.add(["net.jodah", "typetools", "${project.typetools_version}"] as String[])
deps.add(["com.github.mineLdiver", "expressions", "${project.expressions_version}"] as String[])
deps.add(["com.github.mineLdiver", "UnsafeEvents", "${project.unsafeevents_version}"] as String[])
deps.add(["it.unimi.dsi", "fastutil", "${project.fastutil_version}"] as String[])
deps.add(["com.github.ben-manes.caffeine", "caffeine", "${project.caffeine_version}"] as String[])
deps.add(["com.mojang", "datafixerupper", "${project.dfu_version}"] as String[])
deps.add(["org.apache.commons", "commons-lang3", "3.5"] as String[])
deps.add(["commons-io", "commons-io", "2.5"] as String[])
deps.add(["maven.modrinth", "spasm", "${project.spasm_version}"] as String[])
deps.each {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it[0])
depNode.appendNode("artifactId", it[1])
depNode.appendNode("version", it[2])
depNode.appendNode("scope", "compile")
}
}
}
}
}
}
}
//Subprojects will set these themselves
//Not neatly. - calm
project.group = project.maven_group
project.archivesBaseName = project.archives_base_name
project.version = project.hasProperty("override_version")? project.override_version.substring(0, 7) : project.mod_version
subprojects {subproject ->
assert this.remapJar != remapJar //No accidents moving this around
this.remapJar.dependsOn(remapJar)
group = project.maven_group + ".${project.parent.archivesBaseName}.${project.hasProperty("override_version")? project.override_version.substring(0, 7) : project.mod_version}"
configurations {
out {
canBeConsumed = true
canBeResolved = false
}
dev {
canBeConsumed = true
canBeResolved = false
}
test {
canBeConsumed = true
canBeResolved = false
}
}
task testJar(type: Jar) {
from sourceSets.test.output
classifier 'test'
}
artifacts {
out remapJar
dev jar
test testJar
}
//Attach the subproject to the root project
this.dependencies {
implementationOnly project(path: ":$name", configuration: 'dev')
testImplementation project(path: ":$name", configuration: 'test')
include project(path: ":$name", configuration: 'out')
}
//Mark the subproject as a compile time dependency of the root project
this.publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml {xml ->
addDependency(xml, 'compile', subproject)
}
}
}
}
}
dependencies {
include "net.jodah:typetools:${project.typetools_version}"
include "com.github.mineLdiver:expressions:${project.expressions_version}"
include "com.github.mineLdiver:UnsafeEvents:${project.unsafeevents_version}"
include "it.unimi.dsi:fastutil:${project.fastutil_version}"
//noinspection GradlePackageUpdate
include "com.github.ben-manes.caffeine:caffeine:${project.caffeine_version}"
include "com.mojang:datafixerupper:${project.dfu_version}"
include "maven.modrinth:spasm:${project.spasm_version}"
}
// Makes java shut up
compileTestJava {
options.compilerArgs << '-XDignore.symbol.file'
options.fork = true
options.forkOptions.executable = System.getProperty("java.home") + "/bin/javac" + (System.getProperty("os.name").startsWith("Windows")? ".exe" : "")
}
publishing.publications.mavenJava(MavenPublication) {
artifactId project.archives_base_name
}
loom {
runs {
register("runTestmodClient") {
source("test")
//noinspection GroovyImplicitNullArgumentCall
client()
}
register("runTestmodServer") {
source("test")
//noinspection GroovyImplicitNullArgumentCall
server()
}
}
}
task testJar(type: Jar) {
from sourceSets.test.output
classifier 'test'
}