gradle commenting and minor refactoring

This commit is contained in:
James Seibel
2024-02-04 15:52:27 -06:00
parent a38551b3d0
commit 794f524ae3
2 changed files with 49 additions and 60 deletions
+35 -46
View File
@@ -1,22 +1,24 @@
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
// Use unimined which is our one in all solution to minecraft loaders
// Unimined is our all in one solution to minecraft loaders
id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false
}
// 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.
*
@@ -51,14 +53,6 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
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 +60,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 +91,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(":quilt") || p == project(":forge") || p == project("WhateverLoaderWeAddLaterOn")"
// Useful later on so we dont have duplicated code
def isMinecraftSubProject = p != project(":core") && p != project(":api")
@@ -104,19 +99,17 @@ 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 (p != project(":common") && isMinecraftSubProject) {
apply plugin: "xyz.wagyourtail.unimined"
unimined.minecraft(sourceSets.main, true) {
version minecraft_version
version = rootProject.minecraft_version
def parchmentVersionParts = parchment_version.split(":")
def parchmentVersionParts = rootProject.parchment_version.split(":")
mappings {
mojmap()
parchment(parchmentVersionParts[0], parchmentVersionParts[1])
@@ -135,7 +128,8 @@ subprojects { p ->
enabled = false
}
// Disable testing for projects that isn't the core or api project
// 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
@@ -146,12 +140,6 @@ subprojects { p ->
}
// Set the manifold version (may not be required tough)
// manifold {
// manifoldVersion = rootProject.manifold_version
// }
// set up custom configurations (configurations are a way to handle dependencies)
configurations {
// extends the shadowJar configuration
@@ -211,7 +199,7 @@ subprojects { p ->
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}")
// JOML
// JOML (doesn't have to be shaded in because NightConfig already includes it)
implementation("org.joml:joml:${rootProject.joml_version}")
// JUnit tests
@@ -230,7 +218,7 @@ subprojects { p ->
shade("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
// SVG (not needed atm)
// shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
//shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
// Netty
// Breaks 1.16.5
@@ -255,6 +243,7 @@ subprojects { p ->
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
}
@@ -267,6 +256,7 @@ subprojects { p ->
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
}
@@ -289,6 +279,7 @@ subprojects { p ->
shadowJar {
configurations = [project.configurations.shadowMe, project.configurations.shade]
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
@@ -298,6 +289,8 @@ subprojects { p ->
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
@@ -341,7 +334,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"]
@@ -349,7 +342,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(",")
@@ -357,9 +350,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')
@@ -374,6 +367,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,
@@ -397,15 +391,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) {
@@ -462,13 +458,6 @@ subprojects { p ->
}
}
*/
// Run mergeJars when running build
// TODO: Fix later
// if (isMinecraftSubProject) {
// build.finalizedBy(mergeJars)
// assemble.finalizedBy(mergeJars)
// }
}
allprojects { p ->
+5 -5
View File
@@ -44,12 +44,13 @@ pluginManagement {
}
plugins {
// handles JVM and toolchain downloading
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
// Loads the version.properties
/** Loads the VersionProperties fiel for the currently selected Minecraft version. */
def loadProperties() {
def defaultMcVersion = "1.20.1" // 1.20.1 is our current most stable version so we use that if no version was defined
@@ -86,7 +87,6 @@ def loadProperties() {
gradle.ext.mcVers = mcVers
gradle.ext.mcIndex = mcIndex
}
loadProperties()
@@ -102,9 +102,9 @@ project(":api").projectDir = file('coreSubProjects/api')
include("common")
// Enables or disables the subprojects depending on whats in the versionProperties/mcVer.properties
for (loader in ((String) gradle.builds_for).split(",")) {
def l = loader.strip() // Strip it in case a space is added before or after the comma
println "Adding loader " + l
include(l)
def loaderName = loader.strip() // Strip it in case a space is added before or after the comma
println "Adding loader " + loaderName
include(loaderName)
}
//if (gradle.builds_for.contains("fabric") || gradle.builds_for.contains("quilt"))
// include("fabricLike")