-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up dependency handling for new backend
- Loading branch information
Showing
13 changed files
with
186 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://repo.polyfrost.org/releases") | ||
} |
38 changes: 38 additions & 0 deletions
38
buildSrc/src/main/kotlin/org/polyfrost/gradle/addDependencies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.polyfrost.gradle | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
fun Project.provideIncludedDependencies(version: Triple<Int, Int, Int>?, loader: String): List<OCDependency> { // Either a String or ExternalModuleDependency | ||
val libs = project | ||
.extensions | ||
.getByType<VersionCatalogsExtension>() | ||
.named("libs") | ||
val deps = mutableListOf<Any>() | ||
deps.addAll(libs.findBundle("kotlin").get().get()) | ||
deps.addAll(libs.findBundle("kotlinx").get().get()) | ||
deps.addAll(libs.findBundle("nightconfig").get().get()) | ||
deps.add(libs.findLibrary("isolated-lwjgl3-loader").get().get()) | ||
deps.add(libs.findLibrary("deftu-filestream").get().get()) | ||
deps.add(libs.findLibrary("polyui").get().get()) | ||
deps.add(libs.findLibrary("hypixel-modapi").get().get()) | ||
deps.add(libs.findLibrary("hypixel-data").get().get()) | ||
if (loader == "fabric") { | ||
deps.add(libs.findLibrary("fabric-language-kotlin").get().get()) | ||
} else if (version != null && version.second > 12) { // forge / neoforge | ||
// TODO add KFF | ||
} | ||
val actualDeps = mutableListOf<OCDependency>() | ||
for (dep in deps) { | ||
actualDeps.add(OCDependency(dep)) | ||
} | ||
if (version != null) { | ||
actualDeps.add(OCDependency("org.polyfrost:universalcraft-${version.toMCVer()}-$loader:${libs.findVersion("universalcraft").get().displayName}", true)) | ||
} | ||
return actualDeps | ||
} | ||
|
||
private fun Triple<Int, Int, Int>.toMCVer() = listOf(first, second, third).dropLastWhile { it == 0 }.joinToString(".") | ||
|
||
data class OCDependency(val dep: Any, val mod: Boolean = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# OneConfig dependencies | ||
|
||
This directory contains the dependencies for the OneConfig project. | ||
|
||
## Complications | ||
The dependencies we use are also used by various other projects. Hence, | ||
we want to ensure that we always load the newest version of whatever | ||
dependency we use. However, each mod loader we use has a different way | ||
of handling dependencies, with varying levels of complexity: | ||
|
||
- **On Legacy Forge:** There is no built-in dependency system. If we have a | ||
newer version of a dependency, we depend on a hack in the OneConfig | ||
loader (which is required for Legacy Forge) known as "Relaunch." | ||
Essential also uses the same system, but we have systems in place to | ||
ensure both work together and always load the correct version of our | ||
dependencies. | ||
- **On modern Forge without JiJ:** In later versions, Forge has | ||
added a similar system to Fabric's JiJ. However, this system is not | ||
in all of the versions we support, so we simply have to cope with | ||
this stupidity and hope that the versions we use will work itself | ||
out... | ||
- **On Fabric:** Fabric has a built-in dependency system (via JiJ, aka | ||
"Jar-in-Jar"). Assuming all dependencies follow SemVer correctly | ||
(which all of ours do), we can simply use the `include` configuration | ||
to include the dependencies in the final JAR file, and Fabric will | ||
automatically handle any version conflicts. | ||
- **On NeoForge / modern Forge with JiJ:** We can use the same system as | ||
Fabric. | ||
|
||
In addition, the `UniversalCraft` library is per-MC version, adding a new | ||
level of complexity, LWJGL is split between LWJGL2 (1.12 and below) and | ||
LWJGL3 (1.13 and above), and we require the `PolyMixin` library for | ||
1.12.2 and below. | ||
|
||
## So... what do we do? | ||
|
||
- **On Legacy Forge:** We put all of our dependencies packed into separate | ||
JAR into one singular JAR file. Once the OneConfig loader downloads the | ||
dependency JAR, it will extract the JAR and load / handle each individual | ||
JAR / dependency from there. | ||
- **On modern Forge without JiJ:** We shade all of our dependencies into | ||
the platform JAR and pray that it works. | ||
- **On Fabric:** We use the `include` configuration to include the | ||
dependencies in the final JAR file. | ||
- **On NeoForge / modern Forge with JiJ:** We use the same system as | ||
Fabric. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import org.polyfrost.gradle.provideIncludedDependencies | ||
|
||
plugins { | ||
alias(libs.plugins.jetbrains.idea.ext) | ||
id("org.polyfrost.loom") | ||
} | ||
|
||
description = "Dependencies for legacy platforms (<1.12)" | ||
|
||
val natives = listOf("windows", "windows-arm64", "linux", "macos", "macos-arm64") | ||
|
||
dependencies { | ||
for (dep in listOf("-nanovg", "-tinyfd", "-stb", "")) { | ||
val lwjglDep = "org.lwjgl:lwjgl$dep:${libs.versions.lwjgl.get()}" | ||
api(lwjglDep) { | ||
isTransitive = false | ||
minecraft("com.mojang:minecraft:1.16.5") | ||
mappings("net.fabricmc:yarn:1.16.5+build.10:v2") | ||
|
||
provideIncludedDependencies(null, "forge").forEach { | ||
val dep = if (it.mod) modCompileOnly(it.dep) else compileOnly(it.dep) | ||
if (dep != null) { | ||
include(dep) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
modules/dependencies/legacy/src/main/resources/fabric.mod.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "oneconfig-deps", | ||
"name": "OneConfig Dependencies", | ||
"version": "${version}", | ||
"description": "Fake Fabric mod JSON for Legacy Forge mods", | ||
"authors": [ | ||
"Polyfrost" | ||
], | ||
"contact": { | ||
"homepage": "https://polyfrost.org", | ||
"sources": "https://github.com/Polyfrost/OneConfig", | ||
"issues": "https://inv.wtf/polyfrost" | ||
}, | ||
"license": "LGPL-3.0", | ||
"environment": "client", | ||
"custom": { | ||
"modmenu": { | ||
"badges": [ "library" ] | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters