3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-05 15:50:15 +01:00
ViaVersion/build-logic/src/main/kotlin/via.shadow-conventions.gradle.kts
Nassim Jahnke cb2165eb93
Greatly reduce the number of (anonymous) inner classes
Reduces code complexity, and much more importantly, reduces the number of classes loaded at runtime by *hundreds*
2023-02-12 11:46:48 +01:00

60 Zeilen
2.0 KiB
Plaintext

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.jvm.tasks.Jar
plugins {
id("via.base-conventions")
id("com.github.johnrengelman.shadow")
}
tasks {
named<Jar>("jar") {
archiveClassifier.set("unshaded")
from(project.rootProject.file("LICENSE"))
}
val shadowJar = named<ShadowJar>("shadowJar") {
archiveClassifier.set("")
configureRelocations()
configureExcludes()
}
named("build") {
dependsOn(shadowJar)
}
}
publishShadowJar()
fun ShadowJar.configureRelocations() {
relocate("com.google.gson", "com.viaversion.viaversion.libs.gson")
relocate("com.github.steveice10.opennbt", "com.viaversion.viaversion.libs.opennbt")
relocate("it.unimi.dsi.fastutil", "com.viaversion.viaversion.libs.fastutil")
relocate("space.vectrix.flare", "com.viaversion.viaversion.libs.flare")
}
fun ShadowJar.configureExcludes() {
// FastUtil - we only want object and int maps
// Object types
exclude("it/unimi/dsi/fastutil/*/*Reference*")
exclude("it/unimi/dsi/fastutil/*/*Boolean*")
exclude("it/unimi/dsi/fastutil/*/*Byte*")
exclude("it/unimi/dsi/fastutil/*/*Short*")
exclude("it/unimi/dsi/fastutil/*/*Float*")
exclude("it/unimi/dsi/fastutil/*/*Double*")
exclude("it/unimi/dsi/fastutil/*/*Long*")
exclude("it/unimi/dsi/fastutil/*/*Char*")
// Map types
exclude("it/unimi/dsi/fastutil/*/*Custom*")
exclude("it/unimi/dsi/fastutil/*/*Tree*")
exclude("it/unimi/dsi/fastutil/*/*Heap*")
exclude("it/unimi/dsi/fastutil/*/*Queue*")
// Crossing fingers
exclude("it/unimi/dsi/fastutil/*/*Big*")
exclude("it/unimi/dsi/fastutil/*/*Synchronized*")
exclude("it/unimi/dsi/fastutil/*/*Unmodifiable*")
exclude("it/unimi/dsi/fastutil/io/*")
// Flare - only need int maps
exclude("space/vectrix/flare/fastutil/*Double*")
exclude("space/vectrix/flare/fastutil/*Float*")
exclude("space/vectrix/flare/fastutil/*Long*")
exclude("space/vectrix/flare/fastutil/*Short*")
}