Cleaned up some shadow code

This commit is contained in:
coolGi
2023-02-28 16:54:43 +10:30
parent cdbfad060b
commit 4d195a6378
5 changed files with 55 additions and 72 deletions
+50 -11
View File
@@ -117,9 +117,6 @@ subprojects { p ->
shadowMe
// have implemented dependencies automatically embedded in the final jar
implementation.extendsFrom(shadowMe)
customModule
implementation.extendsFrom(customModule)
if (isMinecraftSubProject) {
// Shadow common
@@ -185,25 +182,65 @@ subprojects { p ->
// Add core
if (isMinecraftSubProject) {
implementation(project(":core")) {
shadowMe(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
}
}
// Add the api
if (p != project(":api")) {
implementation(project(":api")) {
shadowMe(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
}
}
// Add common
if (isMinecraftSubProject && p != project(":common")) {
// Common
// implementation project(":common")
common(project(path: ":common")) { transitive false }
shadowCommon(project(path: ":common")) { transitive false }
}
}
shadowJar {
configurations = [project.configurations.shadowMe]
if (isMinecraftSubProject && p != project(":common")) {
configurations.push(project.configurations.shadowCommon) // Shadow the common subproject
relocate "com.seibel.lod.common", "loaderCommon.${p.name}.com.seibel.lod.common" // Move the loader files to a different location
}
// Compression
relocate 'org.tukaani', 'distanthorizons.libraries.tukaani'
// NightConfig (includes Toml & Json)
relocate 'com.electronwill.nightconfig', 'distanthorizons.libraries.electronwill.nightconfig'
// Theming
relocate 'com.formdev.flatlaf', 'distanthorizons.libraries.formdev.flatlaf'
// SVG
relocate 'com.kitfox.svg', 'distanthorizons.libraries.kitfox.svg'
mergeServiceFiles()
}
// Using jar.finalizedBy(shadowJar) causes issues so we do this scuffed bypass
jar.dependsOn(shadowJar)
// Adds the standalone jar's entrypoint
jar {
from "LICENSE.txt"
@@ -351,15 +388,17 @@ allprojects { p ->
}
}
// 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("]", ",)")
// System.out.println(compatible_forgemc_versions)
// 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
def replaceProperties = [
version : mod_version,
mod_name : mod_readable_name,
@@ -377,7 +416,7 @@ allprojects { p ->
// 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
replaceProperties.put "project", project
filesMatching(resourceTargets) {
expand replaceProperties
}
@@ -412,7 +451,7 @@ allprojects { p ->
options.compilerArgs += ['-Xplugin:Manifold']
} else {
options.release = 8; // Core & Api should use Java 8 no matter what
//options.release = rootProject.java_version as Integer // But if minecraft
//options.release = rootProject.java_version as Integer // But if you want to test some stuff, then this can be enabled
}
options.encoding = "UTF-8"
}
+1 -31
View File
@@ -48,9 +48,6 @@ dependencies {
// Fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// Common
implementation project(":common")
// Architectury API
// if (minecraft_version == "1.16.5") {
// addModJar("me.shedaniel:architectury-fabric:${rootProject.architectury_version}")
@@ -110,35 +107,8 @@ dependencies {
transitive(false)
}
*/
common(project(path: ":common")) { transitive false }
shadowCommon(project(path: ":common")) { transitive false }
// shadowCommon(project(path: ":common"), configuration: "transformProductionFabric") { transitive false } // FIXME
// TODO: These exist in the main build.gradle so fix shadow there
shadowMe(project(path: ":core")) { transitive false }
shadowMe(project(path: ":api")) { transitive false }
}
//shadowJar {
// configurations = [project.configurations.shadowCommon, project.configurations.shadowMe, project.configurations.customModule]
// relocate 'com.seibel.lod.common', 'loaderCommon.fabric.com.seibel.lod.common'
//
// // Compression
// relocate 'org.tukaani', 'distanthorizons.libraries.tukaani'
//
// // NightConfig (includes Toml & Json)
// relocate 'com.electronwill.nightconfig', 'distanthorizons.libraries.electronwill.nightconfig'
//
// // Theming
// relocate 'com.formdev.flatlaf', 'distanthorizons.libraries.formdev.flatlaf'
//
// // SVG
// relocate 'com.kitfox.svg', 'distanthorizons.libraries.kitfox.svg'
//
// mergeServiceFiles()
//}
task deleteResources(type: Delete) {
delete file("build/resources/main")
@@ -184,4 +154,4 @@ publishing {
repositories {
// Add repositories to publish to here.
}
}
}
-26
View File
@@ -130,11 +130,6 @@ dependencies {
// if (System.getProperty("idea.sync.active") != "true") {
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
// }
common(project(path: ":common")) { transitive false }
shadowCommon(project(path: ":common")) { transitive false }
shadowMe(project(path: ":core")) { transitive false }
shadowMe(project(path: ":api")) { transitive false }
}
processResources {
@@ -142,27 +137,6 @@ processResources {
dependsOn(copyAccessWidener)
}
shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon, project.configurations.shadowMe, project.configurations.customModule]
relocate "om.seibel.lod.common", "loaderCommon.forge.com.seibel.lod.common"
// Compression
relocate "org.tukaani", "distanthorizons.libraries.tukaani"
// NightConfig (includes Toml & Json)
relocate "com.electronwill.nightconfig", "distanthorizons.libraries.electronwill.nightconfig"
// Theming
relocate "com.formdev.flatlaf", "distanthorizons.libraries.formdev.flatlaf"
// svg
relocate "com.kitfox.svg", "distanthorizons.libraries.kitfox.svg"
mergeServiceFiles()
}
//remapJar {
// input.set shadowJar.archiveFile
// dependsOn shadowJar
+3 -3
View File
@@ -77,10 +77,10 @@ include("common")
// Enables or disables the subprojects depending on whats in the version.properties
if (gradle.builds_for.contains("fabric"))
include("fabric")
//if (gradle.builds_for.contains("quilt"))
// include("quilt") // Just put this here for once we need it ;)
if (gradle.builds_for.contains("quilt"))
include("quilt") // Just put this here for once we need it ;)
//if (gradle.builds_for.contains("forge"))
// include("forge")
// include("forge") // FIXME: Find some time to fix forge
rootProject.name = "DistantHorizons"