-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommon.gradle
402 lines (337 loc) · 12.3 KB
/
common.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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
buildscript {
dependencies {
classpath 'org.kohsuke:github-api:1.114'
}
repositories {
gradlePluginPortal()
}
}
version = project.mod_version
group = project.maven_group
def local_wunderlib = findProject(':wunderlib') != null
allprojects { projIt ->
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'fabric-loom'
repositories {
maven { url "https://maven.dblsaiko.net/" }
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.shedaniel.me/" }
maven { url 'https://maven.blamejared.com' }
maven { url 'https://jitpack.io' }
maven { url 'https://maven.terraformersmc.com/releases' }
maven { url 'https://maven.terraformersmc.com' }
maven { url 'https://maven.ambertation.de/releases' }
}
version = rootProject.mod_version
group = rootProject.maven_group
java {
// Must be added before the split source sets are setup.
withSourcesJar()
}
sourceSets {
main {
resources {
srcDirs += [
'src/main/generated'
]
}
java {
srcDirs += ['src/client/java', 'src/datagen/java']
}
}
testmod {
resources {
srcDirs += [
'src/testmod/generated'
]
}
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
testmodClient {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += testmod.compileClasspath
runtimeClasspath += testmod.runtimeClasspath
}
testmodDatagen {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += testmod.compileClasspath
runtimeClasspath += testmod.runtimeClasspath
compileClasspath += testmodClient.compileClasspath
runtimeClasspath += testmodClient.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"
runDir "run-server"
source sourceSets.testmod
}
if (project.rootProject != project) {
println "${projIt.name}-testmod"
if (projIt.file('src/testmod').exists()) {
"${projIt.name}-testmod" {
server()
runDir "run-server"
name = "Testmod - ${projIt.name}"
ideConfigGenerated true
//source sourceSets["${projIt.name}-testmod"]
source sourceSets.testmod
}
}
if (projIt.file('src/testmodClient').exists()) {
"${projIt.name}-testmodClient" {
client()
runDir "run"
name = "Testmod Client - ${projIt.name}"
ideConfigGenerated true
//source sourceSets["${projIt.name}-testmodClient"]
source sourceSets.testmodClient
}
}
if (projIt.file('src/testmodDatagen').exists()) {
def modId = projIt.name.replace('-api', '-testmod');
"${projIt.name}-testmodDatagen" {
client()
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/testmod/generated")}"
vmArg "-Dfabric-api.datagen.modid=${modId}"
runDir "build/datagenTestmod"
name = "Testmod DataGen - ${projIt.name}"
ideConfigGenerated true
source sourceSets.testmodDatagen
}
}
if (projIt.file('src/datagen').exists()) {
def modId = projIt.name.replace('-api', '');
println("Mod ID: ${modId}")
"${projIt.name}-datagen" {
client()
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}"
vmArg "-Dfabric-api.datagen.modid=${modId}"
runDir "build/datagen"
name = "DataGen - ${projIt.name}"
ideConfigGenerated true
}
}
}
}
}
configurations {
dev {
transitive true
canBeResolved = true
canBeConsumed = true
extendsFrom api
}
localDev {
extendsFrom dev
}
}
dependencies {
println("Adding dependencies for ${projIt.name}")
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
dev sourceSets.main.output
testmodImplementation sourceSets.main.output
testmodClientImplementation sourceSets.main.output
testmodClientImplementation sourceSets.testmod.output
testmodDatagenImplementation sourceSets.main.output
testmodDatagenImplementation sourceSets.testmod.output
testmodDatagenImplementation sourceSets.testmodClient.output
if (projIt.name != "wunderlib") {
if (local_wunderlib) {
implementation project(path: ":wunderlib", configuration: 'dev')
} else {
modApi "de.ambertation:wunderlib:${project.wunderlib_version}"
}
}
}
processResources {
println "Version: ${project.mod_version}"
inputs.property "version", project.mod_version
filesMatching("fabric.mod.json") {
expand "version": project.mod_version
}
}
// 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"
it.options.release = 21
}
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
// Run this task after updating minecraft to regenerate any required resources
tasks.register('generateResources') {
group = "fabric"
}
tasks.register('testmodJar', Jar) {
from sourceSets.testmod.output
from sourceSets.testmodClient.output
from sourceSets.testmodDatagen.output
destinationDirectory = new File(project.buildDir, "devlibs")
archiveClassifier = "testmod"
}
[jar, sourcesJar].each {
it.from(rootProject.file("LICENSE")) {
rename { "${it}-${project.base.archivesName.get()}" }
}
}
}
allprojects.each { p ->
loom.mods.register(p.name) {
sourceSet p.sourceSets.main
}
loom.mods.register(p.name + "-testmod") {
sourceSet p.sourceSets.testmod
sourceSet p.sourceSets.testmodClient
sourceSet p.sourceSets.testmodDatagen
}
}
subprojects.each {
remapJar.dependsOn("${it.path}:remapJar")
}
tasks.sourcesJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
//dependencies for the main Libraray
dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
subprojects.each {
api project(path: "${it.path}", configuration: "namedElements")
// testmodImplementation project("${it.path}").sourceSets.testmod.output
// testmodClientImplementation project("${it.path}").sourceSets.testmodClient.output
// testmodClientImplementation project("${it.path}").sourceSets.client.output
//
// testmodDatagenImplementation project("${it.path}").sourceSets.testmodDatagen.output
include project("${it.path}")
}
modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
modLocalRuntime "com.terraformersmc:modmenu:${project.modmenu_version}"
if (local_wunderlib) {
implementation project(path: ":wunderlib", configuration: 'dev')
include project(path: ":wunderlib")
} else {
modApi "de.ambertation:wunderlib:${project.wunderlib_version}"
include "de.ambertation:wunderlib:${project.wunderlib_version}"
}
}
loom {
runs {
datagen {
inherit client
name "Data Generation"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}"
vmArg "-Dfabric-api.datagen.modid=${project.archives_base_name}"
runDir "build/datagen"
}
}
subprojects.each { sub ->
//println "${sub.loom.accessWidenerPath.text}"
try {
} catch (e) {
println "No access widener for ${sub.name}"
}
}
accessWidenerPath = file("src/main/resources/wover.accesswidener")
enableTransitiveAccessWideners = true
}
task copyHighlightJs(type: Copy) {
from 'javadoc/contrib' // Path to the local folder containing Highlight.js
into "$buildDir/docs/javadoc/contrib" // Specify the destination folder in the generated Javadoc
}
javadoc {
options {
source = "17"
encoding = "UTF-8"
charSet = "UTF-8"
memberLevel = JavadocMemberLevel.PROTECTED
links("https://docs.oracle.com/en/java/javase/17/docs/api/")
// Disable the crazy super-strict doclint tool in Java 8
addStringOption("Xdoclint:none", "-quiet")
addStringOption("noqualifier", "net.minecraft.*:com.mojang.*:net.fabricmc.*")
addBooleanOption("-allow-script-in-comments", true)
tags(
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:'
)
header = "<script type=\"text/javascript\" src=\"../../../../../contrib/highlight/highlight.min.js\"></script>" +
" <link rel=\"stylesheet\" href=\"../../../../../contrib/highlight/styles/default.min.css\"></link>" +
" <script>window.onload = function () {\n" +
" var allPre, i, j;\n" +
" allPre = document.getElementsByTagName(\"pre\");\n" +
" console.log(allPre); \n" +
" for (i = 0, j = allPre.length; i < j; i++) {\n" +
" hljs.highlightElement(allPre[i]);\n" +
" }\n" +
"};</script>"
stylesheetFile = file("javadoc/wover.css")
}
allprojects.each {
source(it.sourceSets.main.allJava)
}
classpath = files(sourceSets.main.compileClasspath, sourceSets.main.runtimeClasspath)
include("**/api/**")
include("de/ambertation/**")
include("org/betterx/wover/util/**")
failOnError true
finalizedBy copyHighlightJs
}
jar {
from "LICENSE"
}
configurations {
dev {
canBeConsumed true
canBeResolved true
}
localDev {
extendsFrom dev
}
}
task javadocJar(type: Jar, dependsOn: [javadoc, copyHighlightJs]) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
dev remapJar
localDev jar
archives sourcesJar
archives javadocJar
}
idea {
module {
excludeDirs += file('javadoc')
excludeDirs += file('gradle')
excludeDirs += file('public')
excludeDirs += file('tools')
excludeDirs += file('bin')
subprojects.each {
excludeDirs += it.file('run')
excludeDirs += it.file('run-server')
}
}
}