From a17412e1f1c829dd6d085b4849dae4ca571fd16b Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Tue, 22 Nov 2022 20:22:20 +0100 Subject: Terrible Kotlin! (#435) * Terrible Kotlin! You are unloved and everybody dies * Load Kotlin via a Tweaker * Fix version comparison * Allow user to prevent loading of Kotlin libraries using system properties * Remove testing files --- build.gradle.kts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'build.gradle.kts') diff --git a/build.gradle.kts b/build.gradle.kts index defc1052..a661d6be 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,7 @@ plugins { id("com.github.johnrengelman.shadow") version "7.1.2" id("io.github.juuxel.loom-quiltflower") version "1.7.3" `maven-publish` + kotlin("jvm") version "1.7.20" } @@ -47,7 +48,7 @@ loom { "client" { property("mixin.debug", "true") property("asmhelper.verbose", "true") - arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") + arg("--tweakClass", "io.github.moulberry.notenoughupdates.loader.NEUDelegatingTweaker") arg("--mixin", "mixins.notenoughupdates.json") } } @@ -90,11 +91,21 @@ val devEnv by configurations.creating { isVisible = false } +val kotlinDependencies by configurations.creating { + configurations.implementation.get().extendsFrom(this) +} + dependencies { + implementation("org.projectlombok:lombok:1.18.22") minecraft("com.mojang:minecraft:1.8.9") mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") + + // Please keep this version in sync with KotlinLoadingTweaker + implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:1.7.21")) + kotlinDependencies(kotlin("stdlib")) + shadowImplementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") { isTransitive = false // Dependencies of mixin are already bundled by minecraft } @@ -128,7 +139,7 @@ tasks.withType(Jar::class) { archiveBaseName.set("NotEnoughUpdates") manifest.attributes.run { this["Main-Class"] = "NotSkyblockAddonsInstallerFrame" - this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker" + this["TweakClass"] = "io.github.moulberry.notenoughupdates.loader.NEUDelegatingTweaker" this["MixinConfigs"] = "mixins.notenoughupdates.json" this["FMLCorePluginContainsFMLMod"] = "true" this["ForceLoadAsMod"] = "true" @@ -145,6 +156,16 @@ val remapJar by tasks.named("remapJar") { } } +/* Bypassing https://github.com/johnrengelman/shadow/issues/111 */ +// Use Zip instead of Jar as to not include META-INF +val kotlinDependencyCollectionJar by tasks.creating(Zip::class) { + archiveFileName.set("kotlin-libraries-wrapped.jar") + destinationDirectory.set(project.layout.buildDirectory.dir("kotlinwrapper")) + from(kotlinDependencies.files) + into("neu-kotlin-libraries-wrapped") +} + + tasks.shadowJar { archiveClassifier.set("dep-dev") configurations = listOf(shadowImplementation, shadowApi) @@ -155,6 +176,8 @@ tasks.shadowJar { listOf("logback-classic", "commons-logging", "commons-codec", "logback-core") } } + from(kotlinDependencyCollectionJar) + dependsOn(kotlinDependencyCollectionJar) fun relocate(name: String) = relocate(name, "io.github.moulberry.notenoughupdates.deps.$name") } -- cgit