Skip to content

Commit

Permalink
build: add preprocessor to mod
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed May 2, 2024
1 parent 3c2c8a6 commit 88fa37d
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 49 deletions.
6 changes: 4 additions & 2 deletions events/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import org.apache.tools.ant.filters.FixCrLfFilter

plugins {
kotlin("jvm") version "1.9.22"
id("gg.essential.loom") version "1.3.12"
id("gg.essential.defaults") version "0.3.0"
id("gg.essential.loom") version "1.4.13"
id("gg.essential.defaults") version "0.4.1"
}

dependencies {
Expand All @@ -30,6 +30,8 @@ dependencies {
compileOnly("org.spongepowered:mixin:0.8.5")
}

group = "gg.skytils"

java.toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
Expand Down
24 changes: 24 additions & 0 deletions events/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Skytils - Hypixel Skyblock Quality of Life Mod
# Copyright (C) 2020-2023 Skytils
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
org.gradle.jvmargs=-Xmx2G -XX:+UseParallelGC
org.gradle.caching=true
kotlin.code.style=official
loom.platform=forge
minecraft.version=1.8.9

essential.defaults.loom=1
19 changes: 19 additions & 0 deletions events/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://maven.architectury.dev/")
maven("https://maven.fabricmc.net")
maven("https://maven.minecraftforge.net/")
maven("https://repo.essential.gg/repository/maven-releases/")
maven("https://jitpack.io") {
mavenContent {
includeGroupAndSubgroups("com.github")
}
}
}
}

rootProject.name = "events"
104 changes: 59 additions & 45 deletions mod/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Skytils - Hypixel Skyblock Quality of Life Mod
* Copyright (C) 2020-2023 Skytils
* Copyright (C) 2020-2024 Skytils
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand All @@ -23,18 +23,16 @@ import java.security.MessageDigest
plugins {
kotlin("jvm") version "1.9.22"
kotlin("plugin.serialization") version "1.9.22"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.github.johnrengelman.shadow")
id("net.kyori.blossom") version "2.1.0"
id("io.github.juuxel.loom-vineflower") version "1.11.0"
id("gg.essential.loom") version "1.3.12"
id("gg.essential.defaults") version "0.3.0"
id("gg.essential.multi-version")
id("gg.essential.defaults")
idea
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"

signing
}

version = "1.9.4"
group = "gg.skytils"

repositories {
Expand All @@ -49,35 +47,39 @@ repositories {
}
}

vineflower {
toolVersion.set("1.9.3")
}

loom {
silentMojangMappingsLicense()
runConfigs {
getByName("client") {
isIdeConfigGenerated = true
property("fml.coreMods.load", "gg.skytils.skytilsmod.tweaker.SkytilsLoadingPlugin")
property("elementa.dev", "true")
property("elementa.debug", "true")
property("elementa.invalid_usage", "warn")
property("asmhelper.verbose", "true")
property("mixin.debug.verbose", "true")
property("mixin.debug.export", "true")
property("mixin.dumpTargetOnFailure", "true")
property("fml.debugAccessTransformer", "true")
property("legacy.debugClassLoading", "true")
property("legacy.debugClassLoadingSave", "true")
property("legacy.debugClassLoadingFiner", "true")
programArgs("--tweakClass", "gg.skytils.skytilsmod.tweaker.SkytilsTweaker")
programArgs("--mixin", "mixins.skytils.json")
programArgs("--mixin", "mixins.skytils-events.json")

if (project.platform.isLegacyForge) {
property("fml.coreMods.load", "gg.skytils.skytilsmod.tweaker.SkytilsLoadingPlugin")
property("legacy.debugClassLoading", "true")
property("legacy.debugClassLoadingSave", "true")
property("legacy.debugClassLoadingFiner", "true")
programArgs("--tweakClass", "gg.skytils.skytilsmod.tweaker.SkytilsTweaker")
}
if (project.platform.isForge) {
property("fml.debugAccessTransformer", "true")

programArgs("--mixin", "mixins.skytils.json")
programArgs("--mixin", "mixins.skytils-events.json")
}
}
remove(getByName("server"))
}
forge {
mixinConfig("mixins.skytils.json", "mixins.skytils-events.json")
if (project.platform.isForge) {
forge {
mixinConfig("mixins.skytils.json", "mixins.skytils-events.json")
}
}
mixin {
defaultRefmapName = "mixins.skytils.refmap.json"
Expand All @@ -93,15 +95,19 @@ val shadowMeMod: Configuration by configurations.creating {
}

dependencies {
shadowMe("gg.essential:loader-launchwrapper:1.2.2")
implementation("gg.essential:essential-1.8.9-forge:16425+g3a090c5c88") {
if (platform.isForge) {
shadowMe("gg.essential:loader-launchwrapper:1.2.2")
} else {
runtimeOnly("gg.essential:loader-fabric:1.0.0")
}
implementation("gg.essential:essential-$platform:16425+g3a090c5c88") {
exclude(module = "asm")
exclude(module = "asm-commons")
exclude(module = "asm-tree")
exclude(module = "gson")
exclude(module = "vigilance")
}
shadowMe("com.github.Skytils.Vigilance:vigilance-1.8.9-forge:afb0909442") {
shadowMe("com.github.Skytils.Vigilance:vigilance-$platform:afb0909442") {
isTransitive = false
}

Expand Down Expand Up @@ -144,9 +150,8 @@ dependencies {
shadowMe("org.brotli:dec:0.1.2")
shadowMe("com.aayushatharva.brotli4j:brotli4j:1.16.0")

shadowMe(project(":events"))
shadowMe(project(":hypixel-api:types"))

shadowMe("gg.skytils:events")
shadowMe("gg.skytils.hypixel.types:types")

shadowMe(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5")!!)
annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
Expand All @@ -168,6 +173,9 @@ sourceSets {
}
}

val javaVersion = if (platform.isLegacyForge) JavaVersion.VERSION_1_8 else JavaVersion.VERSION_17


tasks {
processResources {
dependsOn(compileJava)
Expand Down Expand Up @@ -227,8 +235,7 @@ tasks {
"META-INF/proguard/**",
"META-INF/maven/**",
"META-INF/versions/**",
"META-INF/com.android.tools/**",
"fabric.mod.json"
"META-INF/com.android.tools/**"
)
mergeServiceFiles()
}
Expand All @@ -241,7 +248,7 @@ tasks {
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = javaVersion.toString()
freeCompilerArgs =
listOf(
/*"-opt-in=kotlin.RequiresOptIn", */
Expand All @@ -262,25 +269,30 @@ tasks {
)
)
}
register<Delete>("deleteClassloader") {
delete(
"${project.projectDir}/run/CLASSLOADER_TEMP",
"${project.projectDir}/run/CLASSLOADER_TEMP1",
"${project.projectDir}/run/CLASSLOADER_TEMP2",
"${project.projectDir}/run/CLASSLOADER_TEMP3",
"${project.projectDir}/run/CLASSLOADER_TEMP4",
"${project.projectDir}/run/CLASSLOADER_TEMP5",
"${project.projectDir}/run/CLASSLOADER_TEMP6",
"${project.projectDir}/run/CLASSLOADER_TEMP7",
"${project.projectDir}/run/CLASSLOADER_TEMP8",
"${project.projectDir}/run/CLASSLOADER_TEMP9",
"${project.projectDir}/run/CLASSLOADER_TEMP10"
)
if (platform.isLegacyForge) {
register<Delete>("deleteClassloader") {
delete(
"${project.projectDir}/run/CLASSLOADER_TEMP",
"${project.projectDir}/run/CLASSLOADER_TEMP1",
"${project.projectDir}/run/CLASSLOADER_TEMP2",
"${project.projectDir}/run/CLASSLOADER_TEMP3",
"${project.projectDir}/run/CLASSLOADER_TEMP4",
"${project.projectDir}/run/CLASSLOADER_TEMP5",
"${project.projectDir}/run/CLASSLOADER_TEMP6",
"${project.projectDir}/run/CLASSLOADER_TEMP7",
"${project.projectDir}/run/CLASSLOADER_TEMP8",
"${project.projectDir}/run/CLASSLOADER_TEMP9",
"${project.projectDir}/run/CLASSLOADER_TEMP10"
)
}
}
}

kotlin {
jvmToolchain(8)
jvmToolchain {
check(this is JavaToolchainSpec)
languageVersion.set(JavaLanguageVersion.of(javaVersion.asInt()))
}
}

signing {
Expand All @@ -301,4 +313,6 @@ fun DependencyHandler.ktor(module: String, version: String? = null, addSuffix: B

fun DependencyHandler.ktorClient(module: String, version: String? = null) = ktor("client-${module}", version)

fun DependencyHandler.ktorServer(module: String, version: String? = null) = ktor("server-${module}", version)
fun DependencyHandler.ktorServer(module: String, version: String? = null) = ktor("server-${module}", version)

fun JavaVersion.asInt() = this.ordinal + 1
34 changes: 34 additions & 0 deletions mod/root.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Skytils - Hypixel Skyblock Quality of Life Mod
* Copyright (C) 2020-2024 Skytils
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
kotlin("jvm") apply false
id("gg.essential.multi-version.root")
}

version = "2.0.0"

preprocess {
val forge10809 = createNode("1.8.9-forge", 10809, "mcp")
val forge11602 = createNode("1.16.2-forge", 11602, "mcp")
val fabric11602 = createNode("1.16.2-fabric", 11602, "yarn")
val fabric12004 = createNode("1.20.4-fabric", 12004, "yarn")

fabric12004.link(fabric11602)
fabric11602.link(forge11602)
forge11602.link(forge10809)
}
1 change: 1 addition & 0 deletions mod/versions/mainProject
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.8.9-forge
32 changes: 30 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,36 @@ pluginManagement {
}
}
}

plugins {
val kotlinVersion = "1.9.22"
kotlin("jvm") version kotlinVersion apply false
kotlin("plugin.serialization") version kotlinVersion apply false
id("gg.essential.multi-version.root") version "0.4.1"
id("gg.essential.loom") apply false
id("gg.essential.defaults") apply false
}
}

rootProject.name = "SkytilsMod"
include("events")
include("hypixel-api:types")
rootProject.buildFileName = "root.gradle.kts"

include(":mod")
project(":mod").apply {
projectDir = file("./mod")
buildFileName = "root.gradle.kts"
}
listOf(
"1.8.9-forge",
"1.16.2-forge",
"1.16.2-fabric",
"1.20.4-fabric",
).forEach { version ->
include(":mod:$version")
project(":mod:$version").apply {
projectDir = file("./mod/versions/$version")
buildFileName = "../../build.gradle.kts"
}
}
includeBuild("events")
includeBuild("hypixel-api/types")

0 comments on commit 88fa37d

Please sign in to comment.