From: Jim Procter Date: Wed, 22 May 2019 16:01:27 +0000 (+0100) Subject: JAL-3274 import build properties and authors resources from JalviewJS site or classes... X-Git-Tag: Release_2_11_4_0~45^2~18^2~131 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FJalview-JS%2Ftasks%2FJAL-3274-build_details;p=jalview.git JAL-3274 import build properties and authors resources from JalviewJS site or classes directory, or jalview.jar as appropriate. --- diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index b6ff253..362fca8 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -396,10 +396,7 @@ public class Cache } // LOAD THE AUTHORS FROM THE authors.props file - String authorDetails = (Platform.isJS() ? null - : "jar:".concat(Cache.class.getProtectionDomain() - .getCodeSource().getLocation().toString() - .concat("!/authors.props"))); + String authorDetails = resolveResourceURLFor("authors.props"); try { @@ -425,10 +422,8 @@ public class Cache // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar // MUST FOLLOW READING OF LOCAL PROPERTIES FILE AS THE // VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW - String buildDetails = (Platform.isJS() ? null - : "jar:".concat(Cache.class.getProtectionDomain() - .getCodeSource().getLocation().toString() - .concat("!/.build_properties"))); + String buildDetails = resolveResourceURLFor("/.build_properties"); + if (buildDetails != null) { try @@ -573,6 +568,34 @@ public class Cache } + /** + * construct a resource URL for the given absolute resource pathname + * + * @param resourcePath + * @return + */ + private static String resolveResourceURLFor(String resourcePath) + { + String url = null; + if (Platform.isJS() || !Cache.class.getProtectionDomain() + .getCodeSource().getLocation().toString().endsWith(".jar")) + { + try + { + url = Cache.class.getResource(resourcePath).toString(); + } catch (Exception ex) + { + + } + } + else + { + url = "jar:".concat(Cache.class.getProtectionDomain().getCodeSource() + .getLocation().toString().concat("!" + resourcePath)); + } + return url; + } + private static void deleteBuildProperties() { applicationProperties.remove("LATEST_VERSION");