-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
288 lines (251 loc) · 7.48 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
import com.mmodding.gradle.api.mod.json.NamespaceProvider;
import com.mmodding.gradle.api.mod.json.ParentSchema;
plugins {
id 'maven-publish'
alias libs.plugins.fabric.loom
alias libs.plugins.mmodding.gradle
}
base {
archivesName = project.archives_base_name
}
version = "$project.version+${libs.versions.minecraft.get()}"
group = project.maven_group
static def getMModdingLibraryNamespace(Project project) {
return project.name.replace("-", "_")
}
static def getMModdingLibraryName(Project project) {
String projectName = ""
getMModdingLibraryNamespace(project).split("_").each {
if (it[0] == "m" && it[1] == "m") {
projectName = projectName + it[0].toUpperCase() + it[1].toUpperCase() + it.substring(2) + " "
}
else {
projectName = projectName + it[0].toUpperCase() + it.substring(1) + " "
}
}
return projectName + "Library"
}
static def getMModdingLibraryDescription(Project project) {
if (getMModdingLibraryNamespace(project) == "mmodding") {
return "Library made by MModding Team to provide few sets of modding tools."
}
else {
return getMModdingLibraryName(project) - "MModding " + " of MModding"
}
}
static def applyMModdingLibraryProvider(Project project, NamespaceProvider provider) {
String projectId = getMModdingLibraryNamespace(project);
if (projectId != "mmodding") {
provider.provide(projectId.replace("_", "-"))
}
provider.provide(projectId + "_library")
provider.provide(projectId.replace("_", "-") + "-library")
provider.provide(projectId + "_api")
provider.provide(projectId.replace("_", "-") + "-api")
}
static def applyYumiCommonsParent(ParentSchema parent) {
parent.name = "Yumi Commons"
parent.description = "A library containing common utilities."
parent.addBadge("library")
}
allprojects {
processResources {
inputs.properties 'version': version
filesMatching('fabric.mod.json') {
expand 'version': version
}
}
}
allprojects {
apply plugin: 'fabric-loom'
apply plugin: 'com.mmodding.gradle'
repositories {
maven {
name "QuiltMC"
url "https://maven.quiltmc.org/repository/release"
}
maven {
name "ParchmentMC"
url "https://maven.parchmentmc.org"
}
}
// All the dependencies are declared at gradle/libs.version.toml and referenced with "libs.<id>"
// See https://docs.gradle.org/current/userguide/platforms.html for information on how version catalogs work.
dependencies {
minecraft libs.minecraft
mappings variantOf(libs.quilt.mappings) { classifier "intermediary-v2" }
modImplementation libs.fabric.loader
modImplementation libs.yumi.commons
modImplementation libs.fabric.api
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
mmodding {
configureFabricModJson {
name = getMModdingLibraryName(project)
namespace = getMModdingLibraryNamespace(project)
description = getMModdingLibraryDescription(project)
license = "Code: PolyForm-Shield-1.0.0\\nAssets: All Rights Reserved"
icon = "assets/" + getMModdingLibraryNamespace(project) + "/icon.png"
addAuthor("MModding Team")
addContributor("FirstMegaGame4")
withContact {
it.homepage = "https://mmodding.com"
it.sources = "https://github.com/MModding/mmodding-library"
it.issues = "https://github.com/MModding/mmodding-library/issues"
}
withDependencies {
it.javaVersion = ">=" + 17
it.minecraftVersion = "~" + libs.versions.minecraft.get()
it.fabricLoaderVersion = ">=" + libs.versions.fabric.loader.get()
it.fabricApiVersion = ">=" + libs.versions.fabric.api.get()
}
withProvider {
applyMModdingLibraryProvider(project, it)
}
if (getMModdingLibraryNamespace(project) != "mmodding") withParent("mmodding")
withCustom {
it.withBlock("modmenu") {
it.withArray("badges") {
it.addUnique("library")
}
}
}
}
}
java {
// Still required by IDEs such as Eclipse and Visual Studio Code
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar()
withJavadocJar()
}
}
subprojects {
afterEvaluate {
// Disable the gen sources task on sub projects
genSourcesWithVineflower.enabled = false
genSourcesWithFernFlower.enabled = false
genSourcesWithCfr.enabled = false
}
}
// If you plan to use a different file for the license, don't forget to change the file name here!
jar {
from('LICENSE.md') {
rename { "${it}_${base.archivesName.get()}" }
}
}
mmodding {
modules(project) {
it.include {
it.api("mmodding-block")
it.api("mmodding-block-entity")
it.api("mmodding-config")
it.api("mmodding-core")
it.api("mmodding-datagen")
it.api("mmodding-fluid")
it.api("mmodding-item")
it.api("mmodding-java")
it.api("mmodding-math")
it.api("mmodding-network")
it.api("mmodding-worldgen")
}
}
}
dependencies {
mmodding.configureFMJForDependency(include(libs.yumi.commons.core.get())) {
name = "Yumi Commons: Core"
namespace = "yumi-commons-core"
withContact {
it.email = "[email protected]"
}
addAuthor("LambdAurora") {
withContact {
it.email = "[email protected]"
}
}
withParent("yumi-commons") {
applyYumiCommonsParent(it)
}
}
mmodding.configureFMJForDependency(include(libs.yumi.commons.collections.get())) {
name = "Yumi Commons: Collections"
namespace = "yumi-commons-collections"
withContact {
it.email = "[email protected]"
}
addAuthor("LambdAurora") {
withContact {
it.email = "[email protected]"
}
}
withParent("yumi-commons") {
applyYumiCommonsParent(it)
}
}
mmodding.configureFMJForDependency(include(libs.yumi.commons.event.get())) {
name = "Yumi Commons: Event"
namespace = "yumi-commons-event"
withContact {
it.email = "[email protected]"
}
addAuthor("LambdAurora") {
withContact {
it.email = "[email protected]"
}
}
withParent("yumi-commons") {
applyYumiCommonsParent(it)
}
}
include libs.quilt.parsers.json
}
// Loom can detect content of generated FMJs thanks to that block code.
afterEvaluate {
project.subprojects.each {
project.sourceSets.main.compileClasspath += it.sourceSets.main.compileClasspath
project.sourceSets.main.runtimeClasspath += it.sourceSets.main.runtimeClasspath
}
}
// Javadocs
allprojects {
javadoc {
options {
it.source = "17"
it.encoding = "UTF-8"
it.charSet = "UTF-8"
it.memberLevel = JavadocMemberLevel.PACKAGE
it.tags("apiNote:a:API Note:", "implNote:a:Implementation Note:")
it.addStringOption('Xdoclint:none', '-quiet')
}
allprojects.each {
source(it.sourceSets.main.allJava)
files(it.sourceSets.main.compileClasspath)
}
include("**/api/**")
// failOnError true => seems to have class load issues that prevents javadocs from working well with this, needs investigation in the future
}
}
// Configure the maven publication
allprojects {
apply plugin: 'maven-publish'
afterEvaluate {
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
}