From 44af4940850fac2cb293e5c3cb24acc821d5122b Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 31 Aug 2020 18:38:15 +0100 Subject: [PATCH] JAL-3280 Pass appbase and appdir from getdown to jalvew. Check appbase (defaults to release appbase) for build_properties VERSION insteadl of jnlp file. --- build.gradle | 4 +- src/jalview/bin/Cache.java | 91 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index d5b39e3..acf5737 100644 --- a/build.gradle +++ b/build.gradle @@ -1600,6 +1600,8 @@ task getdownWebsite() { //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n" getdownTextString += "resource = ${getdown_launcher_new}\n" getdownTextString += "class = ${main_class}\n" + getdownTextString += "jvmarg = -Dgetdowndistdir=${getdownAppDistDir}\n" + getdownTextString += "jvmarg = -Dgetdownappbase=${getdownAppBase}\n" def getdown_txt = file("${getdownWebsiteDir}/getdown.txt") getdown_txt.write(getdownTextString) @@ -1626,7 +1628,7 @@ task getdownWebsite() { copy { from getdown_txt from getdownLauncher - from "${getdownWebsiteDir}/${getdown_build_properties}" + from "${getdownAppDir}/${getdown_build_properties}" if (file(getdownLauncher).getName() != getdown_launcher) { rename(file(getdownLauncher).getName(), getdown_launcher) } diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 153eaff..806d263 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -527,9 +527,12 @@ public class Cache class VersionChecker extends Thread { + @Override public void run() { + String buildPropertiesUrl = Cache.getAppbaseBuildProperties(); + String orgtimeout = System .getProperty("sun.net.client.defaultConnectTimeout"); if (orgtimeout == null) @@ -543,28 +546,20 @@ public class Cache { System.setProperty("sun.net.client.defaultConnectTimeout", "5000"); - java.net.URL url = new java.net.URL(Cache - .getDefault("www.jalview.org", "http://www.jalview.org") - + "/webstart/jalview.jnlp"); + java.net.URL url = new java.net.URL(buildPropertiesUrl); + BufferedReader in = new BufferedReader( new InputStreamReader(url.openStream())); - String line = null; - while ((line = in.readLine()) != null) - { - if (line.indexOf("jalview.version") == -1) - { - continue; - } - line = line.substring(line.indexOf("value=") + 7); - line = line.substring(0, line.lastIndexOf("\"")); - remoteVersion = line; - break; - } + Properties remoteBuildProperties = new Properties(); + remoteBuildProperties.load(in); + remoteVersion = remoteBuildProperties.getProperty("VERSION"); + remoteBuildProperties.load(in); } catch (Exception ex) { - System.out.println( - "Non-fatal exception when checking version at www.jalview.org :"); + System.out + .println("Non-fatal exception when checking version at " + + buildPropertiesUrl + ":"); System.out.println(ex); remoteVersion = getProperty("VERSION"); } @@ -572,6 +567,7 @@ public class Cache orgtimeout); setProperty("LATEST_VERSION", remoteVersion); + System.out.println("LATEST_VERSION=" + remoteVersion); } } @@ -1251,6 +1247,8 @@ public class Cache { appendIfNotNull(sb, "Getdown appdir: ", System.getProperty("getdownappdir"), "\n", null); + appendIfNotNull(sb, "Getdown appbase: ", + System.getProperty("getdownappbase"), "\n", null); appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"), "\n", "unknown"); } @@ -1624,4 +1622,61 @@ public class Cache { println(ERROR, message); } -} \ No newline at end of file + + /** + * Getdown appbase methods + */ + + private static final String releaseAppbase; + + private static String getdownAppbase; + + private static String getdownDistDir; + + static + { + Float specversion = Float + .parseFloat(System.getProperty("java.specification.version")); + releaseAppbase = (specversion < 9) + ? "https://www.jalview.org/getdown/release/1.8" + : "https://www.jalview.org/getdown/release/11"; + } + + // look for properties (passed in by getdown) otherwise default to release + private static void setGetdownAppbase() + { + if (getdownAppbase != null) + { + return; + } + String appbase = System.getProperty("getdownappbase"); + String distDir = System.getProperty("getdowndistdir"); + if (appbase == null) + { + appbase = releaseAppbase; + distDir = "release"; + } + if (appbase.endsWith("/")) + { + appbase = appbase.substring(0, appbase.length() - 1); + } + if (distDir == null) + { + distDir = appbase.equals(releaseAppbase) ? "release" : "alt"; + } + getdownAppbase = appbase; + getdownDistDir = distDir; + } + + private static String getGetdownAppbase() + { + setGetdownAppbase(); + return getdownAppbase; + } + + private static String getAppbaseBuildProperties() + { + String appbase = getGetdownAppbase(); + return appbase + "/" + getdownDistDir + "/build_properties"; + } +} -- 1.7.10.2