diff --git a/build.gradle b/build.gradle index d3982d8a5..b17cddaa6 100644 --- a/build.gradle +++ b/build.gradle @@ -269,6 +269,77 @@ subprojects { p -> jar.dependsOn(shadowJar) + // Put stuff from gradle.properties into the mod info + processResources { + def resourceTargets = [ // Location of where to inject the properties + // Properties for each of the loaders + "fabric.mod.json", + "quilt.mod.json", + "META-INF/mods.toml", + + // The mixins for each of the loaders + "DistantHorizons."+ p.name +".fabricLike.mixins.json" + ] + def intoTargets = ["$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"] which make more sense + def compatible_forgemc_versions = "${compatible_minecraft_versions}".replaceAll("\"", "").replaceAll("]", ",)") +// println compatible_forgemc_versions + + // Quilt's custom contributors system + // This has to be like + // "Person": "Developer", "Another person": "Developer" + def quilt_contributors = [] + def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",") + for (dev in mod_author_list) { + quilt_contributors.push("\"${dev.strip()}\": \"Developer\"") + } + quilt_contributors.reverse() +// println quilt_contributors.join(", ") + + // TODOI: Find something we can use so we can basically re-map only when the jar is shadowed and relocated +// println p.tasks.findByName('shadowJar') + + + def replaceProperties = [ + version : mod_version, + mod_name : mod_readable_name, + group : maven_group, + authors : mod_authors, + description : mod_description, + homepage : mod_homepage, + source : mod_source, + issues : mod_issues, + discord : mod_discord, + minecraft_version : minecraft_version, + compatible_minecraft_versions: compatible_minecraft_versions, + compatible_forgemc_versions : compatible_forgemc_versions, + java_version : java_version, + quilt_contributors : "{"+quilt_contributors.join(", ")+"}" + ] + // 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 + + inputs.properties replaceProperties + replaceProperties.put "project", project + filesMatching(resourceTargets) { + expand replaceProperties + } + + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } + } + } + + // Adds the standalone jar's entrypoint jar { from "LICENSE.txt" @@ -422,68 +493,17 @@ allprojects { p -> } - // Put stuff from gradle.properties into the mod info - processResources { - def resourceTargets = ["fabric.mod.json", "quilt.mod.json", "META-INF/mods.toml"] // Location of where to inject the properties - def intoTargets = ["$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"] which make more sense - def compatible_forgemc_versions = "${compatible_minecraft_versions}".replaceAll("\"", "").replaceAll("]", ",)") -// println compatible_forgemc_versions - - // Quilt's custom contributors system - // This has to be like - // "Person": "Developer", "Another person": "Developer" - def quilt_contributors = [] - def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",") - for (dev in mod_author_list) { - quilt_contributors.push("\"${dev.strip()}\": \"Developer\"") - } - quilt_contributors.reverse() -// println quilt_contributors.join(", ") - - def replaceProperties = [ - version : mod_version, - mod_name : mod_readable_name, - group : maven_group, - authors : mod_authors, - description : mod_description, - homepage : mod_homepage, - source : mod_source, - issues : mod_issues, - discord : mod_discord, - minecraft_version : minecraft_version, - compatible_minecraft_versions: compatible_minecraft_versions, - compatible_forgemc_versions : compatible_forgemc_versions, - java_version : java_version, - quilt_contributors : "{"+quilt_contributors.join(", ")+"}" - ] - // 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 - - inputs.properties replaceProperties - replaceProperties.put "project", project - filesMatching(resourceTargets) { - expand replaceProperties - } - - intoTargets.each { target -> - if (file(target).exists()) { - copy { - from(sourceSets.main.resources) { - include resourceTargets - expand replaceProperties - } - into target - } - } - } - } - - task copyAccessWidener(type: Copy) { + task copyCommonLoaderResources(type: Copy) { from project(":common").file("src/main/resources/${accessWidenerVersion}.lod.accesswidener") into(file(p.file("build/resources/main"))) rename "${accessWidenerVersion}.lod.accesswidener", "lod.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" + } } task copyCoreResources(type: Copy) { @@ -491,6 +511,17 @@ allprojects { p -> into p.file("build/resources/main") } + // TODO: This method doesnt seem to actually remove it from the jar, probably called at incorrect spots + task deleteDuplicatedCommonLoaderResources(type: Delete) { + // Delete the duplicated fabricLike.mixins.json + delete p.file("build/resources/main/DistantHorizons.fabricLike.mixins.json") + + // Delete all the duplicated accesswideners + delete fileTree(p.file("build/resources/main")) { + include "*.lod.accesswidener" + } + } + tasks.withType(JavaCompile) { if (isMinecraftSubProject) { options.release = rootProject.java_version as Integer diff --git a/fabric/build.gradle b/fabric/build.gradle index 9c7af8a26..992dcef52 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -115,12 +115,14 @@ task deleteResources(type: Delete) { processResources { dependsOn(copyCoreResources) - dependsOn(copyAccessWidener) + dependsOn(copyCommonLoaderResources) + dependsOn(deleteDuplicatedCommonLoaderResources) } runClient { dependsOn(copyCoreResources) - dependsOn(copyAccessWidener) + dependsOn(copyCommonLoaderResources) + dependsOn(deleteDuplicatedCommonLoaderResources) jvmArgs "-XX:-OmitStackTraceInFastThrow" finalizedBy(deleteResources) } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 13fa0641d..9efe99039 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -33,7 +33,7 @@ }, "mixins": [ - "DistantHorizons.fabricLike.mixins.json", + "DistantHorizons.fabric.fabricLike.mixins.json", "DistantHorizons.fabric.mixins.json" ], diff --git a/forge/build.gradle b/forge/build.gradle index 5f48ec634..798573793 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -134,7 +134,8 @@ dependencies { processResources { dependsOn(copyCoreResources) - dependsOn(copyAccessWidener) + dependsOn(copyCommonLoaderResources) + dependsOn(deleteDuplicatedCommonLoaderResources) } //remapJar { diff --git a/quilt/build.gradle b/quilt/build.gradle index 16daba2a9..3e8de18d0 100644 --- a/quilt/build.gradle +++ b/quilt/build.gradle @@ -92,12 +92,14 @@ task deleteResources(type: Delete) { processResources { dependsOn(copyCoreResources) - dependsOn(copyAccessWidener) + dependsOn(copyCommonLoaderResources) + dependsOn(deleteDuplicatedCommonLoaderResources) } runClient { dependsOn(copyCoreResources) - dependsOn(copyAccessWidener) + dependsOn(copyCommonLoaderResources) + dependsOn(deleteDuplicatedCommonLoaderResources) jvmArgs "-XX:-OmitStackTraceInFastThrow" finalizedBy(deleteResources) } diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json index 2294d24b4..642b60169 100644 --- a/quilt/src/main/resources/quilt.mod.json +++ b/quilt/src/main/resources/quilt.mod.json @@ -57,7 +57,7 @@ "access_widener": "lod.accesswidener", "mixin": [ - "DistantHorizons.fabricLike.mixins.json", + "DistantHorizons.quilt.fabricLike.mixins.json", "DistantHorizons.quilt.mixins.json" ],