Skip to content

Commit

Permalink
Merge branch 'twoconfig' of https://github.com/Polyfrost/PolyPatcher
Browse files Browse the repository at this point in the history
…into twoconfig
  • Loading branch information
Wyvest committed Jan 6, 2025
2 parents a49c5e3 + 8c4f342 commit 6627e9e
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 57 deletions.
41 changes: 28 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
name: build
# Build Workflow

name: Build with Gradle

on:
push:
pull_request:
workflow_dispatch:
push:

concurrency:
group: ${{ github.head_ref || format('{0}-{1}', github.ref, github.run_number) }}
cancel-in-progress: true

jobs:
build:
name: "Build"
runs-on: "ubuntu-latest"
name: Build

steps:
- uses: actions/checkout@v4
runs-on: ubuntu-latest

- uses: gradle/wrapper-validation-action@v3
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 10

- uses: actions/setup-java@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
java-version: 21
distribution: temurin

- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
**/loom-cache
key: ${{ runner.os }}-gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
**/prebundled-jars
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-v2-
${{ runner.os }}-gradle-
- name: Chmod Gradle
run: chmod +x ./gradlew

- run: ./gradlew --no-daemon build
- name: Build
run: ./gradlew build --no-daemon
54 changes: 22 additions & 32 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@file:Suppress("UnstableApiUsage", "PropertyName")

import dev.deftu.gradle.utils.GameSide
import dev.deftu.gradle.utils.includeOrShade
import dev.deftu.gradle.utils.MinecraftVersion

plugins {
java
Expand All @@ -11,12 +11,11 @@ plugins {
id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources.
id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files.
id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those!
id("dev.deftu.gradle.tools.ducks") // Creates a ducks source set, which allows us to use theoretical classes which may not exist at runtime (such as things which are in other mods).
id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you.
id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth.
}

val accessTransformerName = "patcher1${mcData.version.minor}_at.cfg"

toolkitLoomHelper {
useOneConfig {
version = "1.0.0-alpha.49"
Expand All @@ -31,8 +30,6 @@ toolkitLoomHelper {
+module
}
}
useDevAuth("1.2.1")
useMixinExtras("0.4.1")

// Turns off the server-side run configs, as we're building a client-sided mod.
disableRunConfigs(GameSide.SERVER)
Expand All @@ -45,73 +42,66 @@ toolkitLoomHelper {
if (mcData.isForge) {
// Configures the Mixin tweaker if we are building for Forge.
useForgeMixin(modData.id)

useProperty("patcher.debugBytecode", "true", GameSide.CLIENT)
useProperty("fml.coreMods.load", "club.sk1er.patcher.tweaker.PatcherTweaker", GameSide.CLIENT)
}
}

val accessTransformerName = "patcher1${mcData.version.minor}_at.cfg"

if (mcData.isForge) {
loom {
forge {
accessTransformer(rootProject.file("src/main/resources/META-INF/$accessTransformerName"))
accessTransformer(rootProject.file("src/main/resources/$accessTransformerName"))
}
}
}

// Configures the output directory for when building from the `src/resources` directory.
sourceSets {
val dummy by creating
main {
dummy.compileClasspath += compileClasspath
compileClasspath += dummy.output
output.setResourcesDir(java.classesDirectory)
}
}

// Configures the libraries/dependencies for your mod.
dependencies {
modImplementation(includeOrShade("org.polyfrost:elementa-$mcData:562") {
modImplementation(shade("org.polyfrost:elementa-$mcData:562") {
isTransitive = false
})

implementation(includeOrShade("com.github.ben-manes.caffeine:caffeine:2.9.3")!!)
implementation(shade("com.github.ben-manes.caffeine:caffeine:2.9.3")!!)

implementation(includeOrShade("com.github.char:Koffee:88ba1b0") {
implementation(shade("com.github.videogame-hacker:Koffee:88ba1b0") {
isTransitive = false
})

if (mcData.version.minor < 12) {
implementation(includeOrShade("it.unimi.dsi:fastutil:8.5.13")!!)
implementation(shade("it.unimi.dsi:fastutil:8.5.13")!!)
}

// Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
if (mcData.isFabric) {
runtimeOnly("include"(rootProject.project(":fake-mod"))!!)
implementation(includeOrShade("com.github.Chocohead:Fabric-ASM:2.3")!!)
if (mcData.isLegacyFabric) {
// 1.8.9 - 1.13
modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}")
} else {
// 1.16.5+
modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}")
}
}
}

tasks {
compileKotlin {
compilerOptions {
optIn.add("kotlin.RequiresOptIn")
freeCompilerArgs.add("-Xno-param-assertions")
freeCompilerArgs.add("-Xjvm-default=all-compatibility")
kotlinOptions {
freeCompilerArgs += listOf("-Xopt-in=kotlin.RequiresOptIn", "-Xno-param-assertions", "-Xjvm-default=all-compatibility")
}
}

jar {
// Sets the jar manifest attributes.
if (mcData.isLegacyForge) {
manifest.attributes += mapOf(
"FMLCorePlugin" to "club.sk1er.patcher.tweaker.PatcherTweaker",
"FMLCorePluginContainsFMLMod" to "Yes, yes it does",
"FMLAT" to accessTransformerName,
"Main-Class" to "club.sk1er.container.ContainerMessage"
)
}
}

processResources {
exclude("**/*.at.cfg")
exclude("patcher18_at.cfg")
exclude("patcher112_at.cfg")
}
}
12 changes: 6 additions & 6 deletions root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ preprocess {
// "1.8.9-forge"(10809, "srg")
// }

"1.12.2-forge"(11202, "srg") {
"1.12.2-fabric"(11202, "yarn") {
"1.8.9-fabric"(10809, "yarn", file("versions/1.12.2-1.8.9.txt")) {
"1.8.9-forge"(10809, "srg")
"1.12.2-fabric"(11202, "yarn") {
"1.12.2-forge"(11202, "srg") {
"1.8.9-forge"(10809, "srg", file("versions/1.12.2-1.8.9.txt")) {
"1.8.9-fabric"(10809, "yarn")
}
}
}

strictExtraMappings.set(true)
}
}
10 changes: 4 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pluginManagement {

plugins {
kotlin("jvm") version("2.0.0")
id("dev.deftu.gradle.multiversion-root") version("2.17.0")
id("dev.deftu.gradle.multiversion-root") version("2.18.2")
}
}

Expand All @@ -35,21 +35,19 @@ val projectName: String = extra["mod.name"]?.toString()
rootProject.name = projectName
rootProject.buildFileName = "root.gradle.kts"

include(":fake-mod")

// Adds all of our build target versions to the classpath if we need to add version-specific code.
// Update this list if you want to remove/add a version and/or mod loader.
// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc)
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` FILE WITH THE NEW VERSION(S).
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S).
listOf(
"1.8.9-forge",
"1.8.9-fabric",
"1.12.2-fabric",
"1.12.2-forge",
"1.12.2-fabric"
).forEach { version ->
include(":$version")
project(":$version").apply {
projectDir = file("versions/$version")
buildFileName = "../../build.gradle.kts"
}
}
}

0 comments on commit 6627e9e

Please sign in to comment.