diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-05-30 02:57:41 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-05-30 03:00:36 +0200 |
commit | 48c93ecc30b8ee8d04336bf73955293d25f9eeda (patch) | |
tree | 5d0b1f9319da496e428f4ec901a275992180597d /src | |
parent | 912b96c1e55f9e400505cab2963a28ca1433b275 (diff) | |
download | lombok-48c93ecc30b8ee8d04336bf73955293d25f9eeda.tar.gz lombok-48c93ecc30b8ee8d04336bf73955293d25f9eeda.tar.bz2 lombok-48c93ecc30b8ee8d04336bf73955293d25f9eeda.zip |
edge releases now include the release timestamp in the ‘full version’ name.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/core/Version.java | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index 0b6696da..6b1ed0f8 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -21,6 +21,8 @@ */ package lombok.core; +import java.io.InputStream; + /** * This class just holds lombok's current version. */ @@ -66,6 +68,38 @@ public class Version { } public static String getFullVersion() { - return String.format("v%s \"%s\"", VERSION, RELEASE_NAME); + String version = String.format("v%s \"%s\"", VERSION, RELEASE_NAME); + if (!isEdgeRelease()) return version; + + InputStream in = Version.class.getResourceAsStream("release-timestamp.txt"); + if (in == null) return version; + try { + byte[] data = new byte[65536]; + int p = 0; + while (p < data.length) { + int r = in.read(data, p, data.length - p); + if (r == -1) break; + p += r; + } + + String timestamp = new String(data, "UTF-8").trim(); + return version + " - " + timestamp; + } catch (Exception e) { + try { + in.close(); + } catch (Exception ignore) {} + } + + return version; + } + + public static boolean isEdgeRelease() { + int lastIdx = VERSION.lastIndexOf('.'); + if (lastIdx == -1) return false; + try { + return Integer.parseInt(VERSION.substring(lastIdx + 1)) % 1 == 1; + } catch (Exception e) { + return false; + } } } |