Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new script to easily add the essential loader #5

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
69 changes: 69 additions & 0 deletions src/main/kotlin/gg/essential/essential-loader.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package gg.essential

import gg.essential.gradle.multiversion.Platform
import gg.essential.gradle.util.RelocationTransform.Companion.registerRelocationAttribute


plugins {
id("gg.essential.loom")
}

val platform = Platform.of(project)

val essentialLoader: Configuration by configurations.creating

when {
platform.isLegacyForge -> {
dependencies {
"implementation"(essentialLoader("gg.essential:loader-launchwrapper:1.2.2")!!)
Copy link
Member

@caoimhebyrne caoimhebyrne Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a property for the loader version which just defaults to 1.2.2? (and we can change that whenever we get around to it)

Without one, we would have to make sure we always update this (which shouldn't be too often from my knowledge, but still)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe however the original intent was for the dev to have to do as little as possible (and I think it's mostly fine that the version is hardcoded since in theory the stage0 version should almost never change)

}
tasks.named<Jar>("jar") {
Sychic marked this conversation as resolved.
Show resolved Hide resolved
dependsOn(essentialLoader)
manifest.attributes(mapOf(
"TweakClass" to "gg.essential.loader.stage0.EssentialSetupTweaker"
))
from({ zipTree(essentialLoader.singleFile) })
}
}

platform.isFabric -> {
dependencies {
"include"("modRuntimeOnly"("gg.essential:loader-fabric:1.2.2")!!)
}
}

Sychic marked this conversation as resolved.
Show resolved Hide resolved
//FIXME: Fix loader not working on ml
platform.isModLauncher -> {
error("Modlauncher is currently not supported")
// dependencies {
// val relocatedPackage = findProperty("essential.loader.package")?.toString() ?: throw GradleException("""
// A package for the Essential loader to be relocated to has not been set.
// You need to set `essential.loader.package` in the project's `gradle.properties` file to a package where Essential's loader will be relocated to.
// For example: `essential.loader.package = org.example.coolmod.relocated.essential`
// """.trimIndent())
// val relocationAttribute =
// registerRelocationAttribute("essential-loader-relocated") {
// relocate("gg.essential.loader.stage0", "$relocatedPackage.stage0")
// // preserve stage1 path
// rename("gg/essential/loader/stage0/stage1.jar", "gg/essential/loader/stage0/stage1.jar")
// }
// essentialLoader.attributes {
// attribute(relocationAttribute, true)
// }
// if (platform.mcVersion < 11700) {
// "forgeRuntimeLibrary"(essentialLoader("gg.essential:loader-modlauncher8:1.2.2")!!)
// } else {
// "forgeRuntimeLibrary"(essentialLoader("gg.essential:loader-modlauncher9:1.2.2")!!)
// }
// }
// tasks.named<Jar>("jar") {
// dependsOn(essentialLoader)
// from({ zipTree(essentialLoader.singleFile) })
// }
}

else -> error("No loader available for this platform")
}

// Unit statement so it doesn't try to get the result from the when block
Unit
Loading