From e0a7010abfbd6d5b70e9eb1637314a5198e711ee Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Mon, 14 Feb 2022 17:36:37 +1030 Subject: [PATCH] Updated gradle stuff to be more like 1.18 --- build.gradle | 33 +++++++++++++++++++++++++++++++++ fabric/build.gradle | 39 +++++++++------------------------------ forge/build.gradle | 36 ++++++++---------------------------- gradle.properties | 23 +++++++++++++++++++++-- 4 files changed, 71 insertions(+), 60 deletions(-) diff --git a/build.gradle b/build.gradle index 4b69d9eb0..a8c06bcc3 100644 --- a/build.gradle +++ b/build.gradle @@ -98,6 +98,39 @@ allprojects { } } + // Put stuff from gradle.properties into the mod info + processResources { + def resourceTargets = ["fabric.mod.json", "META-INF/mods.toml"] // Location of where to put + def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder + def replaceProperties = [ + version: mod_version, + mod_name: mod_name, + authors: mod_authors, + description: mod_description, + homepage: mod_homepage, + source: mod_source, + issues: mod_issues + ] // 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 + } + } + } + } + tasks.withType(JavaCompile) { options.encoding = "UTF-8" options.release = 16 diff --git a/fabric/build.gradle b/fabric/build.gradle index f690a458f..32f739e58 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -24,6 +24,12 @@ repositories { maven { url "https://maven.terraformersmc.com/" } } +def addMod(path, enabled) { + if (enabled == "2") + dependencies { modImplementation(path) } + else if (enabled == "1") + dependencies { modCompileOnly(path) } +} dependencies { // Fabric loader @@ -38,14 +44,14 @@ dependencies { } // Sodium - modImplementation "curse.maven:sodium-394468:${rootProject.sodium_version}" + addMod("curse.maven:sodium-394468:${rootProject.sodium_version}", rootProject.enable_sodium) implementation "org.joml:joml:1.10.2" // Lithium -// modImplementation "maven.modrinth:lithium:${rootProject.lithium_version}" + addMod("maven.modrinth:lithium:${rootProject.lithium_version}", rootProject.enable_lithium) // Iris -// modImplementation "maven.modrinth:iris:${rootProject.iris_version}" + addMod("maven.modrinth:iris:${rootProject.iris_version}", rootProject.enable_iris) // Immersive Portals /* @@ -105,35 +111,8 @@ runClient { finalizedBy(deleteResources) } -// Put stuff from gradle.properties into the mod info stuff -def resourceTargets = ["fabric.mod.json"] -def intoTargets = ["$buildDir/resources/main/"] -def replaceProperties = [ - version: mod_version, - mod_name: mod_name, - authors: mod_authors, - description: mod_description -] - processResources { dependsOn(copyAccessWidener) - 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 - } - } - } } shadowJar { diff --git a/forge/build.gradle b/forge/build.gradle index ebee9ee80..130760908 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -19,6 +19,13 @@ architectury { forge() } +def addMod(path, enabled) { + if (enabled == "2") + dependencies { modImplementation(path) } + else if (enabled == "1") + dependencies { modCompileOnly(path) } +} + configurations { compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common @@ -33,7 +40,7 @@ dependencies { shadowMe(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } // Starlight -// modImplementation("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}") + addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge) // forgeDependencies(project(":core")) { transitive false } @@ -57,36 +64,9 @@ task copyCommonResources(type: Copy) { into file("build/resources/main") } -// Put stuff from gradle.properties into the mod info stuff -def resourceTargets = ["META-INF/mods.toml"] -def intoTargets = ["$buildDir/resources/main/"] -def replaceProperties = [ - version: mod_version, - mod_name: mod_name, - authors: mod_authors, - description: mod_description -] - processResources { dependsOn(copyCoreResources) dependsOn(copyCommonResources) - 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 - } - } - } } shadowJar { diff --git a/gradle.properties b/gradle.properties index 1354befcf..e3cf3e7d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,11 +12,14 @@ mod_name=Distant Horizons mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow. mod_authors=James Seibel, Leonardo Amato, Cola, coolGi2007, Ran, Leetom mod_homepage=https://www.curseforge.com/minecraft/mc-mods/distant-horizons +mod_source=https://gitlab.com/jeseibel/minecraft-lod-mod/ +mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues + # Fabric loader fabric_loader_version=0.12.6 fabric_api_version=0.37.1+1.17 - # Fabric mods + # Fabric mod versions modmenu_version=2.0.14 starlight_version_fabric=3442770 lithium_version=mc1.17.1-0.7.5 @@ -24,7 +27,23 @@ fabric_api_version=0.37.1+1.17 iris_version=1.17.x-v1.1.4 immersive_portals_version = 0.14-1.17 + # Fabric mod run + # 0 = Dont enable and dont run + # 1 = Can be refranced in code but dosnt run + # 2 = Can be refranced in code and runs in client + enable_starlight=0 + enable_lithium=0 + enable_sodium=1 + enable_iris=0 + + # Forge loader forge_version=37.1.1 - # Forge mods + # Forge mod versions starlight_version_forge=3457784 + + # Forge mod run + # 0 = Dont enable and dont run + # 1 = Can be refranced in code but dosnt run + # 2 = Can be refranced in code and runs in client + enable_starlight_forge=0