JAL-3820 Create and use 'Jalview app' symblinks to java executable. Fixes grouped...
authorBen Soares <b.soares@dundee.ac.uk>
Thu, 25 May 2023 12:55:37 +0000 (13:55 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Thu, 25 May 2023 12:55:37 +0000 (13:55 +0100)
16 files changed:
getdown/lib/FJVL_VERSION
getdown/lib/JVL_VERSION
getdown/lib/getdown-core.jar
getdown/lib/getdown-launcher-local.jar
getdown/lib/getdown-launcher.jar
getdown/src/getdown/ant/pom.xml
getdown/src/getdown/core/pom.xml
getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java
getdown/src/getdown/launcher/pom.xml
getdown/src/getdown/mvn_cmd
getdown/src/getdown/pom.xml
j11lib/getdown-core.jar
j8lib/getdown-core.jar
src/jalview/bin/Launcher.java
src/jalview/gui/Desktop.java
utils/install4j/install4j10_template.install4j

index 1a5992a..35bd812 100644 (file)
@@ -1 +1 @@
-1.8.3-1.2.13_FJVL
+1.8.3-1.2.14_FJVL
index 60daf6c..0a14c3b 100644 (file)
@@ -1 +1 @@
-1.8.3-1.2.13_JVL
+1.8.3-1.2.14_JVL
index 5c98d23..41540fd 100644 (file)
Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ
index b022d9f..c1237da 100644 (file)
Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ
index b9e3c6b..46e7327 100644 (file)
Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ
index ed0f34a..b0c54e2 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.threerings.getdown</groupId>
     <artifactId>getdown</artifactId>
-    <version>1.8.3-1.2.13_FJVL</version>
+    <version>1.8.3-1.2.14_FJVL</version>
   </parent>
 
   <artifactId>getdown-ant</artifactId>
index a7dfa07..5dd429d 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.threerings.getdown</groupId>
     <artifactId>getdown</artifactId>
-    <version>1.8.3-1.2.13_FJVL</version>
+    <version>1.8.3-1.2.14_FJVL</version>
   </parent>
 
   <artifactId>getdown-core</artifactId>
index 31a69c3..0781a11 100644 (file)
@@ -233,12 +233,47 @@ public class LaunchUtil
     public static final boolean isLinux () { return _isLinux; }
 
     /**
+     * Check if a symlink (or file) points to a JVM
+     */
+    private static boolean checkJVMSymlink(String testBin)
+    {
+      File testBinFile = new File(testBin);
+      if (!testBinFile.exists())
+      {
+        return false;
+      }
+      File targetFile = null;
+      try
+      {
+        targetFile = testBinFile.getCanonicalFile();
+      } catch (IOException e)
+      {
+        return false;
+      }
+      if (targetFile != null && ("java".equals(targetFile.getName())
+            || "java.exe".equals(targetFile.getName())))
+      {
+        return true;
+      }
+      return false;
+    }
+
+    /**
      * Checks whether a Java Virtual Machine can be located in the supplied path.
      */
     protected static String checkJVMPath (String vmhome, boolean windebug)
     {
         String vmbase = vmhome + File.separator + "bin" + File.separator;
-        String vmpath = vmbase + "java";
+        String appName = System.getProperty("channel.app_name", "Jalview");
+        String vmpath = vmbase + appName;
+        if (checkJVMSymlink(vmpath)) {
+          return vmpath;
+        }
+        vmpath = vmbase + "Jalview";
+        if (checkJVMSymlink(vmpath)) {
+          return vmpath;
+        }
+        vmpath = vmbase + "java";
         if (new File(vmpath).exists()) {
             return vmpath;
         }
index 6cf40a8..ea3b6ef 100644 (file)
@@ -4,7 +4,7 @@
   <parent>
     <groupId>com.threerings.getdown</groupId>
     <artifactId>getdown</artifactId>
-    <version>1.8.3-1.2.13_FJVL</version>
+    <version>1.8.3-1.2.14_FJVL</version>
   </parent>
 
   <artifactId>getdown-launcher</artifactId>
index 36bc298..b30194f 100755 (executable)
@@ -3,7 +3,7 @@
 if [ x$JVLVERSION != x ]; then
   export VERSION=$JVLVERSION
 else
-  export VERSION=1.8.3-1.2.13_JVL
+  export VERSION=1.8.3-1.2.14_JVL
 fi
 
 if [ x${VERSION%_JVL} = x$VERSION ]; then
index dc12610..ef8c811 100644 (file)
@@ -10,7 +10,7 @@
   <groupId>com.threerings.getdown</groupId>
   <artifactId>getdown</artifactId>
   <packaging>pom</packaging>
-  <version>1.8.3-1.2.13_FJVL</version>
+  <version>1.8.3-1.2.14_FJVL</version>
 
   <name>getdown</name>
   <description>An application installer and updater.</description>
index 5c98d23..41540fd 100644 (file)
Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ
index 5c98d23..41540fd 100644 (file)
Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ
index f29e0a1..246f0a2 100644 (file)
@@ -53,6 +53,29 @@ public class Launcher
   private final static String dockIconPath = ChannelProperties
           .getProperty("logo.512");
 
+  private static boolean checkJVMSymlink(String testBin)
+  {
+    File testBinFile = new File(testBin);
+    if (!testBinFile.exists())
+    {
+      return false;
+    }
+    File targetFile = null;
+    try
+    {
+      targetFile = testBinFile.getCanonicalFile();
+    } catch (IOException e)
+    {
+      return false;
+    }
+    if (targetFile != null && ("java".equals(targetFile.getName())
+            || "java.exe".equals(targetFile.getName())))
+    {
+      return true;
+    }
+    return false;
+  }
+
   /**
    * main method for jalview.bin.Launcher. This restarts the same JRE's JVM with
    * the same arguments but with memory adjusted based on extracted -jvmmempc
@@ -70,9 +93,22 @@ public class Launcher
               + ") may lead to problems. This installation of Jalview should be used with Java "
               + LaunchUtils.getJavaCompileVersion() + ".");
     }
-
-    final String javaBin = System.getProperty("java.home") + File.separator
-            + "bin" + File.separator + "java";
+    final String appName = ChannelProperties.getProperty("app_name");
+    final String javaBinDir = System.getProperty("java.home")
+            + File.separator + "bin" + File.separator;
+    String javaBin = null;
+    if (javaBin == null && checkJVMSymlink(javaBinDir + appName))
+    {
+      javaBin = javaBinDir + appName;
+    }
+    if (javaBin == null && checkJVMSymlink(javaBinDir + "Jalview"))
+    {
+      javaBin = javaBinDir + "Jalview";
+    }
+    if (javaBin == null)
+    {
+      javaBin = "java";
+    }
 
     List<String> command = new ArrayList<>();
     command.add(javaBin);
@@ -232,14 +268,13 @@ public class Launcher
       {
         // -Xdock:name=... doesn't actually work :(
         // Leaving it in in case it gets fixed
-        command.add(
-                "-Xdock:name=" + ChannelProperties.getProperty("app_name"));
+        command.add("-Xdock:name=" + appName);
         // this launches WITHOUT an icon in the macOS dock. Could be useful for
         // getdown?
         // command.add("-Dapple.awt.UIElement=false");
         // This also does not work for the dock
         command.add("-Dcom.apple.mrj.application.apple.menu.about.name="
-                + ChannelProperties.getProperty("app_name"));
+                + appName);
       }
     }
 
index fb3bbc0..1c55476 100644 (file)
@@ -442,6 +442,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         System.err.println(
                 "Linux platform only! You may have the following warning next: \"WARNING: An illegal reflective access operation has occurred\"\nThis is expected and cannot be avoided, sorry about that.");
       }
+      final String awtAppClassName = "awtAppClassName";
       try
       {
         Toolkit xToolkit = Toolkit.getDefaultToolkit();
@@ -449,10 +450,10 @@ public class Desktop extends jalview.jbgui.GDesktop
         Field awtAppClassNameField = null;
 
         if (Arrays.stream(declaredFields)
-                .anyMatch(f -> f.getName().equals("awtAppClassName")))
+                .anyMatch(f -> f.getName().equals(awtAppClassName)))
         {
           awtAppClassNameField = xToolkit.getClass()
-                  .getDeclaredField("awtAppClassName");
+                  .getDeclaredField(awtAppClassName);
         }
 
         String title = ChannelProperties.getProperty("app_name");
@@ -463,11 +464,12 @@ public class Desktop extends jalview.jbgui.GDesktop
         }
         else
         {
-          jalview.bin.Console.debug("XToolkit: awtAppClassName not found");
+          jalview.bin.Console
+                  .debug("XToolkit: " + awtAppClassName + " not found");
         }
       } catch (Exception e)
       {
-        jalview.bin.Console.debug("Error setting awtAppClassName");
+        jalview.bin.Console.debug("Error setting " + awtAppClassName);
         jalview.bin.Console.trace(Cache.getStackTraceString(e));
       }
     }
index 46feaed..f1eee56 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<install4j version="10.0.4" transformSequenceNumber="10">
-  <directoryPresets config="bin/jalview" />
+<install4j version="10.0.5" transformSequenceNumber="10">
+  <directoryPresets config="bin/Jalview" />
   <application name="${compiler:JALVIEW_APPLICATION_NAME}" applicationId="${compiler:WINDOWS_APPLICATION_ID}" mediaDir="${compiler:BUILD_DIR}" lzmaCompression="true" shortName="${compiler:INTERNAL_ID}" publisher="University of Dundee" publisherWeb="https://www.jalview.org/" version="${compiler:JALVIEW_VERSION}" allPathsRelative="true" macVolumeId="5aac4968c304f65" javaMinVersion="${compiler:JAVA_MIN_VERSION}" javaMaxVersion="${compiler:JAVA_MAX_VERSION}" allowBetaVM="true" jdkMode="jdk" jdkName="JDK 11.0">
     <searchSequence>
       <directory location="${compiler:JRE_DIR}" />
           <versionLine x="85" y="109" text="version ${compiler:sys.version}" />
         </text>
       </splashScreen>
-      <java mainClass="com.threerings.getdown.launcher.GetdownApp" vmParameters="-Dinstaller_template_version=${compiler:INSTALLER_TEMPLATE_VERSION}" arguments="&quot;${launcher:sys.launcherDirectory}&quot; jalview">
+      <java mainClass="com.threerings.getdown.launcher.GetdownApp" vmParameters="-Dinstaller_template_version=${compiler:INSTALLER_TEMPLATE_VERSION} -Dchannel.app_name=&quot;${compiler:JALVIEW_APPLICATION_NAME}&quot;" arguments="&quot;${launcher:sys.launcherDirectory}&quot; jalview">
         <classPath>
           <archive location="getdown-launcher.jar" />
           <archive location="${compiler:GETDOWN_INSTALL_DIR}/getdown-launcher.jar" failOnError="false" />
@@ -472,7 +472,7 @@ return console.askOkCancel(message, true);
           </screen>
           <screen id="15" beanClass="com.install4j.runtime.beans.screens.InstallationScreen" rollbackBarrier="true" rollbackBarrierExitCode="0">
             <actions>
-              <action id="17" beanClass="com.install4j.runtime.beans.actions.InstallFilesAction" actionElevationType="elevated" rollbackBarrierExitCode="0" failureStrategy="quit" errorMessage="${i18n:FileCorrupted}" />
+              <action id="17" beanClass="com.install4j.runtime.beans.actions.InstallFilesAction" rollbackBarrierExitCode="0" failureStrategy="quit" errorMessage="${i18n:FileCorrupted}" />
               <action name="Create program group (RELEASE)" id="18" customizedId="PROGRAM_GROUP_RELEASE" beanClass="com.install4j.runtime.beans.actions.desktop.CreateProgramGroupAction" actionElevationType="elevated" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="allUsers" type="boolean" value="false" />
@@ -593,6 +593,38 @@ return console.askOkCancel(message, true);
           </screen>
           <screen id="20" beanClass="com.install4j.runtime.beans.screens.FinishedScreen" rollbackBarrierExitCode="0" finishScreen="true">
             <actions>
+              <action name="Linux Jalview Appname-&gt;java symlink" id="2813" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make symlink to wrapper script">
+                <serializedBean>
+                  <property name="file">
+                    <object class="java.io.File">
+                      <string>${compiler:JRE_DIR}/bin/java</string>
+                    </object>
+                  </property>
+                  <property name="linkFile">
+                    <object class="java.io.File">
+                      <string>${compiler:JRE_DIR}/bin/${compiler:JALVIEW_APPLICATION_NAME}</string>
+                    </object>
+                  </property>
+                  <property name="removeOnUninstall" type="boolean" value="false" />
+                </serializedBean>
+                <condition>Util.isLinux()</condition>
+              </action>
+              <action name="Linux Jalview-&gt;java symlink" id="2814" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make symlink to wrapper script">
+                <serializedBean>
+                  <property name="file">
+                    <object class="java.io.File">
+                      <string>${compiler:JRE_DIR}/bin/java</string>
+                    </object>
+                  </property>
+                  <property name="linkFile">
+                    <object class="java.io.File">
+                      <string>${compiler:JRE_DIR}/bin/${compiler:JALVIEW_NAME}</string>
+                    </object>
+                  </property>
+                  <property name="removeOnUninstall" type="boolean" value="false" />
+                </serializedBean>
+                <condition>Util.isLinux()</condition>
+              </action>
               <action id="2012" beanClass="com.install4j.runtime.beans.actions.desktop.CreateStartMenuEntryAction" actionElevationType="elevated" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="allUsers" type="boolean" value="false" />
@@ -650,7 +682,7 @@ return console.askOkCancel(message, true);
                 </serializedBean>
                 <condition>context.getBooleanVariable("addToDockAction")</condition>
               </action>
-              <action name="Linux/Unix symlink" id="2733" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" actionElevationType="elevated" rollbackBarrierExitCode="0" errorMessage="Could not make symlink to wrapper script">
+              <action name="Linux/Unix symlink" id="2733" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make symlink to wrapper script">
                 <serializedBean>
                   <property name="file">
                     <object class="java.io.File">
@@ -673,7 +705,7 @@ return console.askOkCancel(message, true);
                 </serializedBean>
                 <condition>context.getBooleanVariable("appendToPathAction")</condition>
               </action>
-              <action name="Create Linux/Unix symbolic link to jalview.sh in user's local bin" id="2739" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" actionElevationType="elevated" rollbackBarrierExitCode="0" errorMessage="Could not make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixUserBinDir}">
+              <action name="Create Linux/Unix symbolic link to jalview.sh in user's local bin" id="2739" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixUserBinDir}">
                 <serializedBean>
                   <property name="file">
                     <object class="java.io.File">
@@ -688,7 +720,7 @@ return console.askOkCancel(message, true);
                 </serializedBean>
                 <condition>context.getBooleanVariable("makeSymbolicLinkAction") &amp;&amp; ( Util.isLinux() || Util.isUnixInstaller() ) &amp;&amp; ( context.getVariable("unixUserBinDir") != null )</condition>
               </action>
-              <action name="Create macOS symbolic link to jalview in user's local bin" id="2743" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" actionElevationType="elevated" rollbackBarrierExitCode="0" errorMessage="Could not make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixUserBinDir}">
+              <action name="Create macOS symbolic link to jalview in user's local bin" id="2743" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixUserBinDir}">
                 <serializedBean>
                   <property name="file">
                     <object class="java.io.File">
@@ -844,13 +876,13 @@ return console.askYesNo(message, true);
                   <property name="progressChangeType" type="enum" class="com.install4j.runtime.beans.actions.control.ProgressChangeType" value="SET_INDETERMINATE" />
                 </serializedBean>
               </action>
-              <action id="29" beanClass="com.install4j.runtime.beans.actions.UninstallFilesAction" actionElevationType="elevated" rollbackBarrierExitCode="0" />
+              <action id="29" beanClass="com.install4j.runtime.beans.actions.UninstallFilesAction" rollbackBarrierExitCode="0" />
               <action id="660" beanClass="com.install4j.runtime.beans.actions.control.SetProgressAction" enabled="false" actionElevationType="none" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="percentValue" type="int" value="95" />
                 </serializedBean>
               </action>
-              <action id="1525" beanClass="com.install4j.runtime.beans.actions.files.DeleteFileAction" actionElevationType="elevated" rollbackBarrierExitCode="0">
+              <action id="1525" beanClass="com.install4j.runtime.beans.actions.files.DeleteFileAction" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="files" type="array" class="java.io.File" length="40">
                     <element index="0">