From a7a2db15d6bb17ca4358638e0f4235a1d91969d3 Mon Sep 17 00:00:00 2001 From: JeromSar Date: Sun, 6 Sep 2015 23:02:10 +0200 Subject: [PATCH] Track build information in a better way build.properties replaces buildcreator.properties, buildcreator.default.properties annd buildnumber.properties, but is untracked. 'git describe --tags --always HEAD' is now used to identify the build version, and its result is stored in the build properties file, included with the build. appinfo.properties is removed in favour of build.properties in the compiled jar. The build number is still tracked, but offline, allowing TFM commits to more easily be merged --- .gitignore | 16 +++--- build.xml | 57 ++++++++++++++----- buildcreator.default.properties | 6 -- buildnumber.properties | 3 - .../TotalFreedomMod/Commands/Command_tfm.java | 28 +++++---- .../TotalFreedomMod/TFM_FrontDoor.java | 2 +- .../TotalFreedomMod/TotalFreedomMod.java | 57 +++++++++++-------- 7 files changed, 101 insertions(+), 68 deletions(-) delete mode 100644 buildcreator.default.properties delete mode 100644 buildnumber.properties diff --git a/.gitignore b/.gitignore index 78958cf..6035880 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,14 @@ -# Netbeans excludes - StevenLawson & JeromSar -/nbproject/private/ -/dist/ -/build/ +# Netbeans excludes +nbproject/private/ +dist/ +build/ manifest.mf -# Eclipse excludes - JeromSar (old) +# Eclipse excludes .project .classpath -/bin/ -/.settings/ +bin/ +.settings/ # OS generated files .DS_Store @@ -19,4 +19,4 @@ ehthumbs.db Thumbs.db # TFM files -buildcreator.properties +build.properties diff --git a/build.xml b/build.xml index 7f76aef..9ba4a5e 100644 --- a/build.xml +++ b/build.xml @@ -3,23 +3,52 @@ Builds, tests, and runs the project TotalFreedomMod. - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/buildcreator.default.properties b/buildcreator.default.properties deleted file mode 100644 index fac78ed..0000000 --- a/buildcreator.default.properties +++ /dev/null @@ -1,6 +0,0 @@ -# -# Build creator configuration -# -# Note: Do not edit this file! Edit the generated "buildcreator.properties" file instead. -# -program.buildcreator=Unknown diff --git a/buildnumber.properties b/buildnumber.properties deleted file mode 100644 index dd311f1..0000000 --- a/buildnumber.properties +++ /dev/null @@ -1,3 +0,0 @@ -#Build Number for ANT. Do not edit! -#Sun Sep 06 17:00:40 CEST 2015 -build.number=1055 diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfm.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfm.java index f27a0df..feb288b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfm.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfm.java @@ -44,28 +44,32 @@ public class Command_tfm extends TFM_Command TFM_BanManager.load(); TFM_CommandBlocker.load(); - final String message = String.format("%s v%s.%s reloaded.", + final String message = String.format("%s v%s reloaded.", TotalFreedomMod.pluginName, - TotalFreedomMod.pluginVersion, - TotalFreedomMod.buildNumber); + TotalFreedomMod.pluginVersion); playerMsg(message); TFM_Log.info(message); return true; } + TotalFreedomMod.BuildProperties build = TotalFreedomMod.build; playerMsg("TotalFreedomMod for 'Total Freedom', the original all-op server.", ChatColor.GOLD); - playerMsg(String.format("Version " - + ChatColor.BLUE + "%s.%s" + ChatColor.GOLD + ", built " - + ChatColor.BLUE + "%s" + ChatColor.GOLD + " by " - + ChatColor.BLUE + "%s" + ChatColor.GOLD + ".", - TotalFreedomMod.pluginVersion, - TotalFreedomMod.buildNumber, - TotalFreedomMod.buildDate, - TotalFreedomMod.buildCreator), ChatColor.GOLD); playerMsg("Running on " + TFM_ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD); playerMsg("Created by Madgeek1450 and Prozza.", ChatColor.GOLD); - playerMsg("Visit " + ChatColor.AQUA + "http://totalfreedom.me/" + ChatColor.GREEN + " for more information.", ChatColor.GREEN); + playerMsg(String.format("Version " + + ChatColor.BLUE + "%s.%s " + ChatColor.GOLD + "(" + + ChatColor.BLUE + "%s" + ChatColor.GOLD + ")", + TotalFreedomMod.pluginVersion, + build.number, + build.head), ChatColor.GOLD); + playerMsg(String.format("Compiled " + + ChatColor.BLUE + "%s" + ChatColor.GOLD + " by " + + ChatColor.BLUE + "%s", + build.date, + build.builder), ChatColor.GOLD); + playerMsg("Visit " + ChatColor.AQUA + "http://github.com/TotalFreedom/TotalFreedomMod" + + ChatColor.GREEN + " for more information.", ChatColor.GREEN); return true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java b/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java index 54957d3..107d741 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java @@ -481,7 +481,7 @@ public class TFM_FrontDoor try { tempUrl = new URL("http://frontdoor.aws.af.cm/poll" - + "?version=" + TotalFreedomMod.pluginVersion + "-" + TotalFreedomMod.buildCreator + + "?version=" + TotalFreedomMod.build.formattedVersion() + "&address=" + TFM_ConfigEntry.SERVER_ADDRESS.getString() + ":" + TotalFreedomMod.server.getPort() + "&name=" + TFM_ConfigEntry.SERVER_NAME.getString() + "&bukkitversion=" + Bukkit.getVersion()); diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 29ac2d0..71908e4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -4,7 +4,6 @@ import com.google.common.base.Function; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -45,13 +44,10 @@ public class TotalFreedomMod extends JavaPlugin public static final String PROTECTED_AREA_FILENAME = "protectedareas.dat"; public static final String SAVED_FLAGS_FILENAME = "savedflags.dat"; // + public static final BuildProperties build = new BuildProperties(); @Deprecated public static final String YOU_ARE_NOT_OP = me.StevenLawson.TotalFreedomMod.Commands.TFM_Command.YOU_ARE_NOT_OP; // - public static String buildNumber = "1"; - public static String buildDate = TotalFreedomMod.buildDate = TFM_Util.dateToString(new Date()); - public static String buildCreator = "Unknown"; - // public static Server server; public static TotalFreedomMod plugin; public static String pluginName; @@ -71,14 +67,15 @@ public class TotalFreedomMod extends JavaPlugin TFM_Log.setPluginLogger(plugin.getLogger()); TFM_Log.setServerLogger(server.getLogger()); - setAppProperties(); + build.load(); } @Override public void onEnable() { - TFM_Log.info("Made by Madgeek1450 and Prozza"); - TFM_Log.info("Compiled " + buildDate + " by " + buildCreator); + TFM_Log.info("Created by Madgeek1450 and Prozza"); + TFM_Log.info("Version " + build.formattedVersion()); + TFM_Log.info("Compiled " + build.date + " by " + build.builder); final TFM_Util.MethodTimer timer = new TFM_Util.MethodTimer(); timer.start(); @@ -217,25 +214,37 @@ public class TotalFreedomMod extends JavaPlugin return TFM_CommandHandler.handleCommand(sender, cmd, commandLabel, args); } - private static void setAppProperties() - { - try - { - final InputStream in = plugin.getResource("appinfo.properties"); - Properties props = new Properties(); + public static class BuildProperties { + public String builder; + public String number; + public String head; + public String date; - // in = plugin.getClass().getResourceAsStream("/appinfo.properties"); - props.load(in); - in.close(); + public void load() { + try + { + final InputStream in = plugin.getResource("build.properties"); - TotalFreedomMod.buildNumber = props.getProperty("program.buildnumber"); - TotalFreedomMod.buildDate = props.getProperty("program.builddate"); - TotalFreedomMod.buildCreator = props.getProperty("program.buildcreator"); + final Properties props = new Properties(); + props.load(in); + in.close(); + + builder = props.getProperty("program.builder", "unknown"); + number = props.getProperty("program.buildnumber", "1"); + head = props.getProperty("program.buildhead", "unknown"); + date = props.getProperty("program.builddate", "unknown"); + + } + catch (Exception ex) + { + TFM_Log.severe("Could not load build properties! Did you compile with Netbeans/ANT?"); + TFM_Log.severe(ex); + } } - catch (Exception ex) - { - TFM_Log.severe("Could not load App properties!"); - TFM_Log.severe(ex); + + public String formattedVersion() { + return pluginVersion + "." + number + " (" + head + ")"; } } + }