add DEV_BUILD as a preprocessor

The preprocessor automatically activates if the mod version contains "dev"
This commit is contained in:
James Seibel
2022-04-26 21:30:06 -05:00
parent 5a0d7b0d67
commit 1bf8317398
+21 -2
View File
@@ -12,7 +12,14 @@ plugins {
id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false
}
/**
* Creates the list of preprocessors to use.
*
* @param mcVers array of all MC versions
* @param mcIndex array index of the currently active MC version
*/
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
ArrayList<String> redefineList = new ArrayList<String>()
for (int i=0; i<mcVers.size(); i++) {
String mcStr = mcVers.get(i).replace(".", "_")
@@ -26,9 +33,21 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
redefineList.add("POST_MC_"+mcStr)
}
}
// build the list of preprocessors to use
StringBuilder sb = new StringBuilder()
for (String s : redefineList) {
sb.append(s)
// check if this is a development build
if (mod_version.toLowerCase().contains("dev")) {
// WARNING: only use this for logging, we don't want to have confusion
// when a method doesn't work correctly in the release build.
sb.append("DEV_BUILD")
sb.append("=\n")
}
// build the MC version preprocessors
for (String redefinedVersion : redefineList) {
sb.append(redefinedVersion)
sb.append("=\n")
}
new File(projectDir, "build.properties").text = sb.toString()