neoforge FINALLY works

This commit is contained in:
onebeastchris 2024-03-15 23:53:03 +01:00
parent b09a2808eb
commit e56b38ab90
3 changed files with 12 additions and 8 deletions

View File

@ -2,6 +2,10 @@ plugins {
application
}
// This is provided by "org.cloudburstmc.math.mutable" too, so yeet.
// NeoForge's class loader is *really* annoying.
provided("org.cloudburstmc.math", "api")
architectury {
platformSetupLoomIde()
neoForge()
@ -34,10 +38,6 @@ application {
}
tasks {
shadowJar {
relocate("it.unimi.dsi.fastutil", "org.geysermc.relocate.fastutil")
}
remapJar {
archiveBaseName.set("Geyser-NeoForge")
}

View File

@ -58,6 +58,10 @@ fun Project.platformRelocate(pattern: String, exclusion: String = "") {
val providedDependencies = mutableMapOf<String, MutableSet<String>>()
fun getProvidedDependenciesForProject(projectName: String): MutableSet<String> {
return providedDependencies.getOrDefault(projectName, emptySet()).toMutableSet()
}
fun Project.provided(pattern: String, name: String, excludedOn: Int = 0b110) {
providedDependencies.getOrPut(project.name) { mutableSetOf() }
.add("${calcExclusion(pattern, 0b100, excludedOn)}:${calcExclusion(name, 0b10, excludedOn)}")

View File

@ -81,22 +81,22 @@ tasks {
}
afterEvaluate {
val dependenciesSet = providedDependencies[project.name]
val dependenciesSet = getProvidedDependenciesForProject(project.name)
// We shadow e.g. geyser-core in. The resolved configuration however would JiJ core once more, leading to duplicates
// Hence: Remove the initially provided dependencies.
configurations["includeTransitive"].dependencies.forEach{ initDependency ->
dependenciesSet!!.add("${initDependency.group}:${initDependency.name}")
dependenciesSet.add("${initDependency.group}:${initDependency.name}")
}
// Now: Include all transitive dependencies that aren't excluded
configurations["includeTransitive"].resolvedConfiguration.resolvedArtifacts.forEach { dep ->
if (!dependenciesSet!!.contains("${dep.moduleVersion.id.group}:${dep.moduleVersion.id.name}")
if (!dependenciesSet.contains("${dep.moduleVersion.id.group}:${dep.moduleVersion.id.name}")
and !dependenciesSet.contains("${dep.moduleVersion.id.group}:*")) {
println("Including dependency via JiJ: ${dep.id}")
dependencies.add("include", dep.moduleVersion.id.toString())
} else {
println("Not including ${dep.id} as it is already provided on the ${project.name} platform!")
println("Not including ${dep.id}, already provided on ${project.name}!")
}
}
}