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 | |
parent | 704a0ac3321dd3bd3f56e52216de0643d0dab748 (diff) | |
download | aspectj-de2f7c753232c9bb4c8e602ac841206a0b72260a.tar.gz aspectj-de2f7c753232c9bb4c8e602ac841206a0b72260a.zip |
Fix version tagging for info strings
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/pom.xml | 69 | ||||
-rw-r--r-- | bridge/src/main/java/org/aspectj/bridge/Version.java | 39 | ||||
-rw-r--r-- | bridge/src/main/resources/org/aspectj/bridge/version.properties | 2 | ||||
-rw-r--r-- | bridge/src/test/java/org/aspectj/bridge/VersionTest.java | 6 |
4 files changed, 91 insertions, 25 deletions
diff --git a/bridge/pom.xml b/bridge/pom.xml index 03ddca049..5d851137e 100644 --- a/bridge/pom.xml +++ b/bridge/pom.xml @@ -1,25 +1,56 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.aspectj</groupId> - <artifactId>aspectj-parent</artifactId> - <version>1.9.3.BUILD-SNAPSHOT</version> - <relativePath>..</relativePath> - </parent> + <parent> + <groupId>org.aspectj</groupId> + <artifactId>aspectj-parent</artifactId> + <version>1.9.3.BUILD-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> - <artifactId>bridge</artifactId> - <packaging>jar</packaging> - <name>bridge</name> + <artifactId>bridge</artifactId> + <packaging>jar</packaging> + <name>bridge</name> + + <dependencies> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>util</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.9.1</version> + <executions> + <execution> + <id>build.time</id> + <goals> + <goal>timestamp-property</goal> + </goals> + <configuration> + <name>version.time_text</name> + <pattern>EEEE MMM d, yyyy 'at' HH:mm:ss z</pattern> + <timeZone>America/Los_Angeles</timeZone> + <!-- build.time: Monday Feb 4, 2019 at 23:50:25 GMT --> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + </build> - <dependencies> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>util</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> </project> 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); } } |