feat(lom): initial NeoForge support (untested)
ci/woodpecker/push/gradle Pipeline was successful Details
ci/woodpecker/push/pages Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2024-03-09 17:48:23 +01:00
parent eb58ea17f3
commit ac475465ce
Signed by: Johannes
GPG Key ID: E76429612C2929F4
8 changed files with 37 additions and 16 deletions

View File

@ -14,4 +14,12 @@ repositories {
name = "Fabric" name = "Fabric"
url = uri("https://maven.fabricmc.net/") url = uri("https://maven.fabricmc.net/")
} }
maven {
name = "Architectury"
url = uri("https://maven.architectury.dev/")
}
maven {
name = "Forge"
url = uri("https://files.minecraftforge.net/maven/")
}
} }

View File

@ -1,8 +1,8 @@
plugins { plugins {
id("jf.plugin-conventions") jf.`plugin-conventions`
} }
dependencies { dependencies {
implementation("org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r") implementation("org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r")
implementation("com.squareup:javapoet:1.13.0") implementation("com.squareup:javapoet:1.13.0")
} }

View File

@ -1,9 +1,9 @@
plugins { plugins {
id("jf.plugin-conventions") jf.`plugin-conventions`
} }
dependencies { dependencies {
api(project(":lom")) api(projects.lom)
implementation("com.modrinth.minotaur:Minotaur:2.8.0") implementation("com.modrinth.minotaur:Minotaur:2.8.7")
implementation("io.github.CDAGaming:CurseGradle:1.6.1") implementation("io.github.CDAGaming:CurseGradle:1.6.1")
} }

View File

@ -33,7 +33,7 @@ fun Project.legacyCheck(jfMod: JfModExtension) {
} }
if (hasProperty("loader_version")) { if (hasProperty("loader_version")) {
logger.warn("Using loader_version is deprecated, please use the DSL") logger.warn("Using loader_version is deprecated, please use the DSL")
jfMod.loaderVersion.set(prop("loader_version")) jfMod.fabricLoaderVersion.set(prop("loader_version"))
} }
if (hasProperty("yarn_mappings")) { if (hasProperty("yarn_mappings")) {
logger.warn("Using yarn_mappings is deprecated, please use the DSL") logger.warn("Using yarn_mappings is deprecated, please use the DSL")

View File

@ -1,9 +1,9 @@
plugins { plugins {
id("jf.plugin-conventions") jf.`plugin-conventions`
} }
dependencies { dependencies {
api(project(":convention")) api(projects.convention)
api("net.fabricmc:fabric-loom:1.5-SNAPSHOT") api("dev.architectury.loom:dev.architectury.loom.gradle.plugin:1.5-SNAPSHOT")
api("com.github.johnrengelman:shadow:8.1.1") api("com.github.johnrengelman:shadow:8.1.1")
} }

View File

@ -16,17 +16,22 @@ interface LomExtension {
} }
val minecraftVersion: Property<String> val minecraftVersion: Property<String>
val loaderVersion: Property<String> val fabricLoaderVersion: Property<String>
val neoforgeVersion: Property<String>
fun check(proj: Project) { fun check(proj: Project) {
yarnBuild.finalizeValue() yarnBuild.finalizeValue()
minecraftVersion.finalizeValue() minecraftVersion.finalizeValue()
loaderVersion.finalizeValue() fabricLoaderVersion.finalizeValue()
neoforgeVersion.finalizeValue()
require(!(fabricLoaderVersion.isPresent && neoforgeVersion.isPresent)) { "fabricLoaderVersion and forgeVersion are mutually exclusive" }
require(fabricLoaderVersion.isPresent || neoforgeVersion.isPresent) { "fabricLoaderVersion or forgeVersion must be set" }
} }
fun copyFrom(ext: LomExtension) { fun copyFrom(ext: LomExtension) {
yarnBuild.set(ext.yarnBuild) yarnBuild.set(ext.yarnBuild)
minecraftVersion.set(ext.minecraftVersion) minecraftVersion.set(ext.minecraftVersion)
loaderVersion.set(ext.loaderVersion) fabricLoaderVersion.set(ext.fabricLoaderVersion)
neoforgeVersion.set(ext.neoforgeVersion)
} }
} }

View File

@ -7,7 +7,7 @@ plugins {
id("jf.java") id("jf.java")
idea idea
`maven-publish` `maven-publish`
id("fabric-loom") id("dev.architectury.loom")
id("com.github.johnrengelman.shadow") id("com.github.johnrengelman.shadow")
} }
@ -17,6 +17,7 @@ val devlibs = project.layout.buildDirectory.dir("devlibs").get().asFile
loom { loom {
runtimeOnlyLog4j.set(true) runtimeOnlyLog4j.set(true)
splitEnvironmentSourceSets() splitEnvironmentSourceSets()
silentMojangMappingsLicense()
} }
// Create testmod source set with access to main and client classpaths // Create testmod source set with access to main and client classpaths
@ -84,8 +85,12 @@ earlyAfterEvaluate {
minecraft("com.mojang:minecraft:${args.minecraftVersion.get()}") minecraft("com.mojang:minecraft:${args.minecraftVersion.get()}")
if (args.yarnBuild.isPresent) mappings("net.fabricmc:yarn:${args.minecraftVersion.get()}+${args.yarnBuild.get()}:v2") if (args.yarnBuild.isPresent) mappings("net.fabricmc:yarn:${args.minecraftVersion.get()}+${args.yarnBuild.get()}:v2")
else loom.officialMojangMappings() else loom.officialMojangMappings()
modImplementation("net.fabricmc:fabric-loader:${args.loaderVersion.get()}") if (!hasProperty("loom.platform") || property("loom.platform") == "fabric") {
testImplementation("net.fabricmc:fabric-loader-junit:${args.loaderVersion.get()}") modImplementation("net.fabricmc:fabric-loader:${args.fabricLoaderVersion.get()}")
testImplementation("net.fabricmc:fabric-loader-junit:${args.fabricLoaderVersion.get()}")
} else if (property("loom.platform") == "neoforge") {
"neoForge"("net.minecraftforge:forge:${args.minecraftVersion.get()}-${args.neoforgeVersion.get()}")
}
testmodImplementation(sourceSets.main.get().output) testmodImplementation(sourceSets.main.get().output)
testmodImplementation(sourceSets.client.get().output) testmodImplementation(sourceSets.client.get().output)
@ -149,9 +154,10 @@ tasks.remapJar {
// fill in mod version // fill in mod version
tasks.processResources { tasks.processResources {
filesMatching("fabric.mod.json") { filesMatching(listOf("fabric.mod.json", "META-INF/mods.toml")) {
expand(mapOf("version" to project.versionS)) expand(mapOf("version" to project.versionS))
} }
inputs.property("version", project.versionS)
} }
// publish sources jar and remapped jar without JiJ'd deps // publish sources jar and remapped jar without JiJ'd deps

View File

@ -3,3 +3,5 @@ rootProject.name = "scripts"
include("lom") include("lom")
include("convention") include("convention")
include("jfmod") include("jfmod")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")