Skip to content

Commit fd7e1a4

Browse files
authored
Merge pull request #26 from EssentialGG/feature/lw2
Make Essential Loader usable without Essential on 1.8.9-1.12.2
2 parents d75286a + f8f4974 commit fd7e1a4

File tree

96 files changed

+3657
-1214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3657
-1214
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish mixin
2+
3+
on:
4+
push:
5+
tags:
6+
- mixin/v*
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: actions/setup-java@v4
15+
with:
16+
distribution: temurin
17+
java-version: |
18+
8
19+
16
20+
17
21+
22+
- name: Publish
23+
run: ./gradlew :mixin:publish --stacktrace
24+
env:
25+
ORG_GRADLE_PROJECT_nexus_user: ${{ secrets.NEXUS_USER }}
26+
ORG_GRADLE_PROJECT_nexus_password: ${{ secrets.NEXUS_PASSWORD }}

.github/workflows/publish-stage2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
17
2121
2222
- name: Build
23-
run: ./gradlew :stage2:{launchwrapper,fabric,modlauncher{8,9}}:build --stacktrace
23+
run: ./gradlew :stage2:{launchwrapper-legacy,fabric,modlauncher{8,9}}:build --stacktrace
2424

2525
- name: Upload Artifacts
2626
uses: actions/upload-artifact@v4

README.md

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,118 @@
1-
[Docs](https://github.com/EssentialGG/EssentialLoader/tree/master/docs)
1+
## Internals
2+
For an explanation of how the internals of Essential Loader on various platforms function, see the [docs](https://github.com/EssentialGG/EssentialLoader/tree/master/docs) folder.
3+
4+
## Using Essential Loader with your mod on 1.8.9 - 1.12.2
5+
Essential Loader for Minecraft 1.8.9 through 1.12.2 (commonly called "legacy Forge" or "LaunchWrapper") provides support
6+
for Mixin 0.8.x (even on 1.8.9, and with improved third-party mod compatibility on 1.12.2) and Jar-in-Jar style
7+
dependency management (e.g. if two mods ship different versions of the same dependency, it will automatically select
8+
the more recent one).
9+
10+
### Setup
11+
To use it with your mod, firstly you must declare a dependency in your build script and include it in your jar file:
12+
```kotlin
13+
repositories {
14+
maven("https://repo.essential.gg/repository/maven-public/")
15+
}
16+
17+
val embed by configurations.creating
18+
configurations.implementation.get().extendsFrom(embed)
19+
20+
dependencies {
21+
embed("gg.essential:loader-launchwrapper:1.3.0")
22+
}
23+
24+
tasks.jar {
25+
// Embed the contents of the Essential Loader jar into your mod jar.
26+
dependsOn(embed)
27+
from(embed.files.map { zipTree(it) })
28+
// Set Essential Loader as the Tweaker for your mod.
29+
// If you already have a custom Tweaker, you can have it extend the class instead.
30+
// If you previously used the Mixin Tweaker, you can simply use Essential Loader instead, it'll automatically
31+
// initialize Mixin for any mod with a `MixinConfigs` attribute.
32+
manifest.attributes(mapOf("TweakClass" to "gg.essential.loader.stage0.EssentialSetupTweaker"))
33+
}
34+
```
35+
You then need to create a `essential.mod.json` file in your `src/main/resources` folder which defines some metadata and
36+
specifies which libraries your mod includes and where inside the mod jar they can be found:
37+
```json
38+
{
39+
"id": "your_mod_id_goes_here",
40+
"version": "1.0.0",
41+
"jars": [
42+
{
43+
"id": "com.example:examplelib",
44+
"version": "0.1.0",
45+
"file": "META-INF/jars/examplelib-0.1.0.jar"
46+
}
47+
]
48+
}
49+
```
50+
If you don't have any special needs, you can auto-generate the `version` and `jars` entries and automate the inclusion
51+
of the libraries in your mod based on Gradle dependencies with the following snippet in your build script:
52+
```kotlin
53+
val jij by configurations.creating
54+
configurations.implementation.get().extendsFrom(jij)
55+
56+
dependencies {
57+
// Add all the dependencies you wish to jar-in-jar to the custom `jij` configuration
58+
jij("com.example:examplelib:0.1.0")
59+
}
60+
61+
tasks.processResources {
62+
val expansions = mapOf(
63+
"version" to version,
64+
"jars" to provider {
65+
jij.resolvedConfiguration.resolvedArtifacts.joinToString(",\n") { artifact ->
66+
val id = artifact.moduleVersion.id
67+
"""
68+
{
69+
"id": "${id.group}:${id.name}",
70+
"version": "${id.version}",
71+
"file": "META-INF/jars/${artifact.file.name}"
72+
}
73+
""".trimIndent()
74+
}
75+
},
76+
)
77+
inputs.property("expansions", expansions)
78+
filesMatching("essential.mod.json") {
79+
expand(expansions)
80+
}
81+
}
82+
83+
tasks.jar {
84+
dependsOn(jij)
85+
from(jij.files) {
86+
into("META-INF/jars")
87+
}
88+
}
89+
```
90+
and the following `essential.mod.json` template file:
91+
```json
92+
{
93+
"id": "your_mod_id_goes_here",
94+
"version": "${version}",
95+
"jars": [
96+
${jars.get()}
97+
]
98+
}
99+
```
100+
101+
### Mixin 0.8.x
102+
103+
To use our Mixin with your mod, assuming you've already included Essential Loader as per above instructions, and you've
104+
already set up Mixin's annotation processor and refmap generation via your build system (this is done the same way as
105+
it would be done with stock Mixin 0.8.x or 0.7.10, Essential Loader only affects things at runtime), simply
106+
add it as a jar-in-jar dependency:
107+
```kotlin
108+
dependencies {
109+
jij("gg.essential:mixin:0.1.0+mixin.0.8.4")
110+
111+
// MixinExtras may be added in the same way:
112+
// Essential Loader will automatically initialize it for you, no need to call `MixinExtrasBootstrap`.
113+
// `annotationProcessor` is necessary to generate refmaps if your build system does not setup MixinExtras for you.
114+
jij(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1")!!)
115+
// or if you've previously used Essential's relocated MixinExtras version:
116+
jij(annotationProcessor("gg.essential.lib:mixinextras:0.4.0")!!)
117+
}
118+
```

build-logic/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ repositories {
88

99
dependencies {
1010
api("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
11+
12+
implementation("org.ow2.asm:asm-commons:9.3")
1113
}

0 commit comments

Comments
 (0)