gradle commenting and minor refactoring
This commit is contained in:
+44
-55
@@ -1,29 +1,31 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java"
|
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
|
id "com.github.johnrengelman.shadow" version '7.1.2' apply false
|
||||||
|
|
||||||
// Plugin to create merged jars
|
// Plugin to create merged jars
|
||||||
id "io.github.pacifistmc.forgix" version "1.2.6"
|
id "io.github.pacifistmc.forgix" version "1.2.6"
|
||||||
|
|
||||||
// Manifold preprocessor
|
// Unimined is our all in one solution to minecraft loaders
|
||||||
// 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
|
|
||||||
id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false
|
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.
|
* Creates the list of preprocessors to use.
|
||||||
*
|
*
|
||||||
* @param mcVers array of all MC versions
|
* @param mcVers array of all MC versions
|
||||||
* @param mcIndex array index of the currently active MC version
|
* @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
|
// Build the list of preprocessors to use
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -31,7 +33,7 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
|
|||||||
sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n");
|
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(".", "_");
|
String verStr = mcVers[i].replace(".", "_");
|
||||||
sb.append("MC_" + verStr + "=" + i.toString() + "\n");
|
sb.append("MC_" + verStr + "=" + i.toString() + "\n");
|
||||||
@@ -42,23 +44,15 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
|
|||||||
|
|
||||||
|
|
||||||
// Check if this is a development build
|
// 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
|
// WARNING: only use this for logging, we don't want to have confusion
|
||||||
// when a method doesn't work correctly in the release build.
|
// when a method doesn't work correctly in the release build.
|
||||||
sb.append("DEV_BUILD=\n");
|
sb.append("DEV_BUILD=\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
new File(projectDir, "build.properties").text = sb.toString()
|
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)
|
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)
|
// 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")
|
rootProject.versionStr = rootProject.mod_version + "-" + rootProject.minecraft_version // + "-" + new Date().format("yyyy_MM_dd_HH_mm")
|
||||||
|
|
||||||
// Forgix settings (used for merging jars)
|
// Forgix settings (used for merging jars)
|
||||||
forgix {
|
forgix {
|
||||||
group = "com.seibel.distanthorizons"
|
group = "com.seibel.distanthorizons"
|
||||||
@@ -96,7 +91,7 @@ forgix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subprojects { p ->
|
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
|
// Useful later on so we dont have duplicated code
|
||||||
def isMinecraftSubProject = p != project(":core") && p != project(":api")
|
def isMinecraftSubProject = p != project(":core") && p != project(":api")
|
||||||
|
|
||||||
@@ -104,19 +99,17 @@ subprojects { p ->
|
|||||||
// Apply plugins
|
// Apply plugins
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
apply plugin: "com.github.johnrengelman.shadow"
|
apply plugin: "com.github.johnrengelman.shadow"
|
||||||
// if (isMinecraftSubProject)
|
if (p == project(":core")) {
|
||||||
// apply plugin: "systems.manifold.manifold-gradle-plugin"
|
|
||||||
if (p == project(":core"))
|
|
||||||
apply plugin: "application"
|
apply plugin: "application"
|
||||||
// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
|
}
|
||||||
|
|
||||||
if (p != project(":common") && isMinecraftSubProject) {
|
if (p != project(":common") && isMinecraftSubProject) {
|
||||||
apply plugin: "xyz.wagyourtail.unimined"
|
apply plugin: "xyz.wagyourtail.unimined"
|
||||||
|
|
||||||
unimined.minecraft(sourceSets.main, true) {
|
unimined.minecraft(sourceSets.main, true) {
|
||||||
version minecraft_version
|
version = rootProject.minecraft_version
|
||||||
|
|
||||||
def parchmentVersionParts = parchment_version.split(":")
|
def parchmentVersionParts = rootProject.parchment_version.split(":")
|
||||||
mappings {
|
mappings {
|
||||||
mojmap()
|
mojmap()
|
||||||
parchment(parchmentVersionParts[0], parchmentVersionParts[1])
|
parchment(parchmentVersionParts[0], parchmentVersionParts[1])
|
||||||
@@ -135,7 +128,8 @@ subprojects { p ->
|
|||||||
enabled = false
|
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) {
|
if (isMinecraftSubProject) {
|
||||||
test {
|
test {
|
||||||
enabled = false
|
enabled = false
|
||||||
@@ -144,13 +138,7 @@ subprojects { p ->
|
|||||||
enabled = false
|
enabled = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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)
|
// set up custom configurations (configurations are a way to handle dependencies)
|
||||||
configurations {
|
configurations {
|
||||||
@@ -211,7 +199,7 @@ subprojects { p ->
|
|||||||
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
|
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
|
||||||
implementation("org.apache.logging.log4j:log4j-core:${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}")
|
implementation("org.joml:joml:${rootProject.joml_version}")
|
||||||
|
|
||||||
// JUnit tests
|
// JUnit tests
|
||||||
@@ -230,7 +218,7 @@ subprojects { p ->
|
|||||||
shade("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
|
shade("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
|
||||||
|
|
||||||
// SVG (not needed atm)
|
// SVG (not needed atm)
|
||||||
// shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
|
//shade("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
|
||||||
|
|
||||||
// Netty
|
// Netty
|
||||||
// Breaks 1.16.5
|
// 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"
|
||||||
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
|
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
|
||||||
exclude group: "junit", module: "junit"
|
exclude group: "junit", module: "junit"
|
||||||
|
|
||||||
// Removed dependencies
|
// Removed dependencies
|
||||||
transitive false
|
transitive false
|
||||||
}
|
}
|
||||||
@@ -267,6 +256,7 @@ subprojects { p ->
|
|||||||
exclude group: "org.junit.jupiter", module: "junit-jupiter"
|
exclude group: "org.junit.jupiter", module: "junit-jupiter"
|
||||||
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
|
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
|
||||||
exclude group: "junit", module: "junit"
|
exclude group: "junit", module: "junit"
|
||||||
|
|
||||||
// Removed dependencies
|
// Removed dependencies
|
||||||
transitive false
|
transitive false
|
||||||
}
|
}
|
||||||
@@ -289,6 +279,7 @@ subprojects { p ->
|
|||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configurations = [project.configurations.shadowMe, project.configurations.shade]
|
configurations = [project.configurations.shadowMe, project.configurations.shade]
|
||||||
|
|
||||||
if (isMinecraftSubProject && p != project(":common")) {
|
if (isMinecraftSubProject && p != project(":common")) {
|
||||||
configurations.push(project.configurations.shadowCommon) // Shadow the common subproject
|
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
|
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
|
relocate "com.seibel.distanthorizons.fabriclike", "loaderCommon.${p.name}.com.seibel.distanthorizons.fabriclike" // Move the loader files to a different location
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def librariesLocation = "distanthorizons.libraries"
|
def librariesLocation = "distanthorizons.libraries"
|
||||||
|
|
||||||
// LWJGL
|
// LWJGL
|
||||||
@@ -341,7 +334,7 @@ subprojects { p ->
|
|||||||
// The mixins for each of the loaders
|
// The mixins for each of the loaders
|
||||||
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
|
"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
|
// 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"]
|
// 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
|
// println compatible_forgemc_versions
|
||||||
|
|
||||||
// Quilt's custom contributors system
|
// Quilt's custom contributors system
|
||||||
// This has to be like
|
// has to be in the format:
|
||||||
// "Person": "Developer", "Another person": "Developer"
|
// "Person": "Developer", "Another person": "Developer"
|
||||||
def quilt_contributors = []
|
def quilt_contributors = []
|
||||||
def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
|
def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
|
||||||
@@ -357,9 +350,9 @@ subprojects { p ->
|
|||||||
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
|
quilt_contributors.push("\"${dev.strip()}\": \"Developer\"")
|
||||||
}
|
}
|
||||||
quilt_contributors.reverse()
|
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')
|
// println p.tasks.findByName('shadowJar')
|
||||||
|
|
||||||
|
|
||||||
@@ -374,6 +367,7 @@ subprojects { p ->
|
|||||||
println "Git or Git project not found"
|
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 = [
|
def replaceProperties = [
|
||||||
version : mod_version,
|
version : mod_version,
|
||||||
mod_name : mod_readable_name,
|
mod_name : mod_readable_name,
|
||||||
@@ -397,15 +391,17 @@ subprojects { p ->
|
|||||||
fabric_incompatibility_list : fabric_incompatibility_list,
|
fabric_incompatibility_list : fabric_incompatibility_list,
|
||||||
fabric_recommend_list : fabric_recommend_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
|
inputs.properties replaceProperties
|
||||||
replaceProperties.put "project", project
|
replaceProperties.put("project", project)
|
||||||
filesMatching(resourceTargets) {
|
filesMatching(resourceTargets) {
|
||||||
expand replaceProperties
|
expand replaceProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
intoTargets.each { target ->
|
|
||||||
|
// copy all our resources into the loader specific resource directory
|
||||||
|
buildResourceTargets.each { target ->
|
||||||
if (file(target).exists()) {
|
if (file(target).exists()) {
|
||||||
copy {
|
copy {
|
||||||
from(sourceSets.main.resources) {
|
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 ->
|
allprojects { p ->
|
||||||
@@ -489,7 +478,7 @@ allprojects { p ->
|
|||||||
javadoc.title = rootProject.mod_name + "-" + project.name
|
javadoc.title = rootProject.mod_name + "-" + project.name
|
||||||
|
|
||||||
// Some annotations arent "technically" part of the official java standard,
|
// Some annotations arent "technically" part of the official java standard,
|
||||||
// so we define it ourself here
|
// so we define it ourself here
|
||||||
javadoc {
|
javadoc {
|
||||||
configure( options ) {
|
configure( options ) {
|
||||||
tags(
|
tags(
|
||||||
|
|||||||
+5
-5
@@ -44,12 +44,13 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
// handles JVM and toolchain downloading
|
||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
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 loadProperties() {
|
||||||
def defaultMcVersion = "1.20.1" // 1.20.1 is our current most stable version so we use that if no version was defined
|
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.mcVers = mcVers
|
||||||
gradle.ext.mcIndex = mcIndex
|
gradle.ext.mcIndex = mcIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
loadProperties()
|
loadProperties()
|
||||||
|
|
||||||
|
|
||||||
@@ -102,9 +102,9 @@ project(":api").projectDir = file('coreSubProjects/api')
|
|||||||
include("common")
|
include("common")
|
||||||
// Enables or disables the subprojects depending on whats in the versionProperties/mcVer.properties
|
// Enables or disables the subprojects depending on whats in the versionProperties/mcVer.properties
|
||||||
for (loader in ((String) gradle.builds_for).split(",")) {
|
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
|
def loaderName = loader.strip() // Strip it in case a space is added before or after the comma
|
||||||
println "Adding loader " + l
|
println "Adding loader " + loaderName
|
||||||
include(l)
|
include(loaderName)
|
||||||
}
|
}
|
||||||
//if (gradle.builds_for.contains("fabric") || gradle.builds_for.contains("quilt"))
|
//if (gradle.builds_for.contains("fabric") || gradle.builds_for.contains("quilt"))
|
||||||
// include("fabricLike")
|
// include("fabricLike")
|
||||||
|
|||||||
Reference in New Issue
Block a user