SnowyGUI/build.gradle.kts

191 lines
7.7 KiB
Plaintext
Raw Normal View History

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.modrinth.minotaur.request.VersionType
buildscript {
dependencies {
classpath("com.guardsquare:proguard-gradle:[7.1.0-beta3, 7.2[") {
exclude("com.android.tools.build")
}
}
}
2021-04-08 10:18:46 +02:00
plugins {
2021-04-27 01:17:46 +02:00
kotlin("jvm") version "1.5.0"
2021-04-08 10:18:46 +02:00
id("com.github.johnrengelman.shadow") version "6.1.0" apply false
id("architectury-plugin") version "[3.0.100, 3.2["
id("forgified-fabric-loom") version "[0.7.0.95, 0.7.1[" apply false
2021-04-17 21:06:29 +02:00
id("com.github.ben-manes.versions") version "0.38.0"
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
}
val kotlinX: String = "org.jetbrains.kotlinx"
2021-04-08 10:18:46 +02:00
subprojects {
group = rootProject.group.toString()
lateinit var mappingsDep: Dependency
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")
val shadowC by configurations.creating
tasks {
withType(ShadowJar::class) { this.configurations = listOf(shadowC) }
val shrinkJar = register("shrinkJar", proguard.gradle.ProGuardTask::class) { group = this@subprojects.group as String
2021-04-14 20:36:05 +02:00
val dictionariesDir = "$rootDir/obfuscation"
val remapJar = this@tasks.getByName("remapJar")
injars(remapJar)
outjars("$rootDir/shrinkedJars/${remapJar.outputs.files.singleFile.name}")
keep("class $group.snowygui.mixins.* { * ; }")
keep("class $group.snowygui.fabric.**")
keep("class $group.snowygui.forge.**")
2021-04-27 20:40:12 +02:00
keepnames("class $group.snowygui.Snowy")
keepclassmembers("class $group.snowygui.** { public protected <methods>; }")
keepattributes("*Annotation*, Signature, InnerClasses, EnclosingMethod, MethodParameters, Synthetic, Exceptions")
2021-04-14 20:36:05 +02:00
obfuscationdictionary("$dictionariesDir/dictionary.txt")
classobfuscationdictionary("$dictionariesDir/classdictionary.txt")
packageobfuscationdictionary("$dictionariesDir/packagesdictionary.txt")
flattenpackagehierarchy("$group.snowygui")
2021-04-27 20:40:12 +02:00
allowaccessmodification()
adaptclassstrings()
"$group.**".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.**")
2021-04-27 02:25:08 +02:00
val homeDir = System.getProperty("java.home") as String
2021-05-03 12:28:12 +02:00
libraryjars(configurations.compileClasspath)
if (JavaVersion.current().isJava9Compatible) {
libraryjars("$homeDir/jmods/java.base.jmod")
} else libraryjars("$homeDir/lib/rt.jar")
// Note: dontpreverify() should NOT be used, it will cause errors at runtime
useuniqueclassmembernames()
optimizationpasses(4)
overloadaggressively()
mergeinterfacesaggressively()
}
if (this@subprojects.name != "common") build.get().finalizedBy(shrinkJar)
}
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 {
implementation("$kotlinX:kotlinx-coroutines-core:1.4.0")
listOf(
"$kotlinX:kotlinx-datetime:0.2.0",
"com.typesafe:config:1.4.1",
"io.github.config4k:config4k:0.4.2"
).forEach { implementation(it); shadowC(it) { isTransitive = false } }
2021-04-08 10:18:46 +02:00
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
"mappings"(mappingsDep)
2021-04-08 10:18:46 +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")
2021-04-20 15:03:40 +02:00
dependencies {
implementation(kotlin("stdlib-jdk8", rootProject.property("kotlin_stdlib_version").toString() + ".0"))
2021-04-20 15:03:40 +02:00
}
2021-04-08 10:18:46 +02:00
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 {
withType(ShadowJar::class) {
2021-05-03 12:28:12 +02:00
relocate("kotlinx-datetime", "${rootProject.group}.kotlinx-datetime")
relocate("org.jetbrains", "${rootProject.group}.jetbrainslibs")
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/**/*")
archiveClassifier.set("shadow")
2021-04-08 10:18:46 +02:00
}
withType(Jar::class) {
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) {
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xlambdas=indy")
2021-04-08 10:18:46 +02:00
jvmTarget = "1.8"
languageVersion = "1.5"
apiVersion = rootProject.property("kotlin_stdlib_version").toString()
2021-04-08 10:18:46 +02:00
}
}
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) {
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"))
2021-04-08 10:18:46 +02:00
}
withType(ProcessResources::class) {
with(project(":common").sourceSets.main.get().resources.srcDirs) {
if (!sourceSets.main.get().resources.srcDirs.containsAll(this)) {
from(this)
}
}
2021-04-21 16:31:32 +02:00
val modProperties = mapOf(
"mod_version" to (rootProject.version as String),
"minecraft_version" to mcBase,
"mod_group" to this@allprojects.group
)
2021-04-21 16:31:32 +02:00
inputs.properties(modProperties)
filesNotMatching(listOf("*.png")) {
2021-04-21 16:31:32 +02:00
expand(modProperties)
}
2021-04-08 10:18:46 +02:00
}
check {
setDependsOn(
dependsOn.minus(test)
)
}
2021-04-08 10:18:46 +02:00
}
}
tasks {
listOf(
file("remappedJars"),
file("shrinkedJars")
).forEach { if (it.exists()) clean.get().delete.add(it) }
val publishToModrinth = register<com.modrinth.minotaur.TaskModrinthUpload>("publishtoModrinth") {
val envStr: String? = System.getenv("MODRINTH")
onlyIf { envStr != null }
versionNumber = version.toString()
projectId = "OuGyGg6A"
token = envStr
addGameVersion(mcBase)
versionType = VersionType.ALPHA
detectLoaders = false
versionName = "${project.name} $versionNumber for Minecraft $gameVersions and higher"
fileTree("$rootDir/shrinkedJars/").files.forEach {
with(it.name) {
when {
contains("fabric") -> uploadFile = it
contains("forge") -> addFile(it)
}
}
}
addLoader("fabric"); addLoader("forge")
}
build.get().finalizedBy(publishToModrinth)
}