@@ -2,24 +2,20 @@ import at.skyhanni.sharedvariables.MultiVersionStage
22import at.skyhanni.sharedvariables.ProjectTarget
33import at.skyhanni.sharedvariables.SHVersionInfo
44import at.skyhanni.sharedvariables.versionString
5- import com.google.devtools.ksp.gradle.KspTaskJvm
65import io.gitlab.arturbosch.detekt.Detekt
76import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
87import net.fabricmc.loom.task.prod.ClientProductionRunTask
98import org.jetbrains.kotlin.gradle.dsl.JvmTarget
10- import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
119import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
1210import skyhannibuildsystem.ChangelogVerification
13- import skyhannibuildsystem.CleanupMappingFiles
1411import skyhannibuildsystem.DownloadBackupRepo
1512import skyhannibuildsystem.PublishToModrinth
1613
1714plugins {
1815 idea
1916 java
20- id(" com.gradleup.shadow" ) version " 8.3.4"
21- id(" fabric-loom" )
22- id(" com.github.SkyHanniStudios.SkyHanni-Preprocessor" )
17+ id(" com.gradleup.shadow" ) version " 9.3.1"
18+ id(" net.fabricmc.fabric-loom-remap" )
2319 kotlin(" jvm" )
2420 id(" com.google.devtools.ksp" )
2521 kotlin(" plugin.power-assert" )
@@ -43,18 +39,18 @@ runDirectory.mkdirs()
4339
4440// Minecraft configuration:
4541loom {
46- val accessWidenerFile = when (target) {
47- ProjectTarget .MODERN_12105 -> rootProject.file(" src/main/resources/skyhanni.accesswidener" )
48- else -> file(" src/main/resources/skyhanni.accesswidener" )
49- }
50- if (accessWidenerFile.exists()) {
51- accessWidenerPath = accessWidenerFile
52- }
53- @Suppress(" UnstableApiUsage" )
54- mixin {
55- useLegacyMixinAp.set(true )
56- defaultRefmapName.set(" mixins.skyhanni.refmap.json" )
42+ val classTweakerFile = sc.process(
43+ rootProject.file(" src/main/resources/skyhanni.classtweaker" ),
44+ " build/skyhanni.classtweaker" ,
45+ )
46+ if (classTweakerFile.exists()) {
47+ accessWidenerPath = classTweakerFile
48+ } else {
49+ println (" No classTweaker file for ${target.minecraftVersion} " )
5750 }
51+
52+ fabricModJsonPath = rootProject.file(" src/main/resources/fabric.mod.json" )
53+
5854 runs {
5955 named(" client" ) {
6056 isIdeConfigGenerated = true
@@ -96,10 +92,6 @@ val includeBackupNeuRepo by tasks.registering(DownloadBackupRepo::class) {
9692 this .outputDirectory.set(layout.buildDirectory.dir(" downloadedNeuRepo" ))
9793}
9894
99- val cleanupMappingFiles by tasks.registering(CleanupMappingFiles ::class ) {
100- this .mappingsDirectory.set(layout.projectDirectory.asFile.parentFile)
101- }
102-
10395val publishToModrinth by tasks.registering(PublishToModrinth ::class )
10496
10597tasks.runClient {
@@ -120,7 +112,12 @@ dependencies {
120112 val versionName = target.minecraftVersion.versionNameOverride ? : target.minecraftVersion.versionName
121113 minecraft(" com.mojang:minecraft:$versionName " )
122114 if (target.mappingDependency == " official" ) {
123- mappings(loom.officialMojangMappings())
115+ mappings(loom.layered {
116+ officialMojangMappings()
117+ if (versionName == " 1.21.10" ) {
118+ mappings(" dev.lambdaurora:yalmm-mojbackward:1.21.10+build.3" )
119+ }
120+ })
124121 } else {
125122 mappings(target.mappingDependency)
126123 }
@@ -153,6 +150,7 @@ dependencies {
153150 }
154151
155152 testImplementation(" org.junit.jupiter:junit-jupiter:5.11.0" )
153+ testRuntimeOnly(" org.junit.platform:junit-platform-launcher" )
156154 testImplementation(" io.mockk:mockk:1.12.5" )
157155
158156 modImplementation(libs.hypixelmodapi)
@@ -173,6 +171,8 @@ dependencies {
173171 detektPlugins(" org.notenoughupdates:detektrules:1.0.0" )
174172 detektPlugins(project(" :detekt" ))
175173 detektPlugins(" io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7" )
174+
175+ if (target != ProjectTarget .MODERN_12110 ) shadowImpl(" org.apache.httpcomponents:httpclient:4.5.14" )
176176}
177177
178178fun DependencyHandler.includeImplementation (dep : Any ) {
@@ -184,10 +184,11 @@ afterEvaluate {
184184 loom.runs.named(" client" ) {
185185 programArgs(" --quickPlayMultiplayer" , " hypixel.net" )
186186 }
187- tasks.named(" kspKotlin" , KspTaskJvm ::class ) {
188- this .options.add(SubpluginOption (" apoption" , " skyhanni.modver=$version " ))
189- this .options.add(SubpluginOption (" apoption" , " skyhanni.mcver=${target.minecraftVersion.versionName} " ))
190- this .options.add(SubpluginOption (" apoption" , " skyhanni.buildpaths=${project.file(" buildpaths-excluded.txt" ).absolutePath} " ))
187+
188+ ksp {
189+ arg(" skyhanni.modver" , version.toString())
190+ arg(" skyhanni.mcver" , target.minecraftVersion.versionName)
191+ arg(" skyhanni.buildpaths" , project.file(" buildpaths-excluded.txt" ).absolutePath)
191192 }
192193}
193194
@@ -211,13 +212,21 @@ kotlin {
211212tasks.processResources {
212213 from(includeBackupRepo)
213214 from(includeBackupNeuRepo)
214- inputs.property(" version" , version)
215+ val fapiVersion = target.fabricApiVersion?.split(" :" )?.last() ? : " "
216+ val props = buildMap {
217+ put(" version" , version)
218+ put(" minecraft" , target.minecraftVersion.versionName)
219+ put(" fapi" , fapiVersion)
220+ }
221+
222+ props.forEach(inputs::property)
223+
215224 filesMatching(" fabric.mod.json" ) {
216- expand(" version " to version )
225+ expand(props )
217226 }
218227}
219228
220- if (target == ProjectTarget .MODERN_12105 ) {
229+ if (target == ProjectTarget .MODERN_12110 ) {
221230 fabricApi {
222231 configureTests {
223232 modId = " skyhanni"
@@ -259,16 +268,6 @@ tasks.withType<KotlinCompile> {
259268 compilerOptions.jvmTarget.set(JvmTarget .fromTarget(target.minecraftVersion.formattedJavaLanguageVersion))
260269}
261270
262- if (target.parent == ProjectTarget .MODERN_12105 ) {
263- val mainRes = project(ProjectTarget .MODERN_12105 .projectPath).tasks.getAt(" processResources" )
264- tasks.named(" processResources" ) {
265- dependsOn(mainRes)
266- }
267- tasks.named(" preprocessCode" ) {
268- dependsOn(mainRes)
269- }
270- }
271-
272271tasks.withType(JavaCompile ::class ) {
273272 options.encoding = " UTF-8"
274273}
@@ -277,9 +276,6 @@ tasks.withType(org.gradle.jvm.tasks.Jar::class) {
277276 archiveBaseName.set(" SkyHanni" )
278277 archiveVersion.set(" $version -mc${target.minecraftVersion.versionName} " )
279278 duplicatesStrategy = DuplicatesStrategy .EXCLUDE // Why do we have this here? This only *hides* errors.
280- manifest.attributes.run {
281- this [" Main-Class" ] = " SkyHanniInstallerFrame"
282- }
283279}
284280
285281val remapJar by tasks.named< net.fabricmc.loom.task.RemapJarTask > (" remapJar" ) {
@@ -293,11 +289,6 @@ tasks.shadowJar {
293289 destinationDirectory.set(layout.buildDirectory.dir(" badjars" ))
294290 archiveClassifier.set(" all-dev" )
295291 configurations = listOf (shadowImpl, shadowModImpl)
296- doLast {
297- configurations.forEach {
298- println (" Config: ${it.files} " )
299- }
300- }
301292 exclude(" META-INF/versions/**" )
302293 mergeServiceFiles()
303294 relocate(" io.github.notenoughupdates.moulconfig" , " at.hannibal2.skyhanni.deps.moulconfig" )
@@ -331,12 +322,6 @@ if (!MultiVersionStage.activeState.shouldCompile(target)) {
331322 }
332323}
333324
334- preprocess {
335- vars.put(" MC" , target.minecraftVersion.versionNumber)
336- vars.put(" JAVA" , target.minecraftVersion.javaVersion)
337- vars.put(" TODO" , 0 )
338- }
339-
340325val sourcesJar by tasks.registering(Jar ::class ) {
341326 destinationDirectory.set(layout.buildDirectory.dir(" badjars" ))
342327 archiveClassifier.set(" src" )
@@ -372,7 +357,7 @@ detekt {
372357
373358tasks.withType<Detekt >().configureEach {
374359 onlyIf {
375- target == ProjectTarget .MODERN_12105 && project.findProperty(" skipDetekt" ) != " true"
360+ target == ProjectTarget .MODERN_12110 && project.findProperty(" skipDetekt" ) != " true"
376361 }
377362 jvmTarget = target.minecraftVersion.formattedJavaLanguageVersion
378363 outputs.cacheIf { false } // Custom rules won't work if cached
@@ -399,10 +384,13 @@ tasks.withType<DetektCreateBaselineTask>().configureEach {
399384 outputs.cacheIf { false } // Custom rules won't work if cached
400385 onlyIf {
401386 // We only need one baseline for the main source set
402- target == ProjectTarget .MODERN_12105
387+ target == ProjectTarget .MODERN_12110
403388 }
404389
405390 val isMainBaseline = (this .name == " detektBaselineMain" )
406391 val outputFileName = if (isMainBaseline) " baseline-main" else " baseline"
407392 baseline.set(file(rootProject.layout.projectDirectory.file(" detekt/$outputFileName .xml" )))
408393}
394+ repositories {
395+ mavenCentral()
396+ }
0 commit comments