forked from FiniteReality/embeddium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
291 lines (239 loc) · 7.74 KB
/
build.gradle.kts
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
plugins {
id("idea")
id("net.neoforged.gradle") version("6.0.21")
id("maven-publish")
id("org.spongepowered.mixin") version("0.7.38")
// This dependency is only used to determine the state of the Git working tree so that build artifacts can be
// more easily identified. TODO: Lazily load GrGit via a service only when builds are performed.
id("org.ajoberstar.grgit") version("5.0.0")
id("me.modmuss50.mod-publish-plugin") version("0.3.4")
id("org.parchmentmc.librarian.forgegradle") version("1.2.0.7-dev-SNAPSHOT")
}
operator fun String.invoke(): String {
return (rootProject.properties[this] as String?)!!
}
tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_17.majorVersion
targetCompatibility = JavaVersion.VERSION_17.majorVersion
options.encoding = "UTF-8"
}
version = getModVersion()
group = "maven_group"()
println("Embeddium: $version")
base {
archivesName = "archives_base_name"()
}
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
// java.toolchain.languageVersion = JavaLanguageVersion.of(17)
sourceSets {
val main = getByName("main")
val api = create("api")
val legacy = create("legacy")
val compat = create("compat")
api.apply {
java {
compileClasspath += main.compileClasspath
}
}
main.apply {
java {
compileClasspath += api.output
runtimeClasspath += api.output
}
}
legacy.apply {
java {
compileClasspath += main.compileClasspath
compileClasspath += main.output
}
}
compat.apply {
java {
compileClasspath += main.compileClasspath
compileClasspath += main.output
}
}
}
repositories {
maven("https://maven.minecraftforge.net/")
maven("https://maven.fabricmc.net")
maven("https://maven.tterrag.com/")
maven("https://maven.blamejared.com")
maven("https://api.modrinth.com/maven") {
content {
includeGroup("maven.modrinth")
}
}
maven("https://cursemaven.com") {
content {
includeGroup("curse.maven")
}
}
maven("https://maven.covers1624.net/")
}
jarJar.enable()
minecraft {
if(rootProject.properties.containsKey("parchment_version")) {
mappings("parchment", "parchment_version"())
} else {
mappings("official", "minecraft_version"())
}
copyIdeResources = true
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs {
configureEach {
workingDirectory(project.file("run"))
property("forge.logging.console.level", "info")
property("mixin.env.remapRefMap", "true")
property("mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg")
mods {
create("embeddium") {
sources(sourceSets["main"])
sources(sourceSets["compat"])
sources(sourceSets["api"])
sources(sourceSets["legacy"])
}
}
}
create("client") {}
}
}
configurations {
val runtimeOnlyNonPublishable = create("runtimeOnlyNonPublishable") {
description = "Runtime only dependencies that are not published alongside the jar"
isCanBeConsumed = false
isCanBeResolved = false
}
runtimeClasspath.get().extendsFrom(runtimeOnlyNonPublishable)
}
val extraModsDir = "extra-mods-${"minecraft_version"()}"
repositories {
flatDir {
name = "extra-mods"
dirs(file(extraModsDir))
}
}
mixin {
// MixinGradle Settings
add(sourceSets["main"], "embeddium-refmap.json")
config("embeddium.mixins.json")
}
fun DependencyHandlerScope.compatCompileOnly(dependency: Dependency) {
"compatCompileOnly"(dependency)
}
// Force LWJGL 3.3.3 for Java 21 compat
configurations.all {
resolutionStrategy {
eachDependency {
when (requested.group.toString()) {
"org.lwjgl" -> useVersion("3.3.3")
}
}
}
}
dependencies {
minecraft("net.neoforged:forge:${"minecraft_version"()}-${"forge_version"()}")
// Mods
compatCompileOnly(fg.deobf("curse.maven:codechickenlib-242818:${"codechicken_fileid"()}"))
compatCompileOnly(fg.deobf("curse.maven:immersiveengineering-231951:${"ie_fileid"()}"))
annotationProcessor("net.fabricmc:sponge-mixin:0.12.5+mixin.0.8.5")
compileOnly("io.github.llamalad7:mixinextras-common:0.3.5")
annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5")
implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.3.5")) {
jarJar.ranged(this, "[0.3.5,)")
}
// runtime remapping at home
fileTree(extraModsDir) {
include("*.jar")
}.files.forEach { extraModJar ->
val basename = extraModJar.name.substring(0, extraModJar.name.length - ".jar".length)
val versionSep = basename.lastIndexOf('-')
assert(versionSep != -1)
val artifactId = basename.substring(0, versionSep)
val version = basename.substring(versionSep + 1)
runtimeOnly(fg.deobf("extra-mods:$artifactId:$version"))
}
}
tasks.processResources {
inputs.property("version", "version"())
filesMatching("META-INF/mods.toml") {
expand("version" to "version"())
}
}
tasks.withType<JavaCompile> {
options.release = 17
}
java {
withSourcesJar()
}
tasks.jarJar {
from("COPYING", "COPYING.LESSER", "README.md")
from(sourceSets["compat"].output.classesDirs)
from(sourceSets["compat"].output.resourcesDir)
from(sourceSets["api"].output.classesDirs)
from(sourceSets["api"].output.resourcesDir)
from(sourceSets["legacy"].output.classesDirs)
from(sourceSets["legacy"].output.resourcesDir)
finalizedBy("reobfJarJar")
}
tasks.named<Jar>("sourcesJar").configure {
from(sourceSets["compat"].allJava)
from(sourceSets["api"].allJava)
from(sourceSets["legacy"].allJava)
}
publishing {
tasks.publish {
dependsOn(tasks.build)
}
publications {
this.create<MavenPublication>("mavenJava") {
artifact(tasks.jar)
artifact(tasks.named("sourcesJar"))
}
}
repositories {
maven("file://${System.getenv("local_maven")}")
}
}
publishMods {
file = tasks.jarJar.get().archiveFile
changelog = "https://github.com/embeddedt/embeddium/wiki/Changelog"
type = STABLE
modLoaders.add("forge")
modLoaders.add("neoforge")
curseforge {
projectId = "908741"
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
minecraftVersions.add("minecraft_version"())
incompatible {
slug = "rubidium"
}
}
modrinth {
projectId = "sk9rgfiA"
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
minecraftVersions.add("minecraft_version"())
incompatible {
slug = "rubidium"
}
}
displayName = "[${"minecraft_version"()}] Embeddium ${"mod_version"()}"
}
fun getModVersion(): String {
var baseVersion: String = project.properties["mod_version"].toString()
val mcMetadata: String = "+mc" + project.properties["minecraft_version"]
if (project.hasProperty("build.release")) {
return baseVersion + mcMetadata // no tag whatsoever
}
// Increment patch version
baseVersion = baseVersion.split(".").mapIndexed {
index, s -> if(index == 2) (s.toInt() + 1) else s
}.joinToString(separator = ".")
val head = grgit.head()
var id = head.abbreviatedId
// Flag the build if the build tree is not clean
if (!grgit.status().isClean) {
id += "-dirty"
}
return baseVersion + "-git-${id}" + mcMetadata
}