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-10-26 12:04:34 +02:00
|
|
|
import net.fabricmc.loom.LoomGradleExtension
|
|
|
|
import net.fabricmc.loom.LoomGradlePlugin
|
2021-04-17 14:54:24 +02:00
|
|
|
|
2021-04-14 13:56:20 +02:00
|
|
|
buildscript {
|
|
|
|
dependencies {
|
2021-08-06 13:54:24 +02:00
|
|
|
classpath("com.guardsquare:proguard-gradle:[7.1.0-beta3, 7.3[") {
|
2021-04-14 13:56:20 +02:00
|
|
|
exclude("com.android.tools.build")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-08 10:18:46 +02:00
|
|
|
plugins {
|
2022-02-18 13:09:08 +01:00
|
|
|
kotlin("jvm") version "1.6.20-M1"
|
|
|
|
kotlin("plugin.serialization") version "1.6.20-M1"
|
|
|
|
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
|
2021-10-28 14:08:11 +02:00
|
|
|
id("architectury-plugin") version "[3.4.124, 3.5["
|
2021-06-21 17:54:25 +02:00
|
|
|
id("dev.architectury.loom") version (
|
2021-12-10 19:47:17 +01:00
|
|
|
JavaVersion.current().let { version ->
|
|
|
|
if (version >= JavaVersion.VERSION_16)
|
|
|
|
"[0.9.0.153, ${if (version.isCompatibleWith(JavaVersion.VERSION_17)) "0.11.1" else "0.10.1"}["
|
|
|
|
else "[0.7.3.152, 0.7.3.201["
|
|
|
|
}
|
2021-06-21 17:54:25 +02:00
|
|
|
) apply false
|
2022-02-18 13:09:08 +01:00
|
|
|
id("com.github.ben-manes.versions") version "0.42.0"
|
|
|
|
id("net.kyori.indra.git") version "2.1.1"
|
|
|
|
id("org.cqfn.diktat.diktat-gradle-plugin") version "1.0.3"
|
2021-05-08 17:56:05 +02:00
|
|
|
id("com.modrinth.minotaur") version "1.2.1"
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
group = "fr.username404"
|
2021-07-19 15:32:09 +02:00
|
|
|
version = "0.3.2"
|
2021-04-08 10:18:46 +02:00
|
|
|
val groupAndName = "${rootProject.group}.${rootProject.name.toLowerCase()}"
|
|
|
|
|
2021-05-27 18:45:26 +02:00
|
|
|
val javaVer: String = "8"
|
|
|
|
val kotlinVer: String by rootProject
|
2021-11-07 12:07:36 +01:00
|
|
|
val kotlinSplitVersion = kotlinVer.split('.')
|
2021-06-01 12:37:19 +02:00
|
|
|
val serializationVer: String by rootProject
|
2021-08-03 22:30:25 +02:00
|
|
|
val mcBase: String = (rootProject.property("minecraft") as String).also {
|
|
|
|
architectury { minecraft = it }
|
|
|
|
}.substring(0..3)
|
2021-04-28 11:33:41 +02:00
|
|
|
val kotlinX: String = "org.jetbrains.kotlinx"
|
2021-05-27 18:45:26 +02:00
|
|
|
|
2021-04-08 10:18:46 +02:00
|
|
|
subprojects {
|
2021-04-27 18:56:09 +02:00
|
|
|
group = rootProject.group.toString()
|
2021-06-19 12:24:22 +02:00
|
|
|
apply(plugin = "org.cqfn.diktat.diktat-gradle-plugin")
|
|
|
|
diktat {
|
2021-12-10 19:47:17 +01:00
|
|
|
inputs { include("src/**/*.kt") }
|
2021-06-19 12:24:22 +02:00
|
|
|
diktatConfigFile = file("$rootDir/Formatting.yml")
|
|
|
|
ignoreFailures = true
|
|
|
|
}
|
2021-04-27 18:56:09 +02:00
|
|
|
lateinit var mappingsDep: Dependency
|
2021-05-04 22:07:06 +02:00
|
|
|
apply(plugin = "dev.architectury.loom")
|
2021-06-01 12:37:19 +02:00
|
|
|
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
|
2021-10-26 12:04:34 +02:00
|
|
|
extensions.configure<LoomGradleExtension>("loom") {
|
2021-07-15 15:09:56 +02:00
|
|
|
mappingsDep = layered {
|
2021-10-26 12:04:34 +02:00
|
|
|
officialMojangMappings().parchment("org.parchmentmc.data:parchment-${rootProject.architectury.minecraft}:2021.10.17")
|
2021-07-15 15:09:56 +02:00
|
|
|
}
|
2021-05-19 21:55:49 +02:00
|
|
|
silentMojangMappingsLicense()
|
2021-10-26 12:04:34 +02:00
|
|
|
val refmap = "snowygui-${project.name}-refmap.json"
|
2021-10-27 14:20:25 +02:00
|
|
|
// The following is used to make this buildscript compatible with architectury-loom 0.7.3, 0.9.X, 0.10.X and higher versions
|
2021-10-26 12:04:34 +02:00
|
|
|
with(javaClass) {
|
2021-10-27 14:20:25 +02:00
|
|
|
val loomMajorRelease = LoomGradlePlugin.LOOM_VERSION.run {
|
2021-10-26 12:04:34 +02:00
|
|
|
val numberPos = indexOf('.') + 1
|
|
|
|
substring(numberPos, indexOf('.', numberPos))
|
2021-10-27 14:20:25 +02:00
|
|
|
}.toShort()
|
|
|
|
if (loomMajorRelease < 10) {
|
|
|
|
if (loomMajorRelease < 9) getField("refmapName").set(this@configure, refmap)
|
|
|
|
else getMethod("setRefmapName", String::class.java).invoke(this@configure, refmap)
|
2021-10-27 12:25:46 +02:00
|
|
|
getMethod("mixinConfig", Array<String>::class.java).invoke(this@configure, arrayOf("snowygui-${project.name}.mixins.json"))
|
2021-10-26 12:04:34 +02:00
|
|
|
} else {
|
|
|
|
getDeclaredMethod("getMixin").invoke(this@configure).run {
|
|
|
|
javaClass.getDeclaredMethod("getDefaultRefmapName").invoke(this).let { refmapProperty ->
|
|
|
|
refmapProperty.javaClass.getDeclaredMethod("set", Any::class.java).invoke(refmapProperty, refmap)
|
|
|
|
}
|
2022-02-18 12:55:02 +01:00
|
|
|
if (isForge) {
|
|
|
|
this@with.getDeclaredMethod("getForge").invoke(this@configure).let { forgeObject ->
|
|
|
|
forgeObject.javaClass.getMethod("mixinConfigs", Array<String>::class.java).invoke(forgeObject, (javaClass.getMethod("getMixinSourceSets").invoke(this) as Collection<SourceSet>).map { it.name.apply { println(this) } }.toTypedArray())
|
|
|
|
}
|
|
|
|
}
|
2021-10-26 12:04:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 21:55:49 +02:00
|
|
|
}
|
2021-04-08 10:18:46 +02:00
|
|
|
apply(plugin = "com.github.johnrengelman.shadow")
|
2021-04-08 12:57:08 +02:00
|
|
|
val shadowC by configurations.creating
|
2021-10-26 12:04:34 +02:00
|
|
|
repositories {
|
|
|
|
maven(url = "https://jitpack.io"); mavenCentral()
|
|
|
|
maven(url = "https://maven.parchmentmc.org")
|
|
|
|
}
|
2021-05-19 21:55:49 +02:00
|
|
|
dependencies {
|
2021-06-07 21:41:12 +02:00
|
|
|
implementation("$kotlinX:kotlinx-coroutines-jdk8:${rootProject.property("kotlin_coroutines_version")}")
|
2021-06-01 12:37:19 +02:00
|
|
|
implementation("$kotlinX:kotlinx-serialization-core:$serializationVer")
|
|
|
|
implementation("$kotlinX:kotlinx-serialization-json:$serializationVer")
|
2021-05-19 21:55:49 +02:00
|
|
|
listOf(
|
|
|
|
"com.typesafe:config:1.4.1",
|
|
|
|
"io.github.config4k:config4k:0.4.2",
|
2021-05-27 20:00:35 +02:00
|
|
|
"com.github.Vatuu:discord-rpc:1.6.2"
|
|
|
|
).forEach { implementation(it); shadowC(it) { isTransitive = false; exclude("com.sun.jna") } }
|
2021-05-19 21:55:49 +02:00
|
|
|
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
|
|
|
|
"mappings"(mappingsDep)
|
|
|
|
}
|
2021-04-14 13:56:20 +02:00
|
|
|
tasks {
|
2021-05-19 21:55:49 +02:00
|
|
|
apply(plugin = "net.kyori.indra.git")
|
|
|
|
withType(Jar::class) {
|
|
|
|
from("$rootDir/LICENSE.txt")
|
|
|
|
indraGit.applyVcsInformationToManifest(manifest)
|
2021-06-01 17:03:07 +02:00
|
|
|
archiveBaseName.set(rootProject.name)
|
2021-05-19 21:55:49 +02:00
|
|
|
}
|
|
|
|
withType(ShadowJar::class) {
|
|
|
|
this.configurations = listOf(shadowC)
|
|
|
|
relocate("com.typesafe.config", "${rootProject.group}.typesafe.config")
|
|
|
|
relocate("io.github.config4k", "${rootProject.group}.config4k")
|
|
|
|
relocate("net.arikia.dev.drpc", "${rootProject.group}.drpc")
|
2021-05-27 20:00:35 +02:00
|
|
|
exclude("com/sun/jna/**/*") // The shadowed JNA from discord-rpc isn't needed since it is already available at runtime
|
2021-05-19 21:55:49 +02:00
|
|
|
exclude("**/*.kotlin_metadata")
|
|
|
|
exclude("**/*.kotlin_builtins")
|
|
|
|
exclude("META-INF/maven/**/*")
|
2021-05-20 13:22:37 +02:00
|
|
|
archiveClassifier.set("shadow-${this@subprojects.name}")
|
2021-05-19 21:55:49 +02:00
|
|
|
}
|
|
|
|
val shadowJar = getByName("shadowJar") as ShadowJar
|
2021-04-27 18:56:09 +02:00
|
|
|
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"
|
2021-05-19 21:55:49 +02:00
|
|
|
injars(shadowJar)
|
2021-05-20 13:59:19 +02:00
|
|
|
outjars("$buildDir/shrinkedJar/${shadowJar.outputs.files.singleFile.name}")
|
2021-04-27 18:56:09 +02:00
|
|
|
keep("class $group.snowygui.mixins.* { * ; }")
|
2021-07-16 16:47:17 +02:00
|
|
|
keep("class $group.snowygui.fabric.FabricInit")
|
|
|
|
keep("class $group.snowygui.fabric.ModMenuConf")
|
|
|
|
keep("class $group.snowygui.forge.ForgeInit")
|
2021-04-27 20:40:12 +02:00
|
|
|
keepnames("class $group.snowygui.Snowy")
|
2021-05-20 17:46:28 +02:00
|
|
|
keepnames("class $group.snowygui.gui.feature.Macro { <fields>; }")
|
2021-05-18 22:14:35 +02:00
|
|
|
keep("class $group.snowygui.gui.feature.* { public static *** INSTANCE; }")
|
2021-04-27 18:56:09 +02:00
|
|
|
keepclassmembers("class $group.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-27 18:56:09 +02:00
|
|
|
flattenpackagehierarchy("$group.snowygui")
|
2021-04-27 20:40:12 +02:00
|
|
|
allowaccessmodification()
|
2021-04-14 18:05:20 +02:00
|
|
|
adaptclassstrings()
|
2021-05-18 22:14:35 +02:00
|
|
|
"$group.**".also { dontnote(it); dontwarn(it) }
|
|
|
|
|
2021-06-01 12:37:19 +02:00
|
|
|
// kotlinx-serialization related configuration:
|
|
|
|
keep(mapOf("includedescriptorclasses" to true), "class $group.snowygui.**$\$serializer { * ; }")
|
|
|
|
keepclassmembers("class $group.snowygui.** { *** Companion; }")
|
|
|
|
keepclasseswithmembers("class $group.snowygui.** { kotlinx.serialization.KSerializer serializer(...); }")
|
|
|
|
|
2021-05-27 20:00:35 +02:00
|
|
|
// Required for discord-rpc
|
2021-05-28 07:10:14 +02:00
|
|
|
keepclassmembers("class $group.drpc.** { public * ; }")
|
2021-05-27 20:00:35 +02:00
|
|
|
|
2021-05-19 21:55:49 +02:00
|
|
|
doFirst {
|
2021-05-20 13:59:19 +02:00
|
|
|
libraryjars(configurations.compileClasspath.get().filterNot { file ->
|
2021-05-19 21:55:49 +02:00
|
|
|
shadowC.contains(file)
|
|
|
|
})
|
|
|
|
}
|
2021-05-21 12:40:03 +02:00
|
|
|
val homeDir = System.getProperty("java.home") as String
|
2021-04-27 10:15:11 +02:00
|
|
|
if (JavaVersion.current().isJava9Compatible) {
|
2021-05-19 15:56:10 +02:00
|
|
|
val jmodsLocations = setOf(
|
|
|
|
"$homeDir/jmods/java.base.jmod",
|
2021-05-19 19:41:13 +02:00
|
|
|
"$homeDir/jmods/java.desktop.jmod",
|
2021-05-19 15:56:10 +02:00
|
|
|
"$homeDir/jmods/java.instrument.jmod"
|
|
|
|
)
|
|
|
|
if (jmodsLocations.all { !file(it).exists() }) throw GradleException("Jmods appear to be missing, please make sure that jmods are installed.")
|
|
|
|
else jmodsLocations.forEach {
|
|
|
|
libraryjars(it)
|
|
|
|
}
|
2021-04-27 02:34:31 +02:00
|
|
|
} else libraryjars("$homeDir/lib/rt.jar")
|
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()
|
|
|
|
optimizationpasses(4)
|
|
|
|
overloadaggressively()
|
2021-04-27 18:39:11 +02:00
|
|
|
mergeinterfacesaggressively()
|
2021-04-14 13:56:20 +02:00
|
|
|
}
|
2021-05-19 21:55:49 +02:00
|
|
|
withType(net.fabricmc.loom.task.RemapJarTask::class) {
|
|
|
|
dependsOn(shrinkJar)
|
|
|
|
val shrinkedJar = shrinkJar.get().outJarFileCollection.singleFile
|
|
|
|
archiveBaseName.set(shadowJar.archiveBaseName)
|
2021-06-01 17:03:07 +02:00
|
|
|
archiveVersion.set("[${rootProject.version}+$mcBase]")
|
2021-05-19 21:55:49 +02:00
|
|
|
archiveClassifier.set(this@subprojects.name)
|
|
|
|
input.set(shrinkedJar)
|
|
|
|
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
|
|
|
|
}
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
2021-05-03 14:37:12 +02:00
|
|
|
/** configurations.all {
|
|
|
|
resolutionStrategy {
|
|
|
|
eachDependency {
|
|
|
|
if (requested.group == "org.jetbrains.kotlin" && requested.name.contains("stdlib") && (requested.version != kotlinVer)) {
|
|
|
|
useVersion(kotlinVer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
**/
|
2021-04-08 10:18:46 +02:00
|
|
|
apply(plugin = "java")
|
2021-05-18 22:14:35 +02:00
|
|
|
apply(plugin = "org.jetbrains.kotlin.jvm")
|
2021-04-08 10:18:46 +02:00
|
|
|
apply(plugin = "architectury-plugin")
|
2021-04-20 15:03:40 +02:00
|
|
|
dependencies {
|
2021-05-03 14:34:49 +02:00
|
|
|
implementation(kotlin("stdlib-jdk8", kotlinVer))
|
2021-05-14 23:20:41 +02:00
|
|
|
implementation(kotlin("reflect", kotlinVer))
|
2021-12-10 19:56:15 +01:00
|
|
|
annotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:0.4.2")
|
2021-04-20 15:03:40 +02:00
|
|
|
}
|
2021-04-08 10:18:46 +02:00
|
|
|
tasks {
|
|
|
|
withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
|
|
|
|
with(kotlinOptions) {
|
2021-06-29 16:42:08 +02:00
|
|
|
// https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt
|
2021-06-26 11:09:43 +02:00
|
|
|
freeCompilerArgs = listOf(
|
2021-10-27 13:52:04 +02:00
|
|
|
"-Xjvm-default=all", "-Xlambdas=indy", "-Xtype-enhancement-improvements-strict-mode",
|
2021-06-29 16:42:08 +02:00
|
|
|
"-Xmultifile-parts-inherit",
|
|
|
|
"-Xparallel-backend-threads=0", "-Xno-param-assertions", "-Xno-call-assertions",
|
|
|
|
"-Xopt-in=kotlin.RequiresOptIn", "-Xextended-compiler-checks", "-Xassertions=jvm", "-progressive"
|
2021-06-26 11:09:43 +02:00
|
|
|
)
|
2021-06-05 16:57:28 +02:00
|
|
|
jvmTarget = if (javaVer.toInt() < 9) "1.$javaVer" else javaVer
|
2021-11-07 12:07:36 +01:00
|
|
|
languageVersion = (kotlinSplitVersion[0] + '.' + (kotlinSplitVersion[1].toShort() + 1).toString())
|
|
|
|
apiVersion = "${kotlinSplitVersion[0]}.${kotlinSplitVersion[1]}"
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
withType(JavaCompile::class) {
|
|
|
|
with(options) {
|
|
|
|
encoding = "UTF-8"
|
2021-05-15 12:49:00 +02:00
|
|
|
isFork = true
|
2021-06-01 11:26:34 +02:00
|
|
|
release.set(javaVer.toInt())
|
2021-10-27 23:58:05 +02:00
|
|
|
sourceCompatibility = "11"
|
2021-06-02 12:11:43 +02:00
|
|
|
targetCompatibility = javaVer
|
2021-10-27 23:58:05 +02:00
|
|
|
compilerArgs.add("-Xplugin:jabel")
|
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-21 16:31:32 +02:00
|
|
|
val modProperties = mapOf(
|
2021-04-18 17:01:05 +02:00
|
|
|
"mod_version" to (rootProject.version as String),
|
2021-04-27 18:56:09 +02:00
|
|
|
"minecraft_version" to mcBase,
|
2021-05-12 17:10:14 +02:00
|
|
|
"java_version" to javaVer,
|
2021-05-07 10:33:35 +02:00
|
|
|
"mod_group" to this@allprojects.group,
|
|
|
|
"fabric_kotlin" to rootProject.property("fabric_language_kotlin"),
|
2021-05-29 22:11:05 +02:00
|
|
|
"kotlinforforge" to rootProject.property("kotlinforforge"),
|
|
|
|
"clothconfig" to rootProject.property("clothconfig_version")
|
2021-04-18 17:01:05 +02:00
|
|
|
)
|
2021-04-21 16:31:32 +02:00
|
|
|
inputs.properties(modProperties)
|
2021-04-18 17:01:05 +02:00
|
|
|
filesNotMatching(listOf("*.png")) {
|
2021-04-21 16:31:32 +02:00
|
|
|
expand(modProperties)
|
2021-04-08 15:48:07 +02:00
|
|
|
}
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
2021-04-27 16:41:23 +02:00
|
|
|
check {
|
|
|
|
setDependsOn(
|
|
|
|
dependsOn.minus(test)
|
|
|
|
)
|
|
|
|
}
|
2021-04-08 10:18:46 +02:00
|
|
|
}
|
2021-04-15 17:17:49 +02:00
|
|
|
}
|
2021-12-10 19:56:15 +01:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
2021-04-15 17:17:49 +02:00
|
|
|
|
|
|
|
tasks {
|
2021-05-19 21:55:49 +02:00
|
|
|
file("remappedJars").let { 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-05-30 21:17:47 +02:00
|
|
|
addDependency("Bxm9xbNJ", com.modrinth.minotaur.request.Dependency.DependencyType.REQUIRED) // Kotlinforforge dependency
|
2021-04-15 17:17:49 +02:00
|
|
|
versionType = VersionType.ALPHA
|
|
|
|
detectLoaders = false
|
|
|
|
versionName = "${project.name} $versionNumber for Minecraft $gameVersions and higher"
|
2021-05-19 21:55:49 +02:00
|
|
|
fileTree("$rootDir/remappedJars/").files.forEach {
|
2021-04-15 21:08:21 +02:00
|
|
|
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-05-15 01:48:12 +02:00
|
|
|
}
|