diff --git a/build.gradle b/build.gradle index 5d4868593..ee728b960 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,6 @@ apply from: 'gradle.properties' group = GROUP archivesBaseName = ARCHIVE_NAME -version = VERSION targetCompatibility = '1.6' sourceCompatibility = '1.6' @@ -78,7 +77,6 @@ jar { attributes 'Implementation-URL': 'https://github.com/Electrical-Age' attributes 'Implementation-Vendor': 'Electrical-Age Team' attributes 'Implementation-Vendor-Id': 'net.electricalage.eln' - attributes 'Implementation-Version': project.version attributes 'Project-Url': 'https://electrical-age.net/' attributes 'Source-Compatibility': project.sourceCompatibility attributes 'Target-Compatibility': project.targetCompatibility @@ -170,6 +168,20 @@ def getMinecratfDir() { return outDir } +task readVersion(type: JavaExec, dependsOn: classes) { + classpath configurations.runtime, sourceSets.main.output + main = "mods.eln.misc.Version" + standardOutput = new ByteArrayOutputStream() + doLast { + project.setVersion(standardOutput.toString()) + jar.manifest { + attributes 'Implementation-Version': project.version + } + } +} + +jar.dependsOn('readVersion') + // Custom task to build and copy the mod Jar to the default local Minecraft folder task buildAndCopyJar(dependsOn: 'build', type: Copy) { group = 'ELN' @@ -222,7 +234,7 @@ publishing { from components.java groupId GROUP artifactId ARCHIVE_NAME - version VERSION + version project.version } } } @@ -240,7 +252,7 @@ bintray { licenses = ['LGPL V3.0', 'CC BY-NC-SA 3.0'] vcsUrl = 'https://github.com/Electrical-Age/ElectricalAge.git' version { - name = VERSION + name = project.version } } } diff --git a/gradle.properties b/gradle.properties index b6fbc4396..5cfad84dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ GROUP = 'net.electricalage.eln' -ARCHIVE_NAME = 'ElectricalAge_BETA' -VERSION = '1.11_r52' +ARCHIVE_NAME = 'ElectricalAge' MAPURL = 'https://github.com/Electrical-Age/ElectricalAge/releases/download/BETA-1.11r51/ElectricalAge_tutorial_map-BETA-1.11r51.zip' diff --git a/src/main/java/mods/eln/Eln.java b/src/main/java/mods/eln/Eln.java index 091130081..d43a2108c 100644 --- a/src/main/java/mods/eln/Eln.java +++ b/src/main/java/mods/eln/Eln.java @@ -174,7 +174,7 @@ import static mods.eln.i18n.I18N.*; -@Mod(modid = Eln.MODID, name = Eln.NAME, version = Version.REVISION) +@Mod(modid = Eln.MODID, name = Eln.NAME, version = Version.VERSION_STRING) // @Mod(modid = "Eln", name = "Electrical Age", version = "BETA-1.2.0b") // @NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = { "miaouMod" }, packetHandler = PacketHandler.class) public class Eln { diff --git a/src/main/java/mods/eln/client/VersionCheckerHandler.java b/src/main/java/mods/eln/client/VersionCheckerHandler.java index 481f7ec90..859a12535 100644 --- a/src/main/java/mods/eln/client/VersionCheckerHandler.java +++ b/src/main/java/mods/eln/client/VersionCheckerHandler.java @@ -58,18 +58,20 @@ public void run() { // Read the last stable version JsonObject stable = j.get("stable").getAsJsonObject(); - int rev = stable.get("version_revision").getAsInt(); - int currentRev = Integer.valueOf(Version.REVISION); + int uniqueVersion = 1000000 * stable.get("version_major").getAsInt() + + 1000 * stable.get("version_minor").getAsInt() + stable.get("version_revision").getAsInt(); + int currentUniqueVersion = Version.UNIQUE_VERSION; // New stable version - if (rev > currentRev) { + if (uniqueVersion > currentUniqueVersion) { int major = stable.get("version_major").getAsInt(); int minor = stable.get("version_minor").getAsInt(); - msg = String.format(Color.GREEN + "> New stable version available: BETA-%d.%d r%d" + " - please upgrade !", - major, minor, rev); + int revision = stable.get("version_revision").getAsInt(); + msg = String.format(Color.GREEN + "> New stable version available: %d.%d.%d" + " - please upgrade !", + major, minor, revision); } // No update - else if (rev == currentRev) { + else if (uniqueVersion == currentUniqueVersion) { msg = "> No update available (last stable version)"; } // DEV version (not stable) diff --git a/src/main/java/mods/eln/misc/Version.java b/src/main/java/mods/eln/misc/Version.java index 99bc48e5e..0b3d0dd07 100644 --- a/src/main/java/mods/eln/misc/Version.java +++ b/src/main/java/mods/eln/misc/Version.java @@ -14,19 +14,24 @@ public final class Version { public final static int MAJOR = 1; /** Minor version code. */ - public final static int MINOR = 11; + public final static int MINOR = 12; + + /** Revision version code. */ + public final static int REVISION = 0; /** * Unique version code. Must be a String for annotations. Used to check if a * new version if available. Each update must increment this number. */ - public final static String REVISION = "52"; + public final static int UNIQUE_VERSION = 1000000 * MAJOR + 1000 * MINOR + REVISION; + + public final static String VERSION_STRING = "" + MAJOR + "." + MINOR + "." + REVISION; - public final static String getVersionName() { - return String.format("BETA-%d.%d r%s", MAJOR, MINOR, REVISION); + public static String getVersionName() { + return VERSION_STRING; } - public final static String print() { + public static String print() { return tr("mod.name") + " " + getVersionName(); } @@ -34,4 +39,8 @@ public final static String printColor() { return Color.WHITE + tr("mod.name") + " version " + Color.ORANGE + getVersionName(); } + + public static void main(String... args) { + System.out.print(getVersionName()); + } }