Skip to content

Commit

Permalink
update PGT
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jan 10, 2024
1 parent 9a51d62 commit da0dc5d
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 107 deletions.
32 changes: 0 additions & 32 deletions Jenkinsfile

This file was deleted.

240 changes: 188 additions & 52 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,91 +1,227 @@
import cc.polyfrost.gradle.util.noServerRunConfigs
@file:Suppress("UnstableApiUsage", "PropertyName")

import org.polyfrost.gradle.util.noServerRunConfigs
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit
// which we use to prepare the environment.
plugins {
kotlin("jvm")
id("cc.polyfrost.multi-version")
id("cc.polyfrost.defaults")
id("org.polyfrost.multi-version")
id("org.polyfrost.defaults.repo")
id("org.polyfrost.defaults.java")
id("org.polyfrost.defaults.loom")
id("com.github.johnrengelman.shadow")
id("net.kyori.blossom") version "1.3.1"
id("signing")
java
}

val modGroup: String by project
val modBaseName: String by project
group = modGroup
base.archivesName.set("$modBaseName-${platform.mcVersionStr}")
// Gets the mod name, version and id from the `gradle.properties` file.
val mod_name: String by project
val mod_version: String by project
val mod_id: String by project
val mod_archives_name: String by project

val accessTransformerName = "patcher1${platform.mcMinor}_at.cfg"

// Sets up the variables for when we preprocess to other Minecraft versions.
preprocess {
vars.put("MODERN", if (project.platform.mcMinor >= 16) 1 else 0)
}

// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`.
blossom {
replaceToken("@VER@", mod_version)
replaceToken("@NAME@", mod_name)
replaceToken("@ID@", mod_id)
}

// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver!
version = mod_version
// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username.
// e.g. com.github.<your username> or com.<your domain>
group = "club.sk1er"

// Sets the name of the output jar (the one you put in your mods folder and send to other people)
// It outputs all versions of the mod into the `build` directory.
base {
archivesName.set("$mod_archives_name-$platform")
}

// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment.
loom {
// Removes the server configs from IntelliJ IDEA, leaving only client runs.
// If you're developing a server-side mod, you can remove this line.
noServerRunConfigs()
mixin {
defaultRefmapName.set("patcher.mixins.refmap.json")

// Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org)
if (project.platform.isLegacyForge) {
runConfigs {
"client" {
property("patcher.debugBytecode", "true")
property("mixin.debug.verbose", "true")
property("mixin.debug.export", "true")
property("mixin.dumpTargetOnFailure", "true")
property("fml.coreMods.load", "club.sk1er.patcher.tweaker.PatcherTweaker")
programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
property("mixin.debug.export", "true")
}
}
}
// Configures the mixins if we are building for forge, useful for when we are dealing with cross-platform projects.
if (project.platform.isForge) {
forge {
accessTransformer(rootProject.file("src/main/resources/$accessTransformerName"))
mixinConfig("mixins.${mod_id}.json")
}
}
launchConfigs {
getByName("client") {
property("patcher.debugBytecode", "true")
property("mixin.debug.verbose", "true")
property("mixin.debug.export", "true")
property("mixin.dumpTargetOnFailure", "true")
if (project.platform.isForge) {
property("fml.coreMods.load", "club.sk1er.patcher.tweaker.PatcherTweaker")
arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
arg("--mixin", "patcher.mixins.json")
}
}
}
// Configures the name of the mixin "refmap" using an experimental loom api.
mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json")
}

// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately.
val shade: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
val modShade: Configuration by configurations.creating {
configurations.modImplementation.get().extendsFrom(this)
}

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


// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
repositories {
maven("https://repo.polyfrost.cc/releases")
maven("https://repo.polyfrost.org/releases")
}

val embed by configurations.creating
configurations.implementation.get().extendsFrom(embed)

// Configures the libraries/dependencies for your mod.
dependencies {
compileOnly("cc.polyfrost:oneconfig-$platform:0.2.0-alpha+")
embed("cc.polyfrost:elementa-$platform:+") {
// Adds the OneConfig library, so we can develop with it.
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.2-alpha+")

modShade("cc.polyfrost:elementa-$platform:+") {
isTransitive = false
}
embed("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
embed("com.github.videogame-hacker:Koffee:88ba1b0") {

shade("com.github.videogame-hacker:Koffee:88ba1b0") {
isTransitive = false
}
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
}

tasks.compileKotlin {
kotlinOptions {
freeCompilerArgs += listOf("-Xopt-in=kotlin.RequiresOptIn", "-Xno-param-assertions", "-Xjvm-default=all-compatibility")
modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.2.0")

// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
if (platform.isLegacyForge) {
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
}
}

tasks.processResources {
rename("(.+_at.cfg)", "META-INF/$1")
}
tasks {

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

// Processes the `src/resources/mcmod.info or fabric.mod.json` and replaces
// the mod id, name and version with the ones in `gradle.properties`
processResources {
inputs.property("id", mod_id)
inputs.property("name", mod_name)
val java = if (project.platform.mcMinor >= 18) {
17 // If we are playing on version 1.18, set the java version to 17
} else {
// Else if we are playing on version 1.17, use java 16.
if (project.platform.mcMinor == 17)
16
else
8 // For all previous versions, we **need** java 8 (for Forge support).
}
val compatLevel = "JAVA_${java}"
inputs.property("java", java)
inputs.property("java_level", compatLevel)
inputs.property("version", mod_version)
inputs.property("mcVersionStr", project.platform.mcVersionStr)
filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr
)
)
}
filesMatching("fabric.mod.json") {
expand(
mapOf(
"id" to mod_id,
"name" to mod_name,
"java" to java,
"java_level" to compatLevel,
"version" to mod_version,
"mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x"
)
)
}
rename("(.+_at.cfg)", "META-INF/$1")
}

// Configures the resources to include if we are building for forge or fabric.
withType(Jar::class.java) {
if (project.platform.isFabric) {
exclude("mcmod.info", "mods.toml")
} else {
exclude("fabric.mod.json")
if (project.platform.isLegacyForge) {
exclude("mods.toml")
} else {
exclude("mcmod.info")
}
}
}

tasks.jar {
from(embed.files.map { zipTree(it) })

manifest.attributes(mapOf(
"FMLCorePlugin" to "club.sk1er.patcher.tweaker.PatcherTweaker",
"ModSide" to "CLIENT",
"FMLAT" to accessTransformerName,
"FMLCorePluginContainsFMLMod" to "Yes, yes it does",
"Main-Class" to "club.sk1er.container.ContainerMessage",
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
"TweakOrder" to "0",
"MixinConfigs" to "patcher.mixins.json"
))
// Configures our shadow/shade configuration, so we can
// include some dependencies within our mod jar file.
named<ShadowJar>("shadowJar") {
archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix.
configurations = listOf(shade, modShade)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

remapJar {
inputFile.set(shadowJar.get().archiveFile)
archiveClassifier.set("")
}

jar {
// Sets the jar manifest attributes.
if (platform.isLegacyForge) {
manifest.attributes += mapOf(
"FMLCorePlugin" to "club.sk1er.patcher.tweaker.PatcherTweaker",
"ModSide" to "CLIENT", // We aren't developing a server-side mod, so this is fine.
"FMLAT" to accessTransformerName,
"FMLCorePluginContainsFMLMod" to "Yes, yes it does",
"Main-Class" to "club.sk1er.container.ContainerMessage",
"ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so.
"TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible.
"MixinConfigs" to "mixins.${mod_id}.json", // We want to use our mixin configuration, so we specify it here.
"TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper.
)
}
dependsOn(shadowJar)
archiveClassifier.set("")
enabled = false
}
}
Binary file removed deploy.jar
Binary file not shown.
15 changes: 12 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
polyfrost.defaults.loom=0
modGroup=club.sk1er
modBaseName=Patcher
# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod_*` AND REMOVE THIS COMMENT.

# Sets the name of your mod.
mod_name=Patcher
# Sets the id of your mod that mod loaders use to recognize it.
mod_id=patcher
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
mod_version=1.8.8
# Sets the name of the jar file that you put in your 'mods' folder.
mod_archives_name=Patcher

# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
polyfrost.defaults.loom=1
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureoncommand=true
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 4 additions & 10 deletions root.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
plugins {
kotlin("jvm") version "1.6.0" apply false
id("cc.polyfrost.multi-version.root")
kotlin("jvm") version "1.9.10" apply false
id("org.polyfrost.multi-version.root")
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
}

// normal versions will be "1.x.x"
// betas will be "1.x.x+beta-y" / "1.x.x+branch_beta-y"
// rcs will be 1.x.x+rc-y
// extra branches will be 1.x.x+branch-y
// MAKE SURE TO UPDATE THIS IN PATCHER CLASS TOO!!!
version = "1.8.7+oneconfig_alpha-3"

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

0 comments on commit da0dc5d

Please sign in to comment.