From 1bf83173988e40652f1371135057b6e874e73c15 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 26 Apr 2022 21:30:06 -0500 Subject: [PATCH] add DEV_BUILD as a preprocessor The preprocessor automatically activates if the mod version contains "dev" --- build.gradle | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index fa67fb0ed..24745bd66 100644 --- a/build.gradle +++ b/build.gradle @@ -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 mcVers, int mcIndex) { + ArrayList redefineList = new ArrayList() for (int i=0; i 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()