1919
2020import java .io .File ;
2121import java .io .IOException ;
22+ import java .io .InputStream ;
2223import java .net .URISyntaxException ;
2324import java .net .URL ;
2425import java .util .Map .Entry ;
2728import java .util .jar .Attributes ;
2829import java .util .jar .JarFile ;
2930import java .util .jar .Manifest ;
31+ import java .util .zip .ZipEntry ;
3032
3133/**
3234 * Reads information about how the current application was built from the Build-Info section of the
@@ -45,11 +47,19 @@ private static Properties loadBuildProperties() {
4547 URL url = BuildInfo .class .getProtectionDomain ().getCodeSource ().getLocation ();
4648 File file = new File (url .toURI ());
4749 jar = new JarFile (file );
50+ ZipEntry entry = jar .getEntry ("META-INF/build-stamp.properties" );
51+ if (entry != null ) {
52+ try (InputStream stream = jar .getInputStream (entry )) {
53+ properties .load (stream );
54+ }
55+ }
56+
4857 manifest = jar .getManifest ();
49- } catch (NullPointerException ignored ) {
50- } catch (URISyntaxException ignored ) {
51- } catch (IOException ignored ) {
52- } catch (IllegalArgumentException ignored ) {
58+ } catch (
59+ IllegalArgumentException |
60+ IOException |
61+ NullPointerException |
62+ URISyntaxException ignored ) {
5363 } finally {
5464 if (jar != null ) {
5565 try {
@@ -84,12 +94,12 @@ public String getReleaseLabel() {
8494
8595 /** @return The embedded build revision or "unknown". */
8696 public String getBuildRevision () {
87- return BUILD_PROPERTIES .getProperty ("Build-Revision " , "unknown" );
97+ return BUILD_PROPERTIES .getProperty ("build-revision " , "unknown" );
8898 }
8999
90100 /** @return The embedded build time or "unknown". */
91101 public String getBuildTime () {
92- return BUILD_PROPERTIES .getProperty ("Build-Time " , "unknown" );
102+ return BUILD_PROPERTIES .getProperty ("build-timestamp " , "unknown" );
93103 }
94104
95105 @ Override
0 commit comments