update project

This commit is contained in:
Relentless 2023-07-29 00:59:02 +02:00
parent 8da2346855
commit e5843fa7d9
No known key found for this signature in database
GPG key ID: 50C5FD225130D790
7 changed files with 144 additions and 130 deletions

View file

@ -1,14 +1,12 @@
val enabledPlatforms: String by project val enabledPlatforms: String by project
val fabricLoaderVersion: String by project val minecraftVersion: String by project
val modPackage: String by project
val modId: String by project val modId: String by project
val modName: String by project val modName: String by project
val modPackage: String by project
val reiVersion: String by project
val jeiVersion: String by project
val mappingsChannel: String by project
val mappingsVersion: String by project
val junitVersion: String by project val junitVersion: String by project
val minecraftVersion: String by project val fabricLoaderVersion: String by project
val jeiVersion: String by project
val reiVersion: String by project
plugins { plugins {
id("com.github.gmazzo.buildconfig") version ("4.0.4") id("com.github.gmazzo.buildconfig") version ("4.0.4")
@ -19,24 +17,26 @@ architectury {
} }
loom { loom {
if (project.findProperty("enableAccessWidener") == "true") { // Optional property for `gradle.properties` to enable access wideners. if (project.findProperty("enableAccessWidener") == "true") { // optional property for `gradle.properties`
accessWidenerPath.set(file("src/main/resources/$modId.accesswidener")) accessWidenerPath.set(file("src/main/resources/$modId.accesswidener"))
println("Access widener enabled for project ${project.name}. Access widener path: ${loom.accessWidenerPath.get()}") println("Access widener enabled for project ${project.name}. Access widener path: ${loom.accessWidenerPath.get()}")
} }
} }
dependencies { dependencies {
// loader /**
// required here for the @Environment annotations and the mixin dependencies * loader
// Do NOT use other classes from the Fabric loader! * required here for the @Environment annotations and the mixin dependencies
* do NOT use other classes from the Fabric loader
*/
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
// compile time mods // compile time mods
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$reiVersion") // required for common rei plugin modCompileOnly("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion") // required for jei plugin
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer on jei plugin modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$reiVersion") // required for rei plugin
testCompileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // don't question this, it's required for compiling
modCompileOnly("mezz.jei:jei-$minecraftVersion-lib:$jeiVersion") // required for common jei plugin and mixin // compile time dependencies
modCompileOnly("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion") // required for common jei plugin and mixin compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer
// tests // tests
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion") testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
@ -51,7 +51,6 @@ buildConfig {
useJavaOutput() useJavaOutput()
} }
// TODO reactivate when specific mod is not annoying anymore
//tasks { //tasks {
// withType<Test> { // withType<Test> {
// useJUnitPlatform() // useJUnitPlatform()

View file

@ -2,8 +2,8 @@ val minecraftVersion: String by project
val fabricLoaderVersion: String by project val fabricLoaderVersion: String by project
val fabricApiVersion: String by project val fabricApiVersion: String by project
val fabricRecipeViewer: String by project val fabricRecipeViewer: String by project
val reiVersion: String by project
val jeiVersion: String by project val jeiVersion: String by project
val reiVersion: String by project
plugins { plugins {
id("com.github.johnrengelman.shadow") version ("8.1.1") id("com.github.johnrengelman.shadow") version ("8.1.1")
@ -15,7 +15,7 @@ architectury {
} }
loom { loom {
if (project.findProperty("enableAccessWidener") == "true") { // Optional property for `gradle.properties` to enable access wideners. if (project.findProperty("enableAccessWidener") == "true") { // optional property for `gradle.properties`
accessWidenerPath.set(project(":Common").loom.accessWidenerPath) accessWidenerPath.set(project(":Common").loom.accessWidenerPath)
println("Access widener enabled for project ${project.name}. Access widener path: ${loom.accessWidenerPath.get()}") println("Access widener enabled for project ${project.name}. Access widener path: ${loom.accessWidenerPath.get()}")
} }
@ -23,6 +23,7 @@ loom {
val common by configurations val common by configurations
val shadowCommon by configurations val shadowCommon by configurations
dependencies { dependencies {
// loader // loader
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
@ -41,8 +42,8 @@ dependencies {
// runtime dependencies // runtime dependencies
modLocalRuntime( modLocalRuntime(
when (fabricRecipeViewer) { when (fabricRecipeViewer) {
"rei" -> "me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion"
"jei" -> "mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion" "jei" -> "mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion"
"rei" -> "me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion"
else -> throw GradleException("Invalid fabricRecipeViewer value: $fabricRecipeViewer") else -> throw GradleException("Invalid fabricRecipeViewer value: $fabricRecipeViewer")
} }
) { ) {

View file

@ -1,11 +1,12 @@
val minecraftVersion: String by project val minecraftVersion: String by project
val forgeVersion: String by project
val junitVersion: String by project
val modId: String by project val modId: String by project
val junitVersion: String by project
val forgeVersion: String by project
val forgeRecipeViewer: String by project val forgeRecipeViewer: String by project
val reiVersion: String by project
val jeiVersion: String by project val jeiVersion: String by project
val reiVersion: String by project
val extraModsPrefix = "extra-mods"
plugins { plugins {
id("com.github.johnrengelman.shadow") version ("8.1.1") id("com.github.johnrengelman.shadow") version ("8.1.1")
@ -17,7 +18,7 @@ architectury {
} }
loom { loom {
if (project.findProperty("enableAccessWidener") == "true") { // Optional property for `gradle.properties` to enable access wideners. if (project.findProperty("enableAccessWidener") == "true") { // optional property for `gradle.properties`
accessWidenerPath.set(project(":Common").loom.accessWidenerPath) accessWidenerPath.set(project(":Common").loom.accessWidenerPath)
forge { forge {
convertAccessWideners.set(true) convertAccessWideners.set(true)
@ -31,9 +32,17 @@ loom {
} }
} }
repositories {
flatDir {
name = extraModsPrefix
dir(file("$extraModsPrefix-$minecraftVersion"))
}
}
val common by configurations val common by configurations
val shadowCommon by configurations val shadowCommon by configurations
val commonTests: SourceSetOutput = project(":Common").sourceSets["test"].output val commonTests: SourceSetOutput = project(":Common").sourceSets["test"].output
dependencies { dependencies {
// loader // loader
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion") forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
@ -52,11 +61,28 @@ dependencies {
// runtime mods // runtime mods
when (forgeRecipeViewer) { when (forgeRecipeViewer) {
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false } "jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
else -> throw GradleException("Invalid forgeRecipeViewer value: $forgeRecipeViewer") else -> throw GradleException("Invalid forgeRecipeViewer value: $forgeRecipeViewer")
} }
/**
* helps to load mods in development through an extra directory
* sadly, this does not support transitive dependencies
*/
fileTree("$extraModsPrefix-$minecraftVersion") { include("**/*.jar") }
.forEach { f ->
val sepIndex = f.nameWithoutExtension.lastIndexOf('-')
if (sepIndex == -1) {
throw IllegalArgumentException("Invalid mod name: '${f.nameWithoutExtension}'. Expected format: 'modName-version.jar'")
}
val mod = f.nameWithoutExtension.substring(0, sepIndex)
val version = f.nameWithoutExtension.substring(sepIndex + 1)
println("Extra mod ${f.nameWithoutExtension} detected.")
"modLocalRuntime"("extra-mods:$mod:$version")
}
// tests // tests
testImplementation(project(":Common")) testImplementation(project(":Common"))
testImplementation(commonTests) testImplementation(commonTests)

View file

@ -38,10 +38,3 @@ mandatory = false
versionRange = "[${reiVersion},)" versionRange = "[${reiVersion},)"
ordering = "BEFORE" ordering = "BEFORE"
side = "BOTH" side = "BOTH"
[[dependencies."${modId}"]]
modId = "rei_plugin_compatibilities"
mandatory = false
versionRange = "[9.0.43,)"
ordering = "BEFORE"
side = "BOTH"

View file

@ -5,61 +5,49 @@ import net.fabricmc.loom.api.LoomGradleExtensionAPI
import net.fabricmc.loom.task.RemapJarTask import net.fabricmc.loom.task.RemapJarTask
val license: String by project val license: String by project
val fabricLoaderVersion: String by project
val fabricApiVersion: String by project
val forgeVersion: String by project
val minecraftVersion: String by project val minecraftVersion: String by project
val modPackage: String by project
val modVersion: String by project val modVersion: String by project
val modId: String by project val modId: String by project
val modName: String by project val modName: String by project
val modDescription: String by project val modDescription: String by project
val modAuthor: String by project val modAuthor: String by project
val githubRepo: String by project
val githubUser: String by project
val sharedRunDir: String by project
val autoServiceVersion: String by project val autoServiceVersion: String by project
val parchmentVersion: String by project val parchmentVersion: String by project
val fabricApiVersion: String by project
val forgeVersion: String by project
val jeiVersion: String by project val jeiVersion: String by project
val reiVersion: String by project val reiVersion: String by project
val githubRepo: String by project
val githubUser: String by project
plugins { plugins {
id("architectury-plugin") version ("3.4.+")
id("dev.architectury.loom") version "1.3.+" apply false
id("io.github.juuxel.loom-vineflower") version "1.11.0" apply false
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
java java
`maven-publish` `maven-publish`
id("architectury-plugin") version ("3.4.+")
id("io.github.juuxel.loom-quiltflower") version "1.10.0" apply false
id("dev.architectury.loom") version ("1.2.+") apply false
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
} }
architectury { architectury {
minecraft = minecraftVersion minecraft = minecraftVersion
} }
val extraModsPrefix = "extra-mods" /**
* configurations for all projects including the root project
*/
allprojects { allprojects {
apply(plugin = "java") apply(plugin = "java")
apply(plugin = "architectury-plugin")
apply(plugin = "maven-publish")
repositories {
mavenLocal()
mavenCentral()
maven("https://maven.parchmentmc.org") // Parchment
maven("https://maven.shedaniel.me") // REI
maven("https://maven.blamejared.com/") // JEI
flatDir {
name = extraModsPrefix
dir(file("$extraModsPrefix-$minecraftVersion"))
}
}
tasks { tasks {
withType<JavaCompile> { withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
options.release.set(17) options.release.set(17)
} }
withType<GenerateModuleMetadata> {
enabled = false
}
} }
extensions.configure<JavaPluginExtension> { extensions.configure<JavaPluginExtension> {
@ -68,87 +56,54 @@ allprojects {
} }
} }
/**
* configurations for all projects except the root project
*/
subprojects { subprojects {
apply(plugin = "java") apply(plugin = "architectury-plugin")
apply(plugin = "dev.architectury.loom") apply(plugin = "dev.architectury.loom")
apply(plugin = "io.github.juuxel.loom-vineflower")
apply(plugin = "java")
apply(plugin = "maven-publish") apply(plugin = "maven-publish")
apply(plugin = "io.github.juuxel.loom-quiltflower")
base.archivesName.set("$modId-${project.name.lowercase()}") base {
archivesName.set("$modId-${project.name.lowercase()}")
version = "$minecraftVersion-$modVersion" version = "$minecraftVersion-$modVersion"
}
repositories {
maven("https://maven.parchmentmc.org") // Parchment
maven("https://maven.shedaniel.me") // REI
maven("https://maven.blamejared.com/") // JEI
mavenLocal()
}
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom") val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
loom.silentMojangMappingsLicense() loom.silentMojangMappingsLicense()
/**
* General dependencies used for all subprojects, e.g. mappings or the Minecraft version.
*/
dependencies { dependencies {
/** /**
* Kotlin accessor methods are not generated in this gradle, they can be accessed through quoted names. * Minecraft
* Kotlin accessor methods are not generated in this gradle
* they can be accessed through quoted names instead
*/ */
"minecraft"("com.mojang:minecraft:$minecraftVersion") "minecraft"("com.mojang:minecraft:$minecraftVersion")
"mappings"(loom.layered { "mappings"(loom.layered {
officialMojangMappings() officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.19.3:$parchmentVersion@zip") parchment("org.parchmentmc.data:parchment-$minecraftVersion:$parchmentVersion@zip")
}) })
/** /**
* Helps to load mods in development through an extra directory. Sadly this does not support transitive dependencies. :-( * non-Minecraft dependencies
*/
fileTree("$extraModsPrefix-$minecraftVersion") { include("**/*.jar") }
.forEach { f ->
val sepIndex = f.nameWithoutExtension.lastIndexOf('-')
if (sepIndex == -1) {
throw IllegalArgumentException("Invalid mod name: '${f.nameWithoutExtension}'. Expected format: 'modName-version.jar'")
}
val mod = f.nameWithoutExtension.substring(0, sepIndex)
val version = f.nameWithoutExtension.substring(sepIndex + 1)
println("Extra mod ${f.nameWithoutExtension} detected.")
"modLocalRuntime"("extra-mods:$mod:$version")
}
/**
* Non-Minecraft dependencies
*/ */
compileOnly("com.google.auto.service:auto-service:$autoServiceVersion") compileOnly("com.google.auto.service:auto-service:$autoServiceVersion")
annotationProcessor("com.google.auto.service:auto-service:$autoServiceVersion") annotationProcessor("com.google.auto.service:auto-service:$autoServiceVersion")
} }
/**
* Maven publishing
*/
publishing {
publications {
val mpm = project.properties["maven-publish-method"] as String
println("[Publish Task] Publishing method for project '${project.name}: $mpm")
register(mpm, MavenPublication::class) {
artifactId = base.archivesName.get()
from(components["java"])
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
maven("file://${System.getenv("local_maven")}")
}
}
/**
* Disabling the runtime transformer from Architectury here.
* When the runtime transformer should be enabled again, remove this block and add the following to the respective subproject:
*
* configurations {
* "developmentFabric" { extendsFrom(configurations["common"]) } // or "developmentForge" for Forge
* }
*/
architectury {
compileOnly()
}
tasks { tasks {
/** /**
* Resource processing for defined targets. This will replace `${key}` with the specified values from the map below. * resource processing for defined targets
* will replace `${key}` with the specified values from the map below
*/ */
processResources { processResources {
val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta", "fabric.mod.json") val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta", "fabric.mod.json")
@ -163,14 +118,16 @@ subprojects {
"modDescription" to modDescription, "modDescription" to modDescription,
"fabricApiVersion" to fabricApiVersion, "fabricApiVersion" to fabricApiVersion,
"forgeVersion" to forgeVersion, "forgeVersion" to forgeVersion,
"forgeFMLVersion" to forgeVersion.substringBefore("."), // Only use major version as FML error message sucks. The error message for wrong Forge version is way better. // use major version for FML only because wrong Forge version error message
// is way better than FML error message
"forgeFMLVersion" to forgeVersion.substringBefore("."),
"jeiVersion" to jeiVersion, "jeiVersion" to jeiVersion,
"reiVersion" to reiVersion, "reiVersion" to reiVersion,
"githubUser" to githubUser, "githubUser" to githubUser,
"githubRepo" to githubRepo "githubRepo" to githubRepo
) )
println("[Process Resources] Replacing properties in resources: ") println("[Process Resources] Replacing resource properties for project '${project.name}': ")
replaceProperties.forEach { (key, value) -> println("\t -> $key = $value") } replaceProperties.forEach { (key, value) -> println("\t -> $key = $value") }
inputs.properties(replaceProperties) inputs.properties(replaceProperties)
@ -179,10 +136,46 @@ subprojects {
} }
} }
} }
/**
* Maven publishing
*/
publishing {
publications {
val mpm = project.properties["maven-publish-method"] as String
println("[Publish Task] Publishing method for project '${project.name}': $mpm")
register(mpm, MavenPublication::class) {
artifactId = base.archivesName.get()
from(components["java"])
}
}
/**
* information on how to set up publishing
* https://docs.gradle.org/current/userguide/publishing_maven.html
*/
repositories {
maven("file://${System.getenv("local_maven")}")
}
}
/**
* disabling the runtime transformer from Architectury
* if the runtime transformer should be enabled again, remove this block and
* add the following to the respective subproject:
*
* configurations {
* "developmentFabric" { extendsFrom(configurations["common"]) }
* "developmentForge" { extendsFrom(configurations["common"]) }
* }
*/
architectury {
compileOnly()
}
} }
/** /**
* Subproject configurations and tasks only applied to subprojects that are not the common project, e.g. Fabric or Forge. * configurations for all subprojects except the common project
*/ */
subprojects { subprojects {
if (project.path == ":Common") { if (project.path == ":Common") {
@ -194,15 +187,19 @@ subprojects {
extensions.configure<LoomGradleExtensionAPI> { extensions.configure<LoomGradleExtensionAPI> {
runs { runs {
forEach { forEach {
it.runDir(if (sharedRunDir.toBoolean()) "../run" else "run") val dir = "../run/${project.name.lowercase()}_${it.environment}"
// Allows DCEVM hot-swapping when using the JetBrains Runtime (https://github.com/JetBrains/JetBrainsRuntime). println("[${project.name}] Run config '${it.name}' directory set to: $dir")
it.runDir(dir)
// allows DCEVM hot-swapping when using the JBR (https://github.com/JetBrains/JetBrainsRuntime)
it.vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition") it.vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
} }
} }
/** /**
* "main" matches the default mod's name. Since `compileOnly()` is being used in Architectury, * "main" matches the default mod name
* the local mods for the loaders need to be set up too. Otherwise, they won't recognize :Common. * since `compileOnly()` is being used in Architectury, the local mods for the
* loaders need to be set up too
* otherwise, they won't recognize :Common.
*/ */
with(mods.maybeCreate("main")) { with(mods.maybeCreate("main")) {
fun Project.sourceSets() = extensions.getByName<SourceSetContainer>("sourceSets") fun Project.sourceSets() = extensions.getByName<SourceSetContainer>("sourceSets")
@ -212,7 +209,7 @@ subprojects {
} }
val common by configurations.creating val common by configurations.creating
val shadowCommon by configurations.creating // Don't use shadow from the shadow plugin because IDEA isn't supposed to index this. val shadowCommon by configurations.creating // don't use shadow from the plugin, IDEA shouldn't index this
configurations { configurations {
"compileClasspath" { extendsFrom(common) } "compileClasspath" { extendsFrom(common) }
"runtimeClasspath" { extendsFrom(common) } "runtimeClasspath" { extendsFrom(common) }

View file

@ -3,9 +3,6 @@ group = com.almostreliable.mods
license = GNU Lesser General Public License v3.0 license = GNU Lesser General Public License v3.0
enabledPlatforms = fabric,forge enabledPlatforms = fabric,forge
enableAccessWidener = false enableAccessWidener = false
sharedRunDir = false
extraModsDirectory = extra-mods
junitVersion = 5.9.0
# Minecraft # Minecraft
minecraftVersion = 1.20.1 minecraftVersion = 1.20.1
@ -20,11 +17,12 @@ modDescription = Unify all resources.
# Project Dependencies # Project Dependencies
autoServiceVersion = 1.1.0 autoServiceVersion = 1.1.0
parchmentVersion = 2023.03.12 junitVersion = 5.9.0
parchmentVersion = 2023.07.23
# Mod Dependencies # Mod Dependencies
reiVersion = 12.0.625
jeiVersion = 15.0.0.12 jeiVersion = 15.0.0.12
reiVersion = 12.0.625
# Fabric Dependencies # Fabric Dependencies
fabricLoaderVersion = 0.14.21 fabricLoaderVersion = 0.14.21

View file

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven("https://maven.fabricmc.net/")
maven("https://maven.architectury.dev/") maven("https://maven.architectury.dev/")
maven("https://maven.fabricmc.net/")
maven("https://maven.minecraftforge.net/") maven("https://maven.minecraftforge.net/")
gradlePluginPortal() gradlePluginPortal()
} }