There is a time when you need to depend on a mod that uses Jar-in-Jar and you need to access classes from those JiJ, but it is a private JiJ, and it doesn't get published to any Maven repository, so you scrap your entire mod idea into the abyss, never to be seen again.
Right? Or maybe it's only me?
Well, I made this Gradle plugin to solve exactly that. This plugin will resolve Jar-in-Jars, making it available to be depended upon.
// settings.gradle
pluginManagement {
repositories {
maven {
url "https://maven2.bai.lol"
content {
includeGroup "lol.bai.explosion"
}
}
}
}
// build.gradle
plugins {
id "lol.bai.explosion" version "0.3.1"
}
repositories {
maven {
url "https://maven2.bai.lol"
content {
includeGroup "lol.bai.explosion"
}
}
}
dependencies {
modImplementation explosion.fabric("curse.maven:fabric-api-306612:5710210")
implementation explosion.forge("curse.maven:create-328085:5689514")
implementation explosion.neoforge("curse.maven:ender-io-64578:5720393")
}
Warning
fg.deobf
won't work with exploded dependency, you need to manually deobfuscate
the jar.
// replace the mapping as needed
def mapping = "official_1.20.1"
def deobfuscator = new net.minecraftforge.gradle.userdev.util.Deobfuscator(project, file("build/explosion_deobf"))
def explode = explosion.forge.with(mapping) {
transformer {
return deobfuscator.deobfBinary(it.toFile(), mapping, it.fileName.toString()).toPath()
}
}
// then use the explode variable
implementation explode("curse.maven:create-328085:5689514")
Explosion also provides way to explode local file and directory.
explosion.fabric {
maven "curse.maven:fabric-api-306612:4764776"
local project.file("path/to/mod.jar")
loacl project.file("path/to/mods/directory")
}
All resolved mods will have exploded
as its group and the mod id as its module.
You can therefore exclude it with such.
def exploded = explosion.fabric { /*...*/ }
modImplementation(exploded) {
exclude group: "exploded", module: "modid"
}
Explosion can also be used to debug modpacks by depending on the modpack's mods folder.
- Install the modpack using your favorite launcher.
- Open its instance folder, and rename the
mods
folder with something else, e.g.mods-blabla
. - Set up a dev environment, you can use the Template Generator. Disable the split sources for higher chance to work.
- Depend on the folder.
modImplementation explosion.fabric { local project.file("path/to/mods-blabla") }
- Configure the run directory to the instance folder.
- Pray for it to be able to run.
- Fix mappings error, if any.
- Pray again.
Explosion simply uses the existing loader infrastructure on each platform to load and resolve the mod jars. It literally runs the loader as if it's the runtime and hack it to get the loaded jars. Well, as long as it works, amirite?