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
This commit is contained in:
JeromSar
2015-09-06 23:02:10 +02:00
parent 6aeb56de07
commit a7a2db15d6
7 changed files with 101 additions and 68 deletions

View File

@ -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;
}

View File

@ -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());

View File

@ -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 + ")";
}
}
}