mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-12-17 19:42:28 -05:00
update project
This commit is contained in:
parent
8da2346855
commit
e5843fa7d9
7 changed files with 144 additions and 130 deletions
|
@ -1,14 +1,12 @@
|
|||
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 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 minecraftVersion: String by project
|
||||
val fabricLoaderVersion: String by project
|
||||
val jeiVersion: String by project
|
||||
val reiVersion: String by project
|
||||
|
||||
plugins {
|
||||
id("com.github.gmazzo.buildconfig") version ("4.0.4")
|
||||
|
@ -19,24 +17,26 @@ architectury {
|
|||
}
|
||||
|
||||
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"))
|
||||
println("Access widener enabled for project ${project.name}. Access widener path: ${loom.accessWidenerPath.get()}")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// loader
|
||||
// required here for the @Environment annotations and the mixin dependencies
|
||||
// Do NOT use other classes from the Fabric loader!
|
||||
/**
|
||||
* 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")
|
||||
|
||||
// compile time mods
|
||||
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$reiVersion") // required for common rei plugin
|
||||
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer on jei 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
|
||||
modCompileOnly("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion") // required for common jei plugin and mixin
|
||||
modCompileOnly("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion") // required for jei plugin
|
||||
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$reiVersion") // required for rei plugin
|
||||
|
||||
// compile time dependencies
|
||||
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+") // required to disable rei compat layer
|
||||
|
||||
// tests
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
|
||||
|
@ -51,7 +51,6 @@ buildConfig {
|
|||
useJavaOutput()
|
||||
}
|
||||
|
||||
// TODO reactivate when specific mod is not annoying anymore
|
||||
//tasks {
|
||||
// withType<Test> {
|
||||
// useJUnitPlatform()
|
||||
|
|
|
@ -2,8 +2,8 @@ val minecraftVersion: String by project
|
|||
val fabricLoaderVersion: String by project
|
||||
val fabricApiVersion: String by project
|
||||
val fabricRecipeViewer: String by project
|
||||
val reiVersion: String by project
|
||||
val jeiVersion: String by project
|
||||
val reiVersion: String by project
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow") version ("8.1.1")
|
||||
|
@ -15,7 +15,7 @@ architectury {
|
|||
}
|
||||
|
||||
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)
|
||||
println("Access widener enabled for project ${project.name}. Access widener path: ${loom.accessWidenerPath.get()}")
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ loom {
|
|||
|
||||
val common by configurations
|
||||
val shadowCommon by configurations
|
||||
|
||||
dependencies {
|
||||
// loader
|
||||
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
|
||||
|
@ -41,8 +42,8 @@ dependencies {
|
|||
// runtime dependencies
|
||||
modLocalRuntime(
|
||||
when (fabricRecipeViewer) {
|
||||
"rei" -> "me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion"
|
||||
"jei" -> "mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion"
|
||||
"rei" -> "me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion"
|
||||
else -> throw GradleException("Invalid fabricRecipeViewer value: $fabricRecipeViewer")
|
||||
}
|
||||
) {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
val minecraftVersion: String by project
|
||||
val forgeVersion: String by project
|
||||
val junitVersion: String by project
|
||||
val modId: String by project
|
||||
val junitVersion: String by project
|
||||
val forgeVersion: String by project
|
||||
val forgeRecipeViewer: String by project
|
||||
val reiVersion: String by project
|
||||
val jeiVersion: String by project
|
||||
val reiVersion: String by project
|
||||
|
||||
val extraModsPrefix = "extra-mods"
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow") version ("8.1.1")
|
||||
|
@ -17,7 +18,7 @@ architectury {
|
|||
}
|
||||
|
||||
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)
|
||||
forge {
|
||||
convertAccessWideners.set(true)
|
||||
|
@ -31,9 +32,17 @@ loom {
|
|||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
flatDir {
|
||||
name = extraModsPrefix
|
||||
dir(file("$extraModsPrefix-$minecraftVersion"))
|
||||
}
|
||||
}
|
||||
|
||||
val common by configurations
|
||||
val shadowCommon by configurations
|
||||
val commonTests: SourceSetOutput = project(":Common").sourceSets["test"].output
|
||||
|
||||
dependencies {
|
||||
// loader
|
||||
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
|
||||
|
@ -52,11 +61,28 @@ dependencies {
|
|||
|
||||
// runtime mods
|
||||
when (forgeRecipeViewer) {
|
||||
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
|
||||
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
|
||||
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
|
||||
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
|
||||
testImplementation(project(":Common"))
|
||||
testImplementation(commonTests)
|
||||
|
|
|
@ -38,10 +38,3 @@ mandatory = false
|
|||
versionRange = "[${reiVersion},)"
|
||||
ordering = "BEFORE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies."${modId}"]]
|
||||
modId = "rei_plugin_compatibilities"
|
||||
mandatory = false
|
||||
versionRange = "[9.0.43,)"
|
||||
ordering = "BEFORE"
|
||||
side = "BOTH"
|
||||
|
|
179
build.gradle.kts
179
build.gradle.kts
|
@ -5,61 +5,49 @@ import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
|||
import net.fabricmc.loom.task.RemapJarTask
|
||||
|
||||
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 modPackage: String by project
|
||||
val modVersion: String by project
|
||||
val modId: String by project
|
||||
val modName: String by project
|
||||
val modDescription: 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 parchmentVersion: String by project
|
||||
val fabricApiVersion: String by project
|
||||
val forgeVersion: String by project
|
||||
val jeiVersion: String by project
|
||||
val reiVersion: String by project
|
||||
val githubRepo: String by project
|
||||
val githubUser: String by project
|
||||
|
||||
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
|
||||
`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 {
|
||||
minecraft = minecraftVersion
|
||||
}
|
||||
|
||||
val extraModsPrefix = "extra-mods"
|
||||
|
||||
/**
|
||||
* configurations for all projects including the root project
|
||||
*/
|
||||
allprojects {
|
||||
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 {
|
||||
withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
withType<GenerateModuleMetadata> {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
extensions.configure<JavaPluginExtension> {
|
||||
|
@ -68,87 +56,54 @@ allprojects {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* configurations for all projects except the root project
|
||||
*/
|
||||
subprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "architectury-plugin")
|
||||
apply(plugin = "dev.architectury.loom")
|
||||
apply(plugin = "io.github.juuxel.loom-vineflower")
|
||||
apply(plugin = "java")
|
||||
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"
|
||||
}
|
||||
|
||||
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")
|
||||
loom.silentMojangMappingsLicense()
|
||||
|
||||
/**
|
||||
* General dependencies used for all subprojects, e.g. mappings or the Minecraft version.
|
||||
*/
|
||||
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")
|
||||
"mappings"(loom.layered {
|
||||
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. :-(
|
||||
*/
|
||||
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
|
||||
* non-Minecraft dependencies
|
||||
*/
|
||||
compileOnly("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 {
|
||||
/**
|
||||
* 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 {
|
||||
val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta", "fabric.mod.json")
|
||||
|
@ -163,14 +118,16 @@ subprojects {
|
|||
"modDescription" to modDescription,
|
||||
"fabricApiVersion" to fabricApiVersion,
|
||||
"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,
|
||||
"reiVersion" to reiVersion,
|
||||
"githubUser" to githubUser,
|
||||
"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") }
|
||||
|
||||
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"])
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subproject configurations and tasks only applied to subprojects that are not the common project, e.g. Fabric or Forge.
|
||||
* 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()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* configurations for all subprojects except the common project
|
||||
*/
|
||||
subprojects {
|
||||
if (project.path == ":Common") {
|
||||
|
@ -194,15 +187,19 @@ subprojects {
|
|||
extensions.configure<LoomGradleExtensionAPI> {
|
||||
runs {
|
||||
forEach {
|
||||
it.runDir(if (sharedRunDir.toBoolean()) "../run" else "run")
|
||||
// Allows DCEVM hot-swapping when using the JetBrains Runtime (https://github.com/JetBrains/JetBrainsRuntime).
|
||||
val dir = "../run/${project.name.lowercase()}_${it.environment}"
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "main" matches the default mod's name. 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.
|
||||
* "main" matches the default mod name
|
||||
* 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")) {
|
||||
fun Project.sourceSets() = extensions.getByName<SourceSetContainer>("sourceSets")
|
||||
|
@ -212,7 +209,7 @@ subprojects {
|
|||
}
|
||||
|
||||
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 {
|
||||
"compileClasspath" { extendsFrom(common) }
|
||||
"runtimeClasspath" { extendsFrom(common) }
|
||||
|
|
|
@ -3,9 +3,6 @@ group = com.almostreliable.mods
|
|||
license = GNU Lesser General Public License v3.0
|
||||
enabledPlatforms = fabric,forge
|
||||
enableAccessWidener = false
|
||||
sharedRunDir = false
|
||||
extraModsDirectory = extra-mods
|
||||
junitVersion = 5.9.0
|
||||
|
||||
# Minecraft
|
||||
minecraftVersion = 1.20.1
|
||||
|
@ -20,11 +17,12 @@ modDescription = Unify all resources.
|
|||
|
||||
# Project Dependencies
|
||||
autoServiceVersion = 1.1.0
|
||||
parchmentVersion = 2023.03.12
|
||||
junitVersion = 5.9.0
|
||||
parchmentVersion = 2023.07.23
|
||||
|
||||
# Mod Dependencies
|
||||
reiVersion = 12.0.625
|
||||
jeiVersion = 15.0.0.12
|
||||
reiVersion = 12.0.625
|
||||
|
||||
# Fabric Dependencies
|
||||
fabricLoaderVersion = 0.14.21
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://maven.architectury.dev/")
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://maven.minecraftforge.net/")
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue