2021-04-08 12:54:54 +02:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
2021-04-15 17:17:49 +02:00
|
|
|
import com.modrinth.minotaur.request.VersionType
|
2021-04-17 14:54:24 +02:00
|
|
|
|
2021-04-14 13:56:20 +02:00
|
|
|
buildscript {
|
|
|
|
dependencies {
|
|
|
|
classpath("com.guardsquare:proguard-gradle:7.1.0-beta2") {
|
|
|
|
exclude("com.android.tools.build")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-08 10:18:46 +02:00
|
|
|
plugins {
|
2021-04-15 10:59:29 +02:00
|
|
|
kotlin("jvm") version "1.5.0-RC"
|
2021-04-08 10:18:46 +02:00
|
|
|
id("com.github.johnrengelman.shadow") version "6.1.0" apply false
|
2021-04-20 15:01:47 +02:00
|
|
|
id("architectury-plugin") version "3.0-SNAPSHOT"
|
2021-04-13 10:50:56 +02:00
|
|
|
id("forgified-fabric-loom") version "0.7.0-SNAPSHOT" apply false
|
2021-04-17 21:06:29 +02:00
|
|
|
id("com.github.ben-manes.versions") version "0.38.0"
|
2021-04-15 17:17:49 +02:00
|
|
|
id("com.modrinth.minotaur") version "1.2.0"
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
group = "fr.username404"
|
|
|
|
version = "0.0.1"
|
|
|
|
val groupAndName = "${rootProject.group}.${rootProject.name.toLowerCase()}"
|
|
|
|
|
|
|
|
architectury {
|
|
|
|
minecraft = rootProject.property("minecraft") as String
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects {
|
2021-04-08 13:23:45 +02:00
|
|
|
lateinit var MappingsDep: Dependency
|
2021-04-08 10:52:09 +02:00
|
|
|
apply(plugin = "org.jetbrains.kotlin.jvm")
|
2021-04-08 10:18:46 +02:00
|
|
|
apply(plugin = "forgified-fabric-loom")
|
|
|
|
apply(plugin = "com.github.johnrengelman.shadow")
|
2021-04-08 12:57:08 +02:00
|
|
|
val shadowC by configurations.creating
|
2021-04-14 13:56:20 +02:00
|
|
|
tasks {
|
|
|
|
withType(ShadowJar::class) { this.configurations = listOf(shadowC) }
|
|
|
|
val shrinkJar = register("shrinkJar", proguard.gradle.ProGuardTask::class) {
|
2021-04-14 20:36:05 +02:00
|
|
|
val dictionariesDir = "$rootDir/obfuscation"
|
2021-04-14 14:34:45 +02:00
|
|
|
injars(this@tasks.getByName("remapJar"))
|
2021-04-14 13:56:20 +02:00
|
|
|
outjars("$rootDir/shrinkedJars/")
|
2021-04-14 18:05:20 +02:00
|
|
|
keep("class fr.username404.snowygui.mixins.* { * ; }")
|
|
|
|
keep("class fr.username404.snowygui.fabric.** { * ; }")
|
|
|
|
keep("class fr.username404.snowygui.forge.** { * ; }")
|
2021-04-14 19:33:19 +02:00
|
|
|
keepclassmembers("class fr.username404.snowygui.** { public protected <methods>; }")
|
2021-04-17 15:15:15 +02:00
|
|
|
keepattributes("*Annotation*, Signature, InnerClasses, EnclosingMethod, MethodParameters, Synthetic, Exceptions")
|
2021-04-14 20:36:05 +02:00
|
|
|
obfuscationdictionary("$dictionariesDir/dictionary.txt")
|
|
|
|
classobfuscationdictionary("$dictionariesDir/classdictionary.txt")
|
2021-04-17 18:46:40 +02:00
|
|
|
packageobfuscationdictionary("$dictionariesDir/packagesdictionary.txt")
|
2021-04-14 18:05:20 +02:00
|
|
|
adaptclassstrings()
|
2021-04-15 12:09:08 +02:00
|
|
|
"fr.username404.**".also { dontwarn(it); dontnote(it) }
|
2021-04-17 14:46:37 +02:00
|
|
|
|
|
|
|
// The following lines are needed at least for the current version of proguard
|
|
|
|
dontwarn("java.**")
|
|
|
|
onlyIf {
|
|
|
|
JavaVersion.current().isJava8.also {
|
2021-04-17 14:54:24 +02:00
|
|
|
if (!it) {
|
|
|
|
println("The shrinkJar task is disabled because Java 9 or higher does not work with our current proguard configuration.")
|
|
|
|
}
|
2021-04-17 14:46:37 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-17 14:54:24 +02:00
|
|
|
libraryjars("${System.getProperty("java.home")}/lib/rt.jar")
|
|
|
|
libraryjars("${System.getProperty("java.home")}/lib/jce.jar")
|
2021-04-17 14:46:37 +02:00
|
|
|
|
2021-04-14 13:56:20 +02:00
|
|
|
// Note: dontpreverify() should NOT be used, it will cause errors at runtime
|
2021-04-14 18:05:20 +02:00
|
|
|
useuniqueclassmembernames()
|
2021-04-17 15:15:15 +02:00
|
|
|
optimizations("method/inlining/*, code/allocation/variable, class/merging/vertical, class/merging/horizontal, code/removal/advanced, code/simplification/branch, code/merging")
|
2021-04-14 18:05:20 +02:00
|
|
|
optimizationpasses(4)
|
|
|
|
overloadaggressively()
|
2021-04-14 13:56:20 +02:00
|
|
|
}
|
|
|
|
if (this@subprojects.name != "common") build.get().finalizedBy(shrinkJar)
|
|
|
|
}
|
2021-04-08 13:23:45 +02:00
|
|
|
extensions.configure<net.fabricmc.loom.LoomGradleExtension>("loom") {
|
|
|
|
MappingsDep = officialMojangMappings()
|
|
|
|
silentMojangMappingsLicense()
|
|
|
|
mixinConfig("snowygui-mixins.json")
|
|
|
|
refmapName = "snowygui-common-refmap.json"
|
|
|
|
}
|
2021-04-08 10:18:46 +02:00
|
|
|
dependencies {
|
2021-04-14 13:56:20 +02:00
|
|
|
shadowC(kotlin("stdlib-jdk8") as String) {
|
|
|
|
exclude(module = "kotlin-stdlib-common")
|
|
|
|
exclude(module = "annotations")
|
|
|
|
}
|
2021-04-16 22:44:03 +02:00
|
|
|
"io.github.config4k:config4k:0.4.2".also { implementation(it); shadowC(it) }
|
2021-04-08 10:18:46 +02:00
|
|
|
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
|
2021-04-08 13:23:45 +02:00
|
|
|
"mappings"(MappingsDep)
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 17:01:05 +02:00
|
|
|
val mcBase: String = rootProject.architectury.minecraft.dropLast(2)
|
2021-04-08 10:18:46 +02:00
|
|
|
allprojects {
|
|
|
|
apply(plugin = "java")
|
|
|
|
apply(plugin = "architectury-plugin")
|
|
|
|
java {
|
|
|
|
targetCompatibility = JavaVersion.VERSION_1_8
|
2021-04-08 11:35:51 +02:00
|
|
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
tasks {
|
2021-04-08 12:54:54 +02:00
|
|
|
withType(ShadowJar::class) {
|
2021-04-08 10:18:46 +02:00
|
|
|
relocate("kotlin", "${rootProject.group}.kotlin")
|
2021-04-17 14:46:37 +02:00
|
|
|
relocate("com.typesafe.config", "${rootProject.group}.typesafe.config")
|
|
|
|
relocate("io.github.config4k", "${rootProject.group}.config4k")
|
|
|
|
exclude("**/*.kotlin_metadata")
|
|
|
|
exclude("**/*.kotlin_builtins")
|
|
|
|
exclude("META-INF/maven/**/*")
|
2021-04-08 12:54:54 +02:00
|
|
|
archiveClassifier.set("shadow")
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
withType(Jar::class) {
|
2021-04-08 12:54:54 +02:00
|
|
|
from("$rootDir/LICENSE.txt")
|
2021-04-08 10:18:46 +02:00
|
|
|
archiveBaseName.set("${rootProject.name}-${rootProject.version}")
|
|
|
|
}
|
|
|
|
withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
|
|
|
|
with(kotlinOptions) {
|
2021-04-15 11:06:15 +02:00
|
|
|
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xlambdas=indy")
|
2021-04-08 10:18:46 +02:00
|
|
|
jvmTarget = "1.8"
|
|
|
|
languageVersion = "1.5"
|
|
|
|
apiVersion = "1.5"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
withType(JavaCompile::class) {
|
|
|
|
with(options) {
|
|
|
|
encoding = "UTF-8"
|
2021-04-08 11:35:51 +02:00
|
|
|
if (JavaVersion.current().isJava9Compatible) {
|
|
|
|
release.set(8)
|
|
|
|
}; isFork = true
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
withType(net.fabricmc.loom.task.RemapJarTask::class) {
|
2021-04-08 12:54:54 +02:00
|
|
|
val shadowTask = getByName("shadowJar") as ShadowJar
|
|
|
|
dependsOn(shadowTask)
|
|
|
|
archiveBaseName.set(shadowTask.archiveBaseName)
|
|
|
|
input.set(shadowTask.archiveFile)
|
|
|
|
archiveClassifier.set(this@allprojects.name)
|
2021-04-08 14:13:37 +02:00
|
|
|
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
withType(ProcessResources::class) {
|
2021-04-08 17:30:41 +02:00
|
|
|
with(project(":common").sourceSets.main.get().resources.srcDirs) {
|
|
|
|
if (!sourceSets.main.get().resources.srcDirs.containsAll(this)) {
|
|
|
|
from(this)
|
|
|
|
}
|
|
|
|
}
|
2021-04-18 17:01:05 +02:00
|
|
|
val ModProperties = mapOf<String, String>(
|
|
|
|
"mod_version" to (rootProject.version as String),
|
|
|
|
"minecraft_version" to mcBase
|
|
|
|
)
|
|
|
|
inputs.properties(ModProperties)
|
|
|
|
filesNotMatching(listOf("*.png")) {
|
|
|
|
expand(ModProperties)
|
2021-04-08 15:48:07 +02:00
|
|
|
}
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-15 17:17:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks {
|
2021-04-17 15:22:57 +02:00
|
|
|
listOf(
|
|
|
|
file("remappedJars"),
|
|
|
|
file("shrinkedJars")
|
|
|
|
).forEach { if (it.exists()) clean.get().delete.add(it) }
|
2021-04-15 17:17:49 +02:00
|
|
|
val publishToModrinth = register<com.modrinth.minotaur.TaskModrinthUpload>("publishtoModrinth") {
|
|
|
|
val envStr: String? = System.getenv("MODRINTH")
|
|
|
|
onlyIf { envStr != null }
|
|
|
|
versionNumber = version.toString()
|
|
|
|
projectId = "OuGyGg6A"
|
|
|
|
token = envStr
|
2021-04-18 17:01:05 +02:00
|
|
|
addGameVersion(mcBase)
|
2021-04-15 17:17:49 +02:00
|
|
|
versionType = VersionType.ALPHA
|
|
|
|
detectLoaders = false
|
|
|
|
versionName = "${project.name} $versionNumber for Minecraft $gameVersions and higher"
|
2021-04-15 21:08:21 +02:00
|
|
|
fileTree("$rootDir/shrinkedJars/").files.forEach {
|
|
|
|
with(it.name) {
|
|
|
|
when {
|
|
|
|
contains("fabric") -> uploadFile = it
|
|
|
|
contains("forge") -> addFile(it)
|
2021-04-15 17:17:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addLoader("fabric"); addLoader("forge")
|
|
|
|
}
|
|
|
|
build.get().finalizedBy(publishToModrinth)
|
2021-04-15 10:59:29 +02:00
|
|
|
}
|