11plugins {
22 id(" fabric-loom" ) version " 1.11-SNAPSHOT"
33 id(" maven-publish" )
4- id(" com.gradleup.shadow" ) version " 9.2.2"
54}
65
76base {
@@ -50,7 +49,7 @@ repositories {
5049}
5150
5251val modInclude: Configuration by configurations.creating
53- val library : Configuration by configurations.creating
52+ val jij : Configuration by configurations.creating
5453
5554configurations {
5655 // include mods
@@ -61,12 +60,12 @@ configurations {
6160 extendsFrom(modInclude)
6261 }
6362
64- // include libraries
63+ // include libraries (jar-in-jar)
6564 implementation.configure {
66- extendsFrom(library )
65+ extendsFrom(jij )
6766 }
68- shadow .configure {
69- extendsFrom(library )
67+ include .configure {
68+ extendsFrom(jij )
7069 }
7170}
7271
@@ -94,16 +93,44 @@ dependencies {
9493 modCompileOnly(" com.terraformersmc:modmenu:${properties[" modmenu_version" ] as String } " )
9594
9695 // Libraries
97- library(" meteordevelopment:orbit:${properties[" orbit_version" ] as String } " )
98- library(" org.meteordev:starscript:${properties[" starscript_version" ] as String } " )
99- library(" meteordevelopment:discord-ipc:${properties[" discordipc_version" ] as String } " )
100- library(" org.reflections:reflections:${properties[" reflections_version" ] as String } " )
101- library(" io.netty:netty-handler-proxy:${properties[" netty_version" ] as String } " ) { isTransitive = false }
102- library(" io.netty:netty-codec-socks:${properties[" netty_version" ] as String } " ) { isTransitive = false }
103- library(" de.florianmichael:WaybackAuthLib:${properties[" waybackauthlib_version" ] as String } " )
104-
105- // Launch sub project
106- shadow(project(" :launch" ))
96+ jij(" meteordevelopment:orbit:${properties[" orbit_version" ] as String } " )
97+ jij(" org.meteordev:starscript:${properties[" starscript_version" ] as String } " )
98+ jij(" meteordevelopment:discord-ipc:${properties[" discordipc_version" ] as String } " )
99+ jij(" org.reflections:reflections:${properties[" reflections_version" ] as String } " )
100+ jij(" io.netty:netty-handler-proxy:${properties[" netty_version" ] as String } " ) { isTransitive = false }
101+ jij(" io.netty:netty-codec-socks:${properties[" netty_version" ] as String } " ) { isTransitive = false }
102+ jij(" de.florianmichael:WaybackAuthLib:${properties[" waybackauthlib_version" ] as String } " )
103+ }
104+
105+ // Handle transitive dependencies for jar-in-jar
106+ // Based on implementation from BaseProject by FlorianMichael/EnZaXD
107+ // Source: https://github.com/FlorianMichael/BaseProject/blob/main/src/main/kotlin/de/florianmichael/baseproject/Fabric.kt
108+ // Licensed under Apache License 2.0
109+ afterEvaluate {
110+ val jijConfig = configurations.findByName(" jij" ) ? : return @afterEvaluate
111+
112+ // Dependencies to exclude from jar-in-jar
113+ val excluded = setOf (
114+ " org.slf4j" , // Logging provided by Minecraft
115+ " jsr305" // Compile time annotations only
116+ )
117+
118+
119+ jijConfig.incoming.resolutionResult.allDependencies.forEach { dep ->
120+ val requested = dep.requested.displayName
121+
122+ if (excluded.any { requested.contains(it) }) return @forEach
123+
124+ val compileOnlyDep = dependencies.create(requested) {
125+ isTransitive = false
126+ }
127+
128+ val implDep = dependencies.create(compileOnlyDep)
129+
130+ dependencies.add(" compileOnlyApi" , compileOnlyDep)
131+ dependencies.add(" implementation" , implDep)
132+ dependencies.add(" include" , compileOnlyDep)
133+ }
107134}
108135
109136loom {
@@ -142,6 +169,10 @@ tasks {
142169 rename { " ${it} _${inputs.properties[" archivesName" ]} " }
143170 }
144171
172+ // Launch sub project
173+ dependsOn(" :launch:compileJava" )
174+ from(project(" :launch" ).layout.buildDirectory.dir(" classes/java/main" ))
175+
145176 manifest {
146177 attributes[" Main-Class" ] = " meteordevelopment.meteorclient.Main"
147178 }
@@ -163,27 +194,6 @@ tasks {
163194 options.compilerArgs.add(" -Xlint:unchecked" )
164195 }
165196
166- shadowJar {
167- configurations = listOf (project.configurations.shadow.get())
168-
169- inputs.property(" archivesName" , project.base.archivesName.get())
170-
171- from(" LICENSE" ) {
172- rename { " ${it} _${inputs.properties[" archivesName" ]} " }
173- }
174-
175- dependencies {
176- exclude {
177- it.moduleGroup == " org.slf4j"
178- }
179- }
180- }
181-
182- remapJar {
183- dependsOn(shadowJar)
184- inputFile.set(shadowJar.get().archiveFile)
185- }
186-
187197 javadoc {
188198 with (options as StandardJavadocDocletOptions ) {
189199 addStringOption(" Xdoclint:none" , " -quiet" )
0 commit comments