-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.gradle.kts
240 lines (205 loc) · 9.24 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
/*
* Copyright (c) 2024 ModCore Inc. All rights reserved.
*
* This code is part of ModCore Inc.'s Essential Mod repository and is protected
* under copyright registration # TX0009138511. For the full license, see:
* https://github.com/EssentialGG/Essential/blob/main/LICENSE
*
* You may not use, copy, reproduce, modify, sell, license, distribute,
* commercialize, or otherwise exploit, or create derivative works based
* upon, this file or any other in this repository, all of which is reserved by Essential.
*/
import essential.*
import gg.essential.gradle.util.*
import gg.essential.gradle.util.StripKotlinMetadataTransform.Companion.registerStripKotlinMetadataAttribute
plugins {
id("kotlin")
id("org.jetbrains.kotlin.plugin.serialization")
id("io.github.goooler.shadow")
id("gg.essential.defaults")
id("gg.essential.defaults.repo")
id("gg.essential.multi-version")
id("gg.essential.mixin")
id("gg.essential.bundle")
id("gg.essential.relocate")
id("essential.embedded-loader")
id("essential.pinned-jar")
}
val mcVersion: Int by project.extra
val mcVersionStr: String by project.extra
val mcPlatform: String by project.extra
repositories {
mavenLocal()
modMenu()
}
base.archivesName.set("Essential " + project.name)
val stripKotlinMetadata = registerStripKotlinMetadataAttribute("strip-kotlin-metadata")
dependencies {
implementation(bundle(project(":feature-flags"))!!)
implementation(bundle(project(":libs"))!!)
implementation(bundle(project(":infra"))!!)
implementation(bundle(project(":vigilance2"))!!)
implementation(bundle(project(":gui:elementa"))!!)
implementation(bundle(project(":gui:essential"))!!)
implementation(bundle(project(":gui:vigilance"))!!)
implementation(project(":api:" + project.name, configuration = "namedElements"))
bundle(project(":api:" + project.name))
implementation(bundle("com.github.KevinPriv:keventbus:c52e0a2") {
attributes { attribute(stripKotlinMetadata, true) }
})
implementation(bundle(project(":kdiscordipc"))!!)
implementation(bundle(project(":cosmetics", configuration = "minecraftRuntimeElements"))!!)
implementation(bundle(project(":lwjgl3"))!!)
runtimeOnly(bundle(project(":lwjgl3:impl"))!!)
// In order to get proper IDE support, we want to use a non-relocated MixinExtras version in dev.
// This gets transformed by `relocatedJar` to use our bundled relocated version for production.
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${libs.versions.mixinextras.get()}")!!)
listOf(configurations.implementation, configurations.annotationProcessor).forEach {
it.configure {
exclude(group = "gg.essential.lib", module = "mixinextras")
}
}
implementation(bundle("org.jitsi:ice4j:3.0-52-ga9ba80e") {
exclude(module = "kotlin-osgi-bundle")
exclude(module = "guava") // we use the one which comes with Minecraft (assuming that it is not too old)
exclude(module = "java-sdp-nist-bridge") // sdp is unnecessarily high-level for our use case
exclude(module = "jna") // comes with jitsi-utils but is not needed
})
// upgrade because the old one pulled in by ice4j got compiled by ancient kotlin and fails to remap
implementation(bundle("org.jitsi:jitsi-metaconfig:1.0-9-g5e1b624")!!)
// Some of our dependencies rely on slf4j but that's not included in MC prior to 1.17, so we'll manually bundle a
// log4j adapter for those versions
// We also bundle it for version 1.17-1.19.2 because those ship slf4j 1.x and only 1.19.3+ starts shipping 2.x
if (platform.mcVersion < 11903) {
implementation(bundle(project(":slf4j-to-log4j"))!!)
}
implementation(bundle(project(":quic-connector"))!!)
implementation(bundle(project(":clipboard"))!!)
implementation(bundle(project(":utils"))!!)
implementation(bundle(project(":plasmo"))!!)
if (platform.mcVersion >= 11800) {
implementation(bundle(project(":immediatelyfast"))!!)
}
testImplementation(kotlin("test"))
if (platform.isFabric && mcVersion >= 11600) {
val modMenuDependency = "com.terraformersmc:modmenu:${when {
platform.mcVersion >= 11800 -> "3.0.0"
platform.mcVersion <= 11700 -> "1.16.22"
else -> "2.0.14"
}}"
val modMenuInDev = mcVersion < 11802 // included fabric-screen-api-v1 is incompatible with 1.18.2
if (modMenuInDev) {
modImplementation(modMenuDependency)
} else {
modCompileOnly(modMenuDependency)
}
}
// Want to test with Optifine in your development environment?
// Set this to true, reload the Gradle project and add the Optifine jar into your mods folder.
// Bonus: Run with -Doptifabric.extract=true to get extracted and remapped OF classes/patches in `run/.optifine`.
val optifabricInDev = false
if (optifabricInDev) {
modImplementation("com.github.Chocohead:OptiFabric:e570a19") {
exclude(group = "net.fabricmc")
exclude(group = "net.fabricmc.fabric-api")
}
modImplementation("net.fabricmc.fabric-api:fabric-api:0.40.0+1.17")
}
if (platform.isFabric && platform.mcVersion >= 12006) {
val fapiVersion = when (platform.mcVersion) {
12006 -> "0.97.8+1.20.6"
12100 -> "0.99.2+1.21"
12102 -> "0.106.0+1.21.2"
12104 -> "0.110.0+1.21.4"
else -> error("No fabric API version configured!")
}
include(modImplementation(fabricApi.module("fabric-api-base", fapiVersion))!!)
include(modImplementation(fabricApi.module("fabric-networking-api-v1", fapiVersion))!!)
}
constraints {
val kotlin = KotlinVersion.minimal
val reason: DependencyConstraint.() -> Unit = {
because("this is the most recent version supported by all platforms")
}
for (name in listOf("stdlib", "stdlib-common", "stdlib-jdk7", "stdlib-jdk8")) {
implementation("org.jetbrains.kotlin:kotlin-$name:${kotlin.stdlib}!!", reason)
}
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlin.stdlib}!!", reason)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${kotlin.coroutines}!!", reason)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${kotlin.coroutines}!!", reason)
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:${kotlin.serialization}!!", reason)
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${kotlin.serialization}!!", reason)
}
}
if (platform.isFabric) {
// Compile against the oldest fabric-loader version we support, so we don't accidentially use APIs available
// only in newer versions
configurations.compileClasspath {
resolutionStrategy.force("net.fabricmc:fabric-loader:0.11.0")
}
}
tasks.jar {
manifest {
attributes(
"ModSide" to "CLIENT",
"FMLCorePluginContainsFMLMod" to "Yes, yes it does",
"Main-Class" to "gg.essential.main.Main",
)
}
if (!platform.isFabric) {
manifest {
if (mcVersion >= 11400) {
attributes("MixinConfigs" to "mixins.essential.json,mixins.essential.init.json,mixins.essential.modcompat.json,mixins.essential.tests.json")
attributes("Requires-Essential-Stage2-Version" to "1.6.0")
}
}
}
}
// For legacy Forge, we need to use a custom tweaker to get mixin bootstrapped
if (platform.isLegacyForge) {
loom.runs.named("client") {
programArgs("--tweakClass", "gg.essential.dev.DevelopmentTweaker")
}
}
// Essential is a client-side only mod
loom.noServerRunConfigs()
// Enable dev-only feature flag
loom.runs.named("client") {
property("essential.feature.dev_only", "true")
}
// We need to use the compatibility mode on old versions because we used to use the old Kotlin defaults for those, and
// we need to match the API to be able to override its methods.
tasks.compileKotlin.setJvmDefault(if (platform.mcVersion >= 11400) "all" else "all-compatibility")
tasks.relocatedJar {
//Discord
relocate("dev.cbyrne.kdiscordipc", "gg.essential.lib.kdiscordipc")
// MojangAPI & keventbus
relocate("me.kbrewster", "gg.essential.lib.kbrewster")
relocate("okhttp3", "gg.essential.lib.okhttp3")
relocate("okio", "gg.essential.lib.okio")
// ice4j
relocate("org.ice4j", "gg.essential.lib.ice4j")
relocate("org.jitsi", "gg.essential.lib.jitsi")
relocate("com.typesafe.config", "gg.essential.lib.typesafeconfig")
relocate("org.json.simple", "gg.essential.lib.jsonsimple")
relocate("org.bitlet.weupnp", "gg.essential.lib.weupnp")
// connection-manager
relocate("org.java_websocket", "gg.essential.lib.websocket")
// cosmetics
relocate("dev.folomeev.kotgl", "gg.essential.lib.kotgl")
if (mcVersion < 11903) {
// Slf4j
relocate("org.slf4j", "gg.essential.lib.slf4j")
}
// MixinExtras
relocate("com.llamalad7.mixinextras", "gg.essential.lib.mixinextras")
}
tasks.processResources {
inputs.property("project_version", project.version)
filesMatching("assets/essential/version.txt") {
expand(mapOf("version" to project.version))
}
}
tasks.test {
useJUnitPlatform()
}