package org.mcupdater.downloadlib;

import java.io.IOException;
import java.util.Properties;

public class Version
{
	public static final int MAJOR_VERSION;
	public static final int MINOR_VERSION;
	public static final int BUILD_VERSION;
	public static final String BUILD_BRANCH;
	public static final String BUILD_LABEL;
	static {
		Properties prop = new Properties();
		try {
			prop.load(Version.class.getResourceAsStream("/version.properties"));
		} catch (IOException e) {
		}
		MAJOR_VERSION = Integer.valueOf(prop.getProperty("major","0"));
		MINOR_VERSION = Integer.valueOf(prop.getProperty("minor","0"));
		BUILD_VERSION = Integer.valueOf(prop.getProperty("build_version","0"));
		BUILD_BRANCH = prop.getProperty("git_branch","unknown");
		if( BUILD_BRANCH.equals("unknown") || BUILD_BRANCH.equals("master") ) {
			BUILD_LABEL = "";
		} else {
			BUILD_LABEL = " ("+BUILD_BRANCH+")";
		}
	}
	
	public static final String API_VERSION = MAJOR_VERSION + "." + MINOR_VERSION;
	public static final String VERSION = "v"+MAJOR_VERSION+"."+MINOR_VERSION+"."+BUILD_VERSION;
}

@@ -475,29 +475,86 @@
 %7B%0A%09%09%7D%0A%09%09
-MAJOR_VERSION
+int major;%0A%09%09int minor;%0A%09%09int build;%0A%09%09String branch;%0A%09%09try %7B%0A%09%09%09major
  = Integ
@@ -585,24 +585,25 @@
 rty(%22major%22,
+ 
 %220%22));%0A%09%09MIN
@@ -599,29 +599,22 @@
 0%22));%0A%09%09
-MINOR_VERSION
+%09minor
  = Integ
@@ -649,16 +649,17 @@
 %22minor%22,
+ 
 %220%22));%0A%09
@@ -659,29 +659,22 @@
 0%22));%0A%09%09
-BUILD_VERSION
+%09build
  = Integ
@@ -717,16 +717,17 @@
 ersion%22,
+ 
 %220%22));%0A%09
@@ -727,28 +727,23 @@
 0%22));%0A%09%09
-BUILD_BRANCH
+%09branch
  = prop.
@@ -767,16 +767,17 @@
 branch%22,
+ 
 %22unknown
@@ -780,16 +780,211 @@
 nown%22);%0A
+%09%09%7D catch (Exception e) %7B%0A%09%09%09major = 1;%0A%09%09%09minor = 3;%0A%09%09%09build = 0;%0A%09%09%09branch = %22develop%22;%0A%09%09%7D%0A%09%09MAJOR_VERSION = major;%0A%09%09MINOR_VERSION = minor;%0A%09%09BUILD_VERSION = build;%0A%09%09BUILD_BRANCH = branch;%0A
 %09%09if( BU

Update Version classes to handle launch from IDE.