Load plugin version through plugin.yml

This commit is contained in:
Jerome van der Sar 2013-11-30 18:04:43 +01:00
parent 7e75287e61
commit 6fca19fa41
6 changed files with 23 additions and 89 deletions

View File

@ -1,5 +0,0 @@
#Tue, 08 Oct 2013 13:58:56 -0400
program.VERSION=3.3
program.BUILDNUM=616
program.BUILDDATE=10/08/2013 01\:58 PM

View File

@ -1,83 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="TotalFreedomMod" default="default" basedir="."> <project name="TotalFreedomMod" default="default" basedir=".">
<description>Builds, tests, and runs the project TotalFreedomMod.</description> <description>Builds, tests, and runs the project TotalFreedomMod.</description>
<import file="nbproject/build-impl.xml"/> <import file="nbproject/build-impl.xml" />
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="TotalFreedomMod-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<target name="-pre-jar"> <target name="-pre-jar">
<buildnumber file="buildnumber.properties" /> <buildnumber file="buildnumber.properties" />
<propertyfile file="appinfo.properties"> <propertyfile file="appinfo.properties">
<entry key="program.VERSION" default="0.0" /> <entry key="program.buildnumber" value="${build.number}" />
<entry key="program.BUILDNUM" value="${build.number}" /> <entry key="program.builddate" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
<entry key="program.BUILDDATE" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
</propertyfile> </propertyfile>
<copy file="appinfo.properties" todir="${build.classes.dir}" /> <copy file="appinfo.properties" todir="${build.classes.dir}" />
<delete file="appinfo.properties" />
</target>
<target name="-post-jar">
<!-- Cleanup -->
<delete file="${dist.dir}/README.TXT" />
<delete dir="${dist.dir}/lib/" />
</target> </target>
</project> </project>

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Tue Oct 08 13:58:56 EDT 2013 #Sat Nov 30 16:57:41 CET 2013
build.number=617 build.number=622

View File

@ -85,7 +85,6 @@ jnlp.signed=false
jnlp.signing= jnlp.signing=
jnlp.signing.alias= jnlp.signing.alias=
jnlp.signing.keystore= jnlp.signing.keystore=
main.class=totalfreedommod.TotalFreedomMod
manifest.file=manifest.mf manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=true mkdist.disabled=true

View File

@ -77,7 +77,7 @@ public class TFM_EssentialsBridge
final User user = getEssentialsUser(username); final User user = getEssentialsUser(username);
if (user != null) if (user != null)
{ {
return TFM_Util.getField(user, "lastActivity"); return TFM_Util.<Long>getField(user, "lastActivity"); // This is weird
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -66,9 +66,10 @@ public class TotalFreedomMod extends JavaPlugin
{ {
TotalFreedomMod.plugin = this; TotalFreedomMod.plugin = this;
TotalFreedomMod.pluginName = plugin.getDescription().getName(); TotalFreedomMod.pluginName = plugin.getDescription().getName();
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
TFM_Log.setPluginLogger(this.getLogger()); TFM_Log.setPluginLogger(plugin.getLogger());
TFM_Log.setServerLogger(this.getServer().getLogger()); TFM_Log.setServerLogger(server.getLogger());
setAppProperties(); setAppProperties();
} }
@ -165,7 +166,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_FrontDoor.getInstance().start(); TFM_FrontDoor.getInstance().start();
TFM_Log.info("Plugin enabled."); TFM_Log.info("Version " + pluginVersion + " enabled");
// Delayed Start : // Delayed Start :
new BukkitRunnable() new BukkitRunnable()
@ -186,7 +187,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_HTTPD_Manager.getInstance().stop(); TFM_HTTPD_Manager.getInstance().stop();
TFM_Log.info("Plugin disabled."); TFM_Log.info("Plugin disabled");
} }
@Override @Override
@ -322,14 +323,16 @@ public class TotalFreedomMod extends JavaPlugin
props.load(in); props.load(in);
in.close(); in.close();
TotalFreedomMod.pluginVersion = props.getProperty("program.VERSION"); TotalFreedomMod.buildNumber = props.getProperty("program.buildnumber");
TotalFreedomMod.buildNumber = props.getProperty("program.BUILDNUM"); TotalFreedomMod.buildDate = props.getProperty("program.builddate");
TotalFreedomMod.buildDate = props.getProperty("program.BUILDDATE");
} }
catch (Exception ex) catch (Exception ex)
{ {
TFM_Log.severe("Could not load App properties!"); TFM_Log.severe("Could not load App properties!");
TFM_Log.severe(ex); TFM_Log.severe(ex);
TotalFreedomMod.buildNumber = "1";
TotalFreedomMod.buildDate = TFM_Util.dateToString(new Date());
} }
} }
} }