1+ package gg.essential
2+
3+ import gg.essential.gradle.multiversion.Platform
4+ import gg.essential.gradle.util.RelocationTransform.Companion.registerRelocationAttribute
5+
6+
7+ plugins {
8+ id(" gg.essential.loom" )
9+ }
10+
11+ val platform = Platform .of(project)
12+
13+ val essentialLoader: Configuration by configurations.creating
14+
15+ when {
16+ platform.isLegacyForge -> {
17+ dependencies {
18+ " runtimeOnly" (essentialLoader(" gg.essential:loader-launchwrapper:1.1.3" )!! )
19+ }
20+ tasks.named<Jar >(" jar" ) {
21+ dependsOn(essentialLoader)
22+ from({ zipTree(essentialLoader.singleFile) })
23+ }
24+ }
25+
26+ platform.isFabric -> {
27+ dependencies {
28+ " include" (" modRuntimeOnly" (" gg.essential:loader-fabric:1.0.0" )!! )
29+ }
30+ }
31+
32+ platform.isModLauncher -> {
33+ dependencies {
34+ val relocatedPackage = findProperty(" essential.loader.package" )?.toString() ? : throw GradleException ("""
35+ No essential loader package set.
36+ You need to set `essential.loader.package` in the project's `gradle.properties` file to a specific package.
37+ The recommended package is your mod's package.
38+ """ .trimIndent())
39+ val relocationAttribute =
40+ registerRelocationAttribute(" essential-loader-relocated" ) {
41+ relocate(" gg.essential.loader.stage0" , " $relocatedPackage .stage0" )
42+ // preserve stage1 path
43+ rename(" gg/essential/loader/stage0/stage1.jar" , " gg/essential/loader/stage0/stage1.jar" )
44+ }
45+ essentialLoader.attributes {
46+ attribute(relocationAttribute, true )
47+ }
48+ if (platform.mcVersion < 11700 ) {
49+ " forgeRuntimeLibrary" (essentialLoader(" gg.essential:loader-modlauncher8:1.0.0" )!! )
50+ } else {
51+ " forgeRuntimeLibrary" (essentialLoader(" gg.essential:loader-modlauncher9:1.0.0" )!! )
52+ }
53+ }
54+ tasks.named<Jar >(" jar" ) {
55+ dependsOn(essentialLoader)
56+ from({ zipTree(essentialLoader.singleFile) })
57+ }
58+ }
59+
60+ else -> error(" No loader available for this platform" )
61+ }
62+
63+ // Unit statement so it doesn't try to get the result from the when block
64+ Unit
0 commit comments