This repository was archived by the owner on Jun 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
376 lines (309 loc) · 8.06 KB
/
Copy pathbuild.gradle
File metadata and controls
376 lines (309 loc) · 8.06 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
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
import groovy.json.JsonSlurper
import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.ValidateMixinNameTask
plugins {
id "java-library"
id "eclipse"
id "idea"
id "maven-publish"
alias(libs.plugins.fabric.loom) apply false
alias(libs.plugins.spotless)
}
def moduleDependencies(project, List<String> depNames) {
def deps = depNames.iterator().collect { project.dependencies.project(path: ":$it", configuration: 'namedElements') }
def clientOutputs = depNames.iterator().collect { findProject(":$it").sourceSets.client.output }
project.dependencies {
deps.each {
api it
}
clientOutputs.each {
clientImplementation it
}
}
}
allprojects {
apply plugin: "maven-publish"
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
publishing {
repositories.mavenLocal()
}
apply plugin: "java-library"
apply plugin: "fabric-loom"
apply plugin: "com.diffplug.spotless"
tasks.withType(JavaCompile).configureEach {
it.options.release.set(17)
}
java {
withSourcesJar()
}
loom {
splitEnvironmentSourceSets()
}
sourceSets {
testmod {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
testmodClient {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += client.compileClasspath
runtimeClasspath += client.runtimeClasspath
compileClasspath += testmod.compileClasspath
runtimeClasspath += testmod.runtimeClasspath
}
}
loom {
runtimeOnlyLog4j = true
runs {
testmodClient {
client()
ideConfigGenerated project.rootProject == project
name = "Testmod Client"
source sourceSets.testmodClient
}
testmodServer {
server()
ideConfigGenerated project.rootProject == project
name = "Testmod Server"
source sourceSets.testmod
}
}
}
loom.runs.configureEach {
vmArg("-enableassertions")
}
allprojects.each { p ->
loom.mods.register(p.name) {
sourceSet p.sourceSets.main
sourceSet p.sourceSets.client
}
loom.mods.register(p.name + "-testmod") {
sourceSet p.sourceSets.testmod
sourceSet p.sourceSets.testmodClient
}
}
dependencies {
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn) { classifier("v2") })
// fabric
modImplementation(libs.fabric.api)
modImplementation(libs.fabric.loader)
testmodImplementation sourceSets.main.output
testmodClientImplementation sourceSets.main.output
testmodClientImplementation sourceSets.client.output
testmodClientImplementation sourceSets.testmod.output
}
tasks.withType(ProcessResources).configureEach {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER"))
removeUnusedImports()
importOrder('java', 'javax', '', 'net.minecraft', 'net.fabricmc', 'dev.phomc')
indentWithTabs()
trimTrailingWhitespace()
}
}
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
tasks.register('testmodJar', Jar) {
from sourceSets.testmod.output
from sourceSets.testmodClient.output
destinationDirectory = new File(project.getBuildDir(), "devlibs")
archiveClassifier = "testmod"
}
[jar, sourcesJar].each {
it.from(rootProject.file("LICENSE")) {
rename { "${it}-${project.base.archivesName.get()}" }
}
}
if (file("src/client").exists() && !file("src/main").exists()) {
remapJar {
additionalClientOnlyEntries.add("LICENSE-${project.base.archivesName.get()}")
}
remapSourcesJar {
additionalClientOnlyEntries.add("LICENSE-${project.base.archivesName.get()}")
}
}
tasks.register('remapTestmodJar', RemapJarTask) {
dependsOn testmodJar
input = testmodJar.archiveFile
archiveClassifier = "testmod"
addNestedDependencies = false
includesClientOnlyClasses = true
clientOnlySourceSetName = sourceSets.testmodClient.name
}
build.dependsOn remapTestmodJar
tasks.register('validateMixinNames', ValidateMixinNameTask) {
source(sourceSets.main.output)
source(sourceSets.client.output)
}
}
remapTestmodJar {
def testModJarTasks = []
subprojects {
if (it.name == "common" || !(it.file("src/testmod").exists() || it.file("src/testmodClient").exists())) {
return
}
testModJarTasks += it.tasks.remapTestmodJar
}
nestedJars.setFrom(testModJarTasks)
addNestedDependencies = true
clientOnlySourceSetName = sourceSets.testmodClient.name
}
javadoc {
options {
source = "17"
encoding = "UTF-8"
charSet = "UTF-8"
memberLevel = JavadocMemberLevel.PACKAGE
links(
"https://maven.fabricmc.net/docs/yarn-${libs.versions.yarn.get()}/"
)
// Disable the crazy super-strict doclint tool in Java 8
addStringOption("Xdoclint:none", "-quiet")
tags(
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:'
)
}
allprojects.each {
source(it.sourceSets.main.allJava)
source(it.sourceSets.client.allJava)
}
classpath = files(sourceSets.main.compileClasspath, sourceSets.client.compileClasspath)
include("**/api/**")
failOnError true
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
from javadoc.destinationDir
//Set as `fatjavadoc` to prevent an ide form trying to use this javadoc, over using the modules javadoc
archiveClassifier = "fatjavadoc"
}
build.dependsOn javadocJar
// Format all the gradle files
spotless {
groovyGradle {
target 'src/**/*.gradle', '*.gradle', 'gradle/*.gradle'
greclipse()
}
}
def addPomMetadataInformation(Project project, MavenPom pom) {
def modJsonFile = project.file("src/main/resources/fabric.mod.json")
if (!modJsonFile.exists()) {
modJsonFile = project.file("src/client/resources/fabric.mod.json")
}
def modJson = new JsonSlurper().parse(modJsonFile)
pom.name = modJson.name
pom.url = "https://github.com/PhoMC/linen/tree/HEAD/${project.rootDir.relativePath(project.projectDir)}"
pom.description = modJson.description
pom.licenses {
license {
name = "Apache-2.0"
url = "https://github.com/PhoMC/linen/blob/HEAD/LICENSE"
}
}
pom.developers {
developer {
name = "PhoMC"
url = "https://phomc.dev/"
}
}
pom.scm {
connection = "scm:git:https://github.com/PhoMC/linen.git"
url = "https://github.com/PhoMC/linen"
developerConnection = "scm:git:git@github.com:PhoMC/linen.git"
}
pom.issueManagement {
system = "GitHub"
url = "https://github.com/PhoMC/linen/issues"
}
}
subprojects {
base {
archivesName = project.name
}
dependencies {
testmodImplementation sourceSets.main.output
}
publishing {
publications {
mavenJava(MavenPublication) {
pom {
addPomMetadataInformation(project, pom)
}
artifact(remapJar) {
builtBy remapJar
}
artifact(remapSourcesJar) {
builtBy remapSourcesJar
}
}
}
}
javadoc.enabled = false
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocJar
artifact remapTestmodJar
pom {
addPomMetadataInformation(rootProject, pom)
}
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
subprojects.each {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
}
}
}
}
subprojects.each {
remapJar.dependsOn("${it.path}:remapJar")
}
dependencies {
afterEvaluate {
subprojects.each {
if (it.name == "linen-common") {
return
}
api project(path: "${it.path}", configuration: "namedElements")
clientImplementation project("${it.path}:").sourceSets.client.output
testmodImplementation project("${it.path}:").sourceSets.testmod.output
testmodClientImplementation project("${it.path}:").sourceSets.testmodClient.output
}
}
}
remapJar {
afterEvaluate {
subprojects.each {
if (it.name == "linen-common") {
return
}
nestedJars.from project("${it.path}").tasks.getByName("remapJar")
}
}
}