-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
258 lines (227 loc) · 6.89 KB
/
build.gradle
File metadata and controls
258 lines (227 loc) · 6.89 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
import com.mmodding.gradle.api.EnvironmentTarget
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 apply false
alias libs.plugins.mmodding.gradle apply false
}
version = "$project.version+${libs.versions.minecraft.get()}"
group = project.maven_group
subprojects {
group = project.module_maven_group
}
def included_integrations = allowed_integrations.split(",")
static def getMModdingLibraryNamespace(Project project) {
return project.rootProject == project ? "mmodding" : 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) + " "
}
}
if (!projectName.contains("Mod Integration")) {
return projectName + "Library"
}
else {
return projectName.substring(0, projectName.length() - 1)
}
}
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("_", "-"))
}
if (!projectId.contains("mod_integration")) {
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 {
apply plugin: 'net.fabricmc.fabric-loom'
apply plugin: 'com.mmodding.gradle'
base {
if (project == rootProject) {
archivesName = project.archives_base_name
}
else {
archivesName = getMModdingLibraryNamespace(project)
}
}
repositories {
mavenCentral()
}
// 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
implementation libs.fabric.loader
implementation libs.yumi.commons
implementation libs.fabric.api
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
// Minecraft 26.1 upwards uses Java 25.
it.options.release = Integer.valueOf(libs.versions.java.get())
}
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"
environment = EnvironmentTarget.ANY
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")
}
}
}
}
loomModRegistration()
loomTestmodRegistration()
configureTestmod {
name = getMModdingLibraryName(project) + " Test Mod"
namespace = getMModdingLibraryNamespace(project) + "_testmod"
withDependencies {
it.addDependency(getMModdingLibraryNamespace(project))
}
}
}
processResources {
inputs.properties 'version': version
filesMatching('fabric.mod.json') {
expand 'version': version
}
}
java {
// Still required by IDEs such as Eclipse and Visual Studio Code
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
withSourcesJar()
// withJavadocJar()
}
}
subprojects {
afterEvaluate {
// Disable the gen sources task on sub projects
genSourcesWithVineflower.enabled = false
genSourcesWithCfr.enabled = false
}
}
allprojects {
jar {
from(rootProject.projectDir.path + "/LICENSE.md") {
rename { "${it}_${base.archivesName.get()}" }
}
}
}
mmodding {
modules {
bundle("mmodding-block")
bundle("mmodding-config")
bundle("mmodding-core")
bundle("mmodding-datagen")
bundle("mmodding-enchantment")
bundle("mmodding-fluid")
bundle("mmodding-inventory")
bundle("mmodding-item")
bundle("mmodding-java")
bundle("mmodding-math")
bundle("mmodding-network")
bundle("mmodding-rendering")
bundle("mmodding-woodset")
bundle("mmodding-worldgen")
rootDir.toPath().resolve("mod-integration").toFile().list().each {
if (included_integrations.contains(it)) {
include("mod-integration-mmodding-" + it) // we don't need to depend on it for the root project
}
}
}
}
dependencies {
api(include(libs.yumi.commons.core.get()))
api(include(libs.yumi.commons.collections.get()))
api(include(libs.yumi.commons.event.get()))
}
// Javadocs
/* javadoc {
options {
source = "17"
encoding = "UTF-8"
charSet = "UTF-8"
memberLevel = JavadocMemberLevel.PACKAGE
addStringOption("Xdoclint:none", "-quiet")
tags(
'apiNote:a:API Note:',
'implNote:a:Implementation Note:'
)
}
allprojects.each {
source(sourceSets.main.allJava)
}
classpath = files(sourceSets.main.compileClasspath)
include("**//*api*//**")
failOnError = true
} */
// Configure the maven publication
allprojects {
if (!project.name.contains("mod-integration")) {
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.
}
}
}
}
}