import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar buildscript { dependencies { classpath("com.guardsquare:proguard-gradle:7.1.0-beta2") { exclude("com.android.tools.build") } } } plugins { kotlin("jvm") version "1.5.0-M2" id("com.github.johnrengelman.shadow") version "6.1.0" apply false id("architectury-plugin") version "3.0-SNAPSHOT" id("forgified-fabric-loom") version "0.7.0-SNAPSHOT" apply false } group = "fr.username404" version = "0.0.1" val groupAndName = "${rootProject.group}.${rootProject.name.toLowerCase()}" architectury { minecraft = rootProject.property("minecraft") as String } subprojects { lateinit var MappingsDep: Dependency apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "forgified-fabric-loom") apply(plugin = "com.github.johnrengelman.shadow") val shadowC by configurations.creating tasks { withType(ShadowJar::class) { this.configurations = listOf(shadowC) } val shrinkJar = register("shrinkJar", proguard.gradle.ProGuardTask::class) { injars(this@tasks.getByName("remapJar")) outjars("$rootDir/shrinkedJars/") keep("class fr.username404.snowygui.** { * ; }") keepattributes(); keepdirectories(); keeppackagenames(); keepparameternames() adaptclassstrings(); adaptresourcefilecontents() dontwarn("fr.username404.**") dontwarn("java.**") // Needed for the current version of proguard // Note: dontpreverify() should NOT be used, it will cause errors at runtime dontoptimize(); dontobfuscate() } if (this@subprojects.name != "common") build.get().finalizedBy(shrinkJar) } extensions.configure("loom") { MappingsDep = officialMojangMappings() silentMojangMappingsLicense() mixinConfig("snowygui-mixins.json") refmapName = "snowygui-common-refmap.json" } dependencies { shadowC(kotlin("stdlib-jdk8") as String) { exclude(module = "kotlin-stdlib-common") exclude(module = "annotations") } "minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}") "mappings"(MappingsDep) } } allprojects { apply(plugin = "java") apply(plugin = "architectury-plugin") java { targetCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8 } tasks { withType(ShadowJar::class) { minimize { exclude(project(":common")) } relocate("kotlin", "${rootProject.group}.kotlin") archiveClassifier.set("shadow") } withType(Jar::class) { from("$rootDir/LICENSE.txt") archiveBaseName.set("${rootProject.name}-${rootProject.version}") } withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { with(kotlinOptions) { freeCompilerArgs = listOf("-Xjvm-default=all") useIR = true jvmTarget = "1.8" languageVersion = "1.5" apiVersion = "1.5" } } withType(JavaCompile::class) { with(options) { encoding = "UTF-8" if (JavaVersion.current().isJava9Compatible) { release.set(8) }; isFork = true } } withType(net.fabricmc.loom.task.RemapJarTask::class) { val shadowTask = getByName("shadowJar") as ShadowJar dependsOn(shadowTask) archiveBaseName.set(shadowTask.archiveBaseName) input.set(shadowTask.archiveFile) archiveClassifier.set(this@allprojects.name) if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars")) } withType(ProcessResources::class) { with(project(":common").sourceSets.main.get().resources.srcDirs) { if (!sourceSets.main.get().resources.srcDirs.containsAll(this)) { from(this) } } val modVersionPair: Pair = "mod_version" to (rootProject.version as String) filesNotMatching(listOf("*.png", "*/*.ttf")) { expand(mutableMapOf(modVersionPair)) } } } }