This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
219 lines (189 loc) · 6.6 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
plugins {
id("dev.architectury.loom") version "1.6-SNAPSHOT"
id("com.github.johnrengelman.shadow")
id("io.github.null2264.preprocess")
id("me.modmuss50.mod-publish-plugin") version "0.3.5"
}
def _env = System.getenv()
archivesBaseName = project.archives_base_name
def isForge = project.name.endsWith("forge")
def isNeo = project.name.endsWith("neoforge")
def isFabric = project.name.endsWith("fabric")
def mcVersion
def (major, minor, patch) = project.name.tokenize('-')[0].tokenize('.')
mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}" as int
static String stringifyVersion(int ver) {
return "${(int)(ver/10000)}.${(int)(ver/100)%100}" + (ver%100==0 ? '' : ".${ver%100}")
}
def mcVersionStr = stringifyVersion(mcVersion)
// TODO(addingVersion)
def supportedVersionRange = [
11800: ["1.18-", "1.20.1"],
12002: ["1.20.2-", "1.20.4"],
12005: ["1.20.5-", null]
][mcVersion]
def buildNumber = _env["GITHUB_RUN_NUMBER"]
version = project.mod_version + "+${mcVersionStr}" + (buildNumber != null ? "b${buildNumber}" : "") + "-BETA" + (isFabric ? "-fabric" : (isNeo ? "-neoforge" : "-forge"))
group = project.maven_group
repositories {
maven { url = "https://maven.neoforged.net/releases" }
}
preprocess {
vars.put("MC", mcVersion)
vars.put("FABRIC", isFabric ? 1 : 0)
vars.put("FORGE", isForge ? 1 + (isNeo ? 1 : 0) : 0)
}
loom {
silentMojangMappingsLicense()
runConfigs.configure {
client {
runDir = "../../run/client"
ideConfigGenerated = true
}
server {
runDir = "../../run/server"
ideConfigGenerated = true
}
}
if (isForge && !isNeo)
forge {
mixinConfigs = ["libreexpfix.mixins.json"]
}
}
configurations {
shade
modImplementation.extendsFrom(shade)
}
dependencies {
// TODO(addingVersion): If needed
def mc = [
11800: "1.18.2",
]
minecraft("com.mojang:minecraft:${mc[mcVersion] ?: mcVersionStr}")
mappings loom.officialMojangMappings()
if (isFabric)
modImplementation("net.fabricmc:fabric-loader:0.15.10")
else {
// TODO(addingVersion)
if (!isNeo) {
forge("net.minecraftforge:forge:" + [
11800: "1.18.2-40.2.9",
12002: "1.20.2-48.0.13",
][mcVersion])
} else {
neoForge("net.neoforged:neoforge:" + [
12002: "20.2.51-beta",
12005: "20.5.0-beta",
][mcVersion])
}
}
}
shadowJar {
zip64 true
if (isFabric) {
exclude("META-INF/mods.toml")
exclude("META-INF/neoforge.mods.toml")
} else if (isForge) {
exclude("fabric.mod.json")
exclude((isNeo && mcVersion >= 12005) ? "META-INF/mods.toml" : "META-INF/neoforge.mods.toml")
}
exclude("architectury.common.json")
configurations = [project.configurations.shade]
archiveClassifier.set("dev-shade")
}
artifacts {
archives(shadowJar)
}
remapJar {
dependsOn(shadowJar)
inputFile.set(shadowJar.archiveFile)
}
tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
def metadataVersion = project.mod_version + (buildNumber != null ? "b${buildNumber}" : "") + "-BETA"
def metadataMCVersion =
supportedVersionRange[0] != null ? (
(isFabric ? ">=" : "[") +
supportedVersionRange[0] +
(supportedVersionRange[1] == null
? (isFabric ? "" : ",)")
: ((isFabric ? " <=" : ",") + supportedVersionRange[1] + (isFabric ? "" : "]")))
) : (isFabric ? supportedVersionRange[1] : "[${supportedVersionRange[1]}]")
inputs.property "version", metadataVersion
inputs.property "mcversion", metadataMCVersion
filteringCharset "UTF-8"
def metadataFilename = ""
if (isFabric) {
metadataFilename = "fabric.mod.json"
} else if (isForge) {
metadataFilename = (isNeo && mcVersion >= 12005) ? "META-INF/neoforge.mods.toml" : "META-INF/mods.toml"
}
filesMatching(metadataFilename) {
expand "version": metadataVersion, "mcversion": metadataMCVersion, "forge": (isNeo ? "neoforge" : "forge")
}
}
def targetJavaVersion = (mcVersion >= 12005) ? 21 : (mcVersion >= 11700 ? 17 : 8)
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
}
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() != javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project["archivesBaseName"]}" }
}
}
// TODO(addingVersion)
def mcReleaseVersions = [
11800: ["1.18", "1.18.1", "1.18.2", "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1"],
12002: ["1.20.2", "1.20.3", "1.20.4"],
12005: ["1.20.5"],
][mcVersion]
def cfSnapshots = [
][mcVersion]
def mrSnapshots = [
][mcVersion]
publishMods {
file = remapJar.archiveFile
displayName = "[${isFabric ? "FABRIC" : (isNeo ? "NEOFORGE" : "FORGE")} MC${mcReleaseVersions[0] + (mcReleaseVersions.size() > 1 ? "+" : "")}] v${project.mod_version}-BETA"
changelog = _env["CHANGELOG"] ?: "The changelog can be found at https://github.com/null2264/LibreExpFix/commits/"
version = project.version as String
if (isFabric) {
modLoaders.add("fabric")
modLoaders.add("quilt")
} else {
if (mcVersion <= 12002 && !isNeo) // No more LexForge, LexForge is too buggy
modLoaders.add("forge")
if (mcVersion < 12002 || isNeo)
modLoaders.add("neoforge")
}
type = BETA
def cToken = _env["CURSEFORGE"]
if (cToken != null)
curseforge {
accessToken = cToken
projectId = project["curseforge_project"]
def mcVersions = cfSnapshots == null ? mcReleaseVersions : cfSnapshots
for (final def mcVer in mcVersions) {
minecraftVersions.add(mcVer)
}
}
def mToken = _env["MODRINTH"]
if (mToken != null)
modrinth {
accessToken = mToken
projectId = project["modrinth_project"]
def mcVersions = mrSnapshots == null ? mcReleaseVersions : mrSnapshots
for (final def mcVer in mcVersions) {
minecraftVersions.add(mcVer)
}
}
}