Merge branch 'removeArch' into Data_Source_Rewrite

This commit is contained in:
James Seibel
2024-04-14 16:41:28 -05:00
19 changed files with 566 additions and 401 deletions
+127 -139
View File
@@ -1,29 +1,32 @@
plugins {
id "java"
// Plugin to handle dependencies
// Plugin to put dependencies inside our final jar
id "com.github.johnrengelman.shadow" version '7.1.2' apply false
// Plugin to create merged jars
id "io.github.pacifistmc.forgix" version "1.2.6"
// Manifold preprocessor
id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha"
// // Provides mc libraries to core
// id "org.spongepowered.gradle.vanilla" version '0.2.1-SNAPSHOT' apply false
// Architectury is used here only as a replacement for forge's own loom
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
// Unimined is our all in one solution to minecraft loaders
// id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false // Unstable Release (TODO: Check back to see when the unstable branch fixes forge run without the jank)
id "xyz.wagyourtail.unimined" version "1.1.2-SNAPSHOT" apply false // LTS Release
}
// Transfers the values set in settings.gradle to the rest of the project
project.gradle.ext.getProperties().each { prop ->
rootProject.ext.set(prop.key, prop.value)
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
}
/**
* Creates the list of preprocessors to use.
*
* @param mcVers array of all MC versions
* @param mcIndex array index of the currently active MC version
*/
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
{
// Build the list of preprocessors to use
StringBuilder sb = new StringBuilder();
@@ -31,7 +34,7 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n");
for (int i = 0; i < mcVers.size(); i++)
for (int i = 0; i < mcVers.size(); i++)
{
String verStr = mcVers[i].replace(".", "_");
sb.append("MC_" + verStr + "=" + i.toString() + "\n");
@@ -42,23 +45,15 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
// Check if this is a development build
if (mod_version.toLowerCase().contains("dev"))
if (mod_version.toLowerCase().contains("dev"))
{
// WARNING: only use this for logging, we don't want to have confusion
// when a method doesn't work correctly in the release build.
sb.append("DEV_BUILD=\n");
}
new File(projectDir, "build.properties").text = sb.toString()
}
// Transfers the values set in settings.gradle to the rest of the project
project.gradle.ext.getProperties().each { prop ->
rootProject.ext.set(prop.key, prop.value)
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
}
// Sets up manifold stuff
writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex)
@@ -66,6 +61,7 @@ writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex)
// Sets up the version string (the name we use for our jar)
rootProject.versionStr = rootProject.mod_version + "-" + rootProject.minecraft_version // + "-" + new Date().format("yyyy_MM_dd_HH_mm")
// Forgix settings (used for merging jars)
forgix {
group = "com.seibel.distanthorizons"
@@ -96,7 +92,7 @@ forgix {
}
subprojects { p ->
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge") || p == project("WhateverWeAddLaterOn")"
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":forge") || p == project("WhateverLoaderWeAddLaterOn")"
// Useful later on so we dont have duplicated code
def isMinecraftSubProject = p != project(":core") && p != project(":api")
@@ -104,73 +100,68 @@ subprojects { p ->
// Apply plugins
apply plugin: "java"
apply plugin: "com.github.johnrengelman.shadow"
if (isMinecraftSubProject)
apply plugin: "systems.manifold.manifold-gradle-plugin"
if (p == project(":core"))
if (p == project(":core"))
apply plugin: "application"
// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
if (isMinecraftSubProject) {
apply plugin: "xyz.wagyourtail.unimined"
// Apply forge's loom
if (
(findProject(":forge") && p == project(":forge")) ||
(findProject(":neoforge") && p == project(":neoforge"))
)
apply plugin: "dev.architectury.loom"
unimined.minecraft(sourceSets.main, true) {
version = rootProject.minecraft_version
def parchmentVersionParts = rootProject.parchment_version.split(":")
mappings {
mojmap()
parchment(parchmentVersionParts[0], parchmentVersionParts[1])
devNamespace "mojmap"
}
runs {
config("client") {
workingDir = rootProject.file("run")
}
config("server") {
workingDir = rootProject.file("run") // TODO: When running the server, would it be a better idea to change this to a different dir?
disabled = true // TODO: Once server-side support is added, remove this
}
}
}
// Set the manifold version (may not be required tough)
manifold {
manifoldVersion = rootProject.manifold_version
if (p != project(":common")) {
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.java)
source(project(":api").sourceSets.main.java)
source(project(":core").sourceSets.main.java)
}
}
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// Disable testing for projects that aren't the core or api project.
// If not done compiling will fail due to an issue with Manifold
if (isMinecraftSubProject) {
test {
enabled = false
}
compileTestJava {
enabled = false
}
}
// set up custom configurations (configurations are a way to handle dependencies)
configurations {
// extends the shadowJar configuration
shadowMe
shadowMc // Configuration that doesn't contain coreProjects
// have implemented dependencies automatically embedded in the final jar
implementation.extendsFrom(shadowMe)
implementation.extendsFrom(shadowMc)
// Configuration fpr core & api
coreProjects
shadowMe.extendsFrom(coreProjects)
// FIXME this additional configuration is necessary because forge
// needs forgeRuntimeLibrary, although adding it to shadowMe
// causes runtime issues where the libraries aren't properly added
forgeShadowMe
// this should match shadowMe pretty closely
implementation.extendsFrom(forgeShadowMe)
shadowMe.extendsFrom(forgeShadowMe)
forgeRuntimeLibrary.extendsFrom(forgeShadowMe)
if (isMinecraftSubProject && p != project(":common")) {
// Shadow common
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
if (findProject(":forge"))
developmentForge.extendsFrom common
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom common
compileClasspath.extendsFrom coreProjects
runtimeClasspath.extendsFrom coreProjects
if (findProject(":forge"))
developmentForge.extendsFrom coreProjects
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom coreProjects
if (findProject(":fabricLike") && p != project(":fabricLike")) {
// Shadow fabricLike
fabricLike
shadowFabricLike
compileClasspath.extendsFrom fabricLike
runtimeClasspath.extendsFrom fabricLike
}
}
// Add shaded libraries very early in the classpath (excluding coreProjects as that's added in a different way)
minecraftLibraries.extendsFrom(shadowMc)
}
@@ -187,53 +178,52 @@ subprojects { p ->
// shared dependencies //
//=====================//
// Manifold
if (isMinecraftSubProject) {
annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}")
}
// Log4j
// TODO: Change to shadowMe later to work in the standalone jar
// TODO: Change to shadowCore later to work in the standalone jar
// We cannot do this now as it would break Quilt
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}")
// JOML
if (project.hasProperty("embed_joml") && embed_joml == "true")
forgeShadowMe("org.joml:joml:${rootProject.joml_version}")
else
implementation("org.joml:joml:${rootProject.joml_version}")
// JUnit tests
implementation("org.junit.jupiter:junit-jupiter:5.8.2")
implementation("org.junit.jupiter:junit-jupiter-engine:5.8.2")
implementation("junit:junit:4.13")
// JOML
if (project.hasProperty("embed_joml") && embed_joml == "true")
shadowMc("org.joml:joml:${rootProject.joml_version}")
else
implementation("org.joml:joml:${rootProject.joml_version}")
// Compression
forgeShadowMe("org.lz4:lz4-java:${rootProject.lz4_version}") // LZ4
forgeShadowMe("com.github.luben:zstd-jni:${rootProject.zstd_version}") // Zstd
forgeShadowMe("org.tukaani:xz:${rootProject.xz_version}") // LZMA
shadowMc("org.lz4:lz4-java:${rootProject.lz4_version}") // LZ4
shadowMc("com.github.luben:zstd-jni:${rootProject.zstd_version}") // Zstd
shadowMc("org.tukaani:xz:${rootProject.xz_version}") // LZMA
// Sqlite Database
forgeShadowMe("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}")
shadowMc("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}")
// NightConfig (includes Toml & Json)
forgeShadowMe("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
forgeShadowMe("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
shadowMc("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
shadowMc("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
// Fastutil
forgeShadowMe("it.unimi.dsi:fastutil:${rootProject.fastutil_version}")
shadowMc("it.unimi.dsi:fastutil:${rootProject.fastutil_version}")
// SVG (not needed atm)
// forgeShadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
//shadowMc("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
// Netty
// Breaks 1.16.5
//forgeShadowMe("io.netty:netty-all:${rootProject.netty_version}")
//shadowMc("io.netty:netty-all:${rootProject.netty_version}")
// Remember, for lwjgl dependencies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing
forgeShadowMe("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") {
shadowMc("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") {
exclude group: "org.lwjgl", module: "lwjgl" // This module is imported by Minecraft so exclude it
}
@@ -246,11 +236,12 @@ subprojects { p ->
// Add core
if (isMinecraftSubProject) {
coreProjects(project(":core")) {
compileOnly(project(":core")) {
// Remove Junit test libraries
exclude group: "org.junit.jupiter", module: "junit-jupiter"
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
exclude group: "junit", module: "junit"
// Removed dependencies
transitive false
}
@@ -258,11 +249,12 @@ subprojects { p ->
// Add the api
if (p != project(":api")) {
coreProjects(project(":api")) {
implementation(project(":api")) {
// Remove Junit test libraries
exclude group: "org.junit.jupiter", module: "junit-jupiter"
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
exclude group: "junit", module: "junit"
// Removed dependencies
transitive false
}
@@ -271,29 +263,19 @@ subprojects { p ->
// Add common
if (isMinecraftSubProject && p != project(":common")) {
// Common
common(project(":common")) { transitive false }
shadowCommon(project(":common")) { transitive false }
// FabricLike
if (findProject(":fabricLike") && p != project(":fabricLike")) {
fabricLike(project(path: ":fabricLike")) { transitive false }
shadowFabricLike(project(path: ":fabricLike")) { transitive false }
}
compileOnly(project(":common")) { transitive false }
}
}
shadowJar {
configurations = [project.configurations.shadowMe]
configurations = [project.configurations.shadowMc]
if (isMinecraftSubProject && p != project(":common")) {
configurations.push(project.configurations.shadowCommon) // Shadow the common subproject
relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location
if (findProject(":fabricLike") && p != project(":fabricLike")) {
configurations.push(project.configurations.shadowFabricLike) // Shadow the fabricLike subproject
relocate "com.seibel.distanthorizons.fabriclike", "loaderCommon.${p.name}.com.seibel.distanthorizons.fabriclike" // Move the loader files to a different location
}
}
def librariesLocation = "distanthorizons.libraries"
// LWJGL
@@ -331,7 +313,20 @@ subprojects { p ->
// Put stuff from gradle.properties into the mod info
processResources {
def resourceTargets = [ // Location of where to inject the properties
duplicatesStrategy = DuplicatesStrategy.WARN
// Include all the resources
from project(":common").sourceSets.main.resources
from project(":core").sourceSets.main.resources
from project(":api").sourceSets.main.resources
// Copy accessWideners
// FIXME: remove copyCommonLoaderResources and use this instead (and if you are removing that task, also remove copyCoreResources while your at it)
// from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
// into(file(p.file("build/resources/main")))
rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener"
// Location of where to inject the properties
def resourceTargets = [
// Holds info like git commit
// TODO: For some reason this script doesnt work with the core project
"build_info.json",
@@ -344,7 +339,7 @@ subprojects { p ->
// The mixins for each of the loaders
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
]
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
def buildResourceTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
// Fix forge version numbering system as it is weird
// For whatever reason forge uses [1.18, 1.18.1, 1.18.2) instead of the standard ["1.18", "1.18.1", "1.18.2"]
@@ -352,7 +347,7 @@ subprojects { p ->
// println compatible_forgemc_versions
// Quilt's custom contributors system
// This has to be like
// has to be in the format:
// "Person": "Developer", "Another person": "Developer"
def quilt_contributors = []
def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
@@ -360,9 +355,9 @@ subprojects { p ->
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
}
quilt_contributors.reverse()
// println quilt_contributors.join(", ")
//println quilt_contributors.join(", ")
// TODOI: Find something we can use so we can basically re-map only when the jar is shadowed and relocated
// TODO: Find something we can use so we can basically re-map only when the jar is shadowed and relocated
// println p.tasks.findByName('shadowJar')
@@ -377,6 +372,7 @@ subprojects { p ->
println "Git or Git project not found"
}
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
def replaceProperties = [
version : mod_version,
mod_name : mod_readable_name,
@@ -400,15 +396,17 @@ subprojects { p ->
fabric_incompatibility_list : fabric_incompatibility_list,
fabric_recommend_list : fabric_recommend_list,
]
// The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
// replace any properties in the sub-projects with the values defined here
inputs.properties replaceProperties
replaceProperties.put "project", project
replaceProperties.put("project", project)
filesMatching(resourceTargets) {
expand replaceProperties
}
intoTargets.each { target ->
// copy all our resources into the loader specific resource directory
buildResourceTargets.each { target ->
if (file(target).exists()) {
copy {
from(sourceSets.main.resources) {
@@ -465,13 +463,6 @@ subprojects { p ->
}
}
*/
// Run mergeJars when running build
// TODO: Fix later
// if (isMinecraftSubProject) {
// build.finalizedBy(mergeJars)
// assemble.finalizedBy(mergeJars)
// }
}
allprojects { p ->
@@ -579,6 +570,7 @@ allprojects { p ->
// Set the OS lwjgl is using to the current os
project.ext.lwjglNatives = "natives-" + os.toFamilyName()
// TODO: Include Minecraft in core-projects but dont include MC code stuff
dependencies { // All of these dependencies are in Vanilla Minecraft, but we need to depend on it as we arent importing Minecraft in the core
// Imports most of lwjgl's libraries (well, only the ones that we need)
implementation platform("org.lwjgl:lwjgl-bom:${rootProject.lwjgl_version}") // TODO: Use Minecraft's version for lwjgl_version (which changes in nearly every version) instead of a hard defined version for all versions
@@ -610,26 +602,22 @@ allprojects { p ->
}
// TODO: Remove this as no loader needs this
// - Fabric can rename which aw they use
// - (Neo)Forge converts the aw to their own at, which is stored at a different place
task copyCommonLoaderResources(type: Copy) {
from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
into(file(p.file("build/resources/main")))
rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener"
// Move the fabricLike mixin to its different places for each subproject
if (findProject(":fabricLike")) {
from project(":fabricLike").file("src/main/resources/DistantHorizons.fabricLike.mixins.json")
into(file(p.file("build/resources/main")))
rename "DistantHorizons.fabricLike.mixins.json", "DistantHorizons." + p.name + ".fabricLike.mixins.json"
}
}
// TODO: Remove this later as we no longer need this. We are now including the resources in the processResources section
task copyCoreResources(type: Copy) {
from fileTree(project(":core").file("src/main/resources"))
into p.file("build/resources/main")
}
tasks.withType(JavaCompile) {
compileJava {
if (isMinecraftSubProject) {
options.release = rootProject.java_version as Integer
options.compilerArgs += ["-Xplugin:Manifold"]