diff options
author | Andy Clement <aclement@pivotal.io> | 2019-02-11 10:46:03 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-02-11 10:46:03 -0800 |
commit | de2f7c753232c9bb4c8e602ac841206a0b72260a (patch) | |
tree | 31ea677478d76b19039c009dcee244a2e6ccb7e9 /bridge/src | |
parent | 704a0ac3321dd3bd3f56e52216de0643d0dab748 (diff) | |
download | aspectj-de2f7c753232c9bb4c8e602ac841206a0b72260a.tar.gz aspectj-de2f7c753232c9bb4c8e602ac841206a0b72260a.zip |
Fix version tagging for info strings
Diffstat (limited to 'bridge/src')
3 files changed, 41 insertions, 6 deletions
diff --git a/bridge/src/main/java/org/aspectj/bridge/Version.java b/bridge/src/main/java/org/aspectj/bridge/Version.java index 367efaf73..321741120 100644 --- a/bridge/src/main/java/org/aspectj/bridge/Version.java +++ b/bridge/src/main/java/org/aspectj/bridge/Version.java @@ -13,9 +13,12 @@ package org.aspectj.bridge; +import java.io.IOException; +import java.net.URL; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Properties; /** release-specific version information */ public class Version { @@ -29,16 +32,19 @@ public class Version { /** default time value for development version */ public static final long NOTIME = 0L; + public static final String UNREPLACED_TEXT = "${project.version}"; + public static final String UNREPLACED_TIME_TEXT = "${version.time_text}"; + /** set by build script */ - public static final String text = "DEVELOPMENT"; + private static String text;// = "DEVELOPMENT"; // VersionUptodate.java scans for "static final String text = " /** * Time text set by build script using SIMPLE_DATE_FORMAT. * (if DEVELOPMENT version, invalid) */ - public static final String time_text = "Tuesday Jan 15, 2019 at 00:53:54 GMT"; - + private static String time_text;// = "Tuesday Jan 15, 2019 at 00:53:54 GMT"; + /** * time in seconds-since-... format, used by programmatic clients. * (if DEVELOPMENT version, NOTIME) @@ -48,6 +54,25 @@ public class Version { /** format used by build script to set time_text */ public static final String SIMPLE_DATE_FORMAT = "EEEE MMM d, yyyy 'at' HH:mm:ss z"; + static { + try { + URL resource = Version.class.getResource("version.properties"); + Properties p = new Properties(); + p.load(resource.openStream()); + text = p.getProperty("version.text",""); + if (text.equals(UNREPLACED_TEXT)) { + text="DEVELOPMENT"; + } + time_text = p.getProperty("version.time_text",""); + if (time_text.equals(UNREPLACED_TIME_TEXT)) { + time_text=""; + } + } catch (IOException e) { + text="DEVELOPMENT"; + time_text = ""; + } + } + public static long getTime() { if (time==-1) { long foundTime = NOTIME; @@ -81,6 +106,14 @@ public class Version { } } } + + public static String getTimeText() { + return time_text; + } + + public static String getText() { + return text; + } } diff --git a/bridge/src/main/resources/org/aspectj/bridge/version.properties b/bridge/src/main/resources/org/aspectj/bridge/version.properties new file mode 100644 index 000000000..361c573ff --- /dev/null +++ b/bridge/src/main/resources/org/aspectj/bridge/version.properties @@ -0,0 +1,2 @@ +version.text=${project.version} +version.time_text=${version.time_text} diff --git a/bridge/src/test/java/org/aspectj/bridge/VersionTest.java b/bridge/src/test/java/org/aspectj/bridge/VersionTest.java index cee4c8450..70eb9d380 100644 --- a/bridge/src/test/java/org/aspectj/bridge/VersionTest.java +++ b/bridge/src/test/java/org/aspectj/bridge/VersionTest.java @@ -48,13 +48,13 @@ public class VersionTest extends TestCase { if (LangUtil.is11VMOrGreater()) { return; } - if (Version.time_text.equals("")) { + if (Version.getTimeText().equals("")) { return; // dev build, we can only test this on the build server. } Date date = new Date(Version.getTime()); SimpleDateFormat format = new SimpleDateFormat(Version.SIMPLE_DATE_FORMAT, Locale.getDefault()); - format.setTimeZone(TimeZone.getTimeZone("GMT")); + format.setTimeZone(TimeZone.getTimeZone("PST")); String timeString = format.format(date); - assertEquals(Version.time_text, timeString); + assertEquals(Version.getTimeText(), timeString); } } |