JAL-3830 BAT file wrapper around powershell, so jalview works in command prompt....
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 31 Mar 2021 22:16:56 +0000 (23:16 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 31 Mar 2021 22:16:56 +0000 (23:16 +0100)
build.gradle
gradle.properties
utils/getdown/bin/jalview.bat [new file with mode: 0755]
utils/install4j/install4j8_template.install4j

index e6c8fbd..2c1a56d 100644 (file)
@@ -370,6 +370,7 @@ ext {
                                     .replaceAll("_*-_*", "-") // collapse _-_
                                     .toLowerCase()
 
+  getdownWrapperLink = install4jUnixApplicationFolder // e.g. "jalview_local"
   getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
   //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
   getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
@@ -1573,7 +1574,7 @@ task getdownWebsite() {
       }
     }
     
-    def getdownWrapperScripts = [ getdown_bash_wrapper_script, getdown_powershell_wrapper_script ]
+    def getdownWrapperScripts = [ getdown_bash_wrapper_script, getdown_powershell_wrapper_script, getdown_batch_wrapper_script ]
     getdownWrapperScripts.each{ script ->
       def s = file( "${jalviewDir}/utils/getdown/${getdown_wrapper_script_dir}/${script}" )
       if (s.exists()) {
@@ -1912,7 +1913,7 @@ task installers(type: com.install4j.gradle.Install4jTask) {
     'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
     'MACOS_DMG_DS_STORE': install4jDMGDSStore,
     'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage,
-    'WRAPPER_LINK': getdown_wrapper_link,
+    'WRAPPER_LINK': getdownWrapperLink,
     'BASH_WRAPPER_SCRIPT': getdown_bash_wrapper_script,
     'POWERSHELL_WRAPPER_SCRIPT': getdown_powershell_wrapper_script,
     'WRAPPER_SCRIPT_BIN_DIR': getdown_wrapper_script_dir,
index 9e7d8da..d0fb57d 100644 (file)
@@ -135,9 +135,9 @@ install4j_background = jalview_logo_background_fade-640x480.png
 install4j_dmg_background = jalview_dmg_background-NON-RELEASE.png
 install4j_dmg_ds_store = jalview_dmg_DS_Store
 getdown_wrapper_script_dir = bin
-getdown_wrapper_link = jalview
 getdown_bash_wrapper_script = jalview.sh
 getdown_powershell_wrapper_script = jalview.ps1
+getdown_batch_wrapper_script = jalview.bat
 
 OSX_KEYSTORE =
 OSX_KEYPASS =
diff --git a/utils/getdown/bin/jalview.bat b/utils/getdown/bin/jalview.bat
new file mode 100755 (executable)
index 0000000..428019b
--- /dev/null
@@ -0,0 +1,4 @@
+@ECHO OFF
+SET ThisScriptsDirectory=%~dp0
+SET PowerShellScriptPath=%ThisScriptsDirectory%jalview.ps1
+PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%' %*";
index 388e14c..a14900c 100644 (file)
@@ -37,7 +37,6 @@
       <variable name="MACOS_DMG_BG_IMAGE" value="jalview_dmg_background-72dpi.png" />
       <variable name="WRAPPER_LINK" value="jalview" />
       <variable name="BASH_WRAPPER_SCRIPT" value="jalview.sh" />
-      <variable name="POWERSHELL_WRAPPER_SCRIPT" value="jalview.ps1" />
       <variable name="WRAPPER_SCRIPT_BIN_DIR" value="bin" />
       <variable name="INSTALLER_NAME" value="Jalview Installer" />
       <variable name="INSTALL4J_UTILS_DIR" value="utils/install4j" />
@@ -57,7 +56,6 @@
       <variable name="WINDOWS_ICONS_FILE" value="utils/channels/release/images/jalview_logo.ico" />
       <variable name="PNG_ICON_FILE" value="utils/channels/release/images/jalview_logo.png" />
       <variable name="BACKGROUND" value="utils/channels/release/images/jalview_logo_background_fade-640x480.png" />
-      <variable name="LINK_TO_WRAPPER_SCRIPT" value="${compiler:BASH_WRAPPER_SCRIPT}" />
     </variables>
     <codeSigning macEnabled="true" macPkcs12File="${compiler:OSX_KEYSTORE}" macNotarize="true" appleId="${compiler:OSX_APPLEID}">
       <macAdditionalBinaries>
                   <property name="obtainIfAdminWin" type="boolean" value="false" />
                 </serializedBean>
               </action>
+              <action name="Set unixUserBinDir (Linux or Unix)" id="2738" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
+                <serializedBean>
+                  <property name="script">
+                    <object class="com.install4j.api.beans.ScriptProperty">
+                      <property name="value" type="string">String userHome = (String)context.getVariable("sys.userHome");
+
+String[] tryPaths = new String[] {
+    "bin",
+    ".local" + File.separator + "bin",
+    "local" + File.separator + "bin",
+    "opt" + File.separator + "bin"
+};
+
+for (int i = 0; i &lt; tryPaths.length; i++) {
+    String tryPath = tryPaths[i];
+    File unixUserBinDir = new File(userHome + File.separator + tryPath);
+    if (unixUserBinDir.exists()) {
+        return tryPath;
+    }
+}
+
+return null;
+</property>
+                    </object>
+                  </property>
+                  <property name="variableName" type="string">unixUserBinDir</property>
+                </serializedBean>
+                <condition>Util.isLinux() || Util.isUnixInstaller()</condition>
+              </action>
             </actions>
           </screen>
         </startup>
@@ -492,7 +519,7 @@ return console.askOkCancel(message, true);
                   </action>
                   <action id="2542" beanClass="com.install4j.runtime.beans.actions.control.SetMessageAction" actionElevationType="none" rollbackBarrierExitCode="0">
                     <serializedBean>
-                      <property name="statusMessage" type="string">Creating file associations</property>
+                      <property name="statusMessage" type="string">Finished creating file associations</property>
                       <property name="useDetail" type="boolean" value="true" />
                       <property name="useStatus" type="boolean" value="true" />
                     </serializedBean>
@@ -533,20 +560,6 @@ return console.askOkCancel(message, true);
           </screen>
           <screen id="20" beanClass="com.install4j.runtime.beans.screens.FinishedScreen" rollbackBarrierExitCode="0" finishScreen="true">
             <actions>
-              <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">
-                <serializedBean>
-                  <property name="file">
-                    <object class="java.io.File">
-                      <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:LINK_TO_WRAPPER_SCRIPT}</string>
-                    </object>
-                  </property>
-                  <property name="linkFile">
-                    <object class="java.io.File">
-                      <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK}</string>
-                    </object>
-                  </property>
-                </serializedBean>
-              </action>
               <action id="2012" beanClass="com.install4j.runtime.beans.actions.desktop.CreateStartMenuEntryAction" actionElevationType="elevated" rollbackBarrierExitCode="0">
                 <serializedBean>
                   <property name="allUsers" type="boolean" value="false" />
@@ -604,6 +617,44 @@ 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">
+                <serializedBean>
+                  <property name="file">
+                    <object class="java.io.File">
+                      <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BASH_WRAPPER_SCRIPT}</string>
+                    </object>
+                  </property>
+                  <property name="linkFile">
+                    <object class="java.io.File">
+                      <string>${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:WRAPPER_LINK}</string>
+                    </object>
+                  </property>
+                </serializedBean>
+                <condition>!Util.isWindows()</condition>
+              </action>
+              <action name="Add Jalview bin to the user's path (Windows)" id="2740" beanClass="com.install4j.runtime.beans.actions.misc.ModifyEnvironmentVariableAction" actionElevationType="elevated" rollbackBarrierExitCode="0" errorMessage="Could not add &quot;${installer:sys.contentDir}\${compiler:WRAPPER_SCRIPT_BIN_DIR}&quot; to the Path environment variable">
+                <serializedBean>
+                  <property name="type" type="enum" class="com.install4j.runtime.beans.actions.misc.ModifyStringType" value="APPEND" />
+                  <property name="value" type="string">${installer:sys.contentDir}\${compiler:WRAPPER_SCRIPT_BIN_DIR}</property>
+                  <property name="variableName" type="string">Path</property>
+                </serializedBean>
+                <condition>context.getBooleanVariable("appendToPathAction")</condition>
+              </action>
+              <action name="Create 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}">
+                <serializedBean>
+                  <property name="file">
+                    <object class="java.io.File">
+                      <string>${installer:sys.contentDir}/${compiler:WRAPPER_SCRIPT_BIN_DIR}/${compiler:BASH_WRAPPER_SCRIPT}</string>
+                    </object>
+                  </property>
+                  <property name="linkFile">
+                    <object class="java.io.File">
+                      <string>${installer:sys.userHome}/${installer:unixUserBinDir}/${compiler:WRAPPER_LINK}</string>
+                    </object>
+                  </property>
+                </serializedBean>
+                <condition>context.getBooleanVariable("makeSymbolicLink") &amp;&amp; ( Util.isLinux() || Util.isUnixInstaller() ) &amp;&amp; ( context.getVariable("unixUserBinDir") != null )</condition>
+              </action>
             </actions>
             <formComponents>
               <formComponent id="21" beanClass="com.install4j.runtime.beans.formcomponents.MultilineLabelComponent" insetBottom="10">
@@ -626,6 +677,22 @@ return console.askOkCancel(message, true);
                 </serializedBean>
                 <visibilityScript>Util.isMacOS()</visibilityScript>
               </formComponent>
+              <formComponent name="Add jalview bin to the user's Path environment variable (Windows)" id="2734" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
+                <serializedBean>
+                  <property name="checkboxText" type="string">Add ${compiler:JALVIEW_APPLICATION_NAME}'s bin folder to the Path environment variable</property>
+                  <property name="initiallySelected" type="boolean" value="true" />
+                  <property name="variableName" type="string">appendToPathAction</property>
+                </serializedBean>
+                <visibilityScript>Util.isWindows()</visibilityScript>
+              </formComponent>
+              <formComponent name="Make a symbolic link to jalview.sh bash script in the user's local bin (Linux or Unix)" id="2736" beanClass="com.install4j.runtime.beans.formcomponents.CheckboxComponent">
+                <serializedBean>
+                  <property name="checkboxText" type="string">Make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixUserBinDir}</property>
+                  <property name="initiallySelected" type="boolean" value="true" />
+                  <property name="variableName" type="string">makeSymbolicLink</property>
+                </serializedBean>
+                <visibilityScript>( Util.isLinux() || Util.isUnixInstaller() ) &amp;&amp; ( context.getVariable("unixUserBinDir") != null )</visibilityScript>
+              </formComponent>
             </formComponents>
           </screen>
         </screens>
@@ -1202,9 +1269,6 @@ return console.askYesNo(message, true);
         <entry filesetId="1873" />
         <entry filesetId="2105" />
       </exclude>
-      <variables>
-        <variable name="LINK_TO_WRAPPER_SCRIPT" value="${compiler:POWERSHELL_WRAPPER_SCRIPT}" />
-      </variables>
       <jreBundle jreBundleSource="preCreated" includedJre="${compiler:WINDOWS_JAVA_VM_TGZ}" manualJreEntry="true" />
     </windows>
     <macosArchive name="macOS Disk Image" id="878" customizedId="MACOS_DISK_IMAGE" mediaFileName="${compiler:APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-java_${compiler:JAVA_INTEGER_VERSION}" volumeName="${compiler:INSTALLER_NAME}" launcherId="737">
@@ -1218,9 +1282,6 @@ return console.askYesNo(message, true);
         <entry filesetId="882" />
         <entry filesetId="1873" />
       </exclude>
-      <variables>
-        <variable name="LINK_TO_WRAPPER_SCRIPT" value="${compiler:BASH_WRAPPER_SCRIPT}" />
-      </variables>
       <topLevelFiles>
         <symlink name="&quot; &quot;" target="/Applications" />
         <file name=".background/jalview_dmg_background.png" file="${compiler:JALVIEW_DIR}/${compiler:MACOS_DMG_BG_IMAGE}" />
@@ -1244,9 +1305,6 @@ return console.askYesNo(message, true);
         <entry filesetId="1873" />
         <entry filesetId="2105" />
       </exclude>
-      <variables>
-        <variable name="LINK_TO_WRAPPER_SCRIPT" value="${compiler:BASH_WRAPPER_SCRIPT}" />
-      </variables>
       <jreBundle jreBundleSource="preCreated" includedJre="${compiler:LINUX_JAVA_VM_TGZ}" manualJreEntry="true" />
     </unixInstaller>
     <unixArchive name="Unix .tar.gz Archive" id="1596" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}">
@@ -1263,9 +1321,6 @@ return console.askYesNo(message, true);
         <entry filesetId="1873" />
         <entry filesetId="2105" />
       </exclude>
-      <variables>
-        <variable name="LINK_TO_WRAPPER_SCRIPT" value="${compiler:BASH_WRAPPER_SCRIPT}" />
-      </variables>
       <jreBundle includedJre="${compiler:LINUX_JAVA_VM_TGZ}" manualJreEntry="true" />
     </unixArchive>
     <unixInstaller name="Unix Shell Installer" id="2639" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}" customInstallBaseDir="~/opt/">
@@ -1282,9 +1337,6 @@ return console.askYesNo(message, true);
         <entry filesetId="1873" />
         <entry filesetId="2105" />
       </exclude>
-      <variables>
-        <variable name="LINK_TO_WRAPPER_SCRIPT" value="${compiler:BASH_WRAPPER_SCRIPT}" />
-      </variables>
       <jreBundle includedJre="${compiler:LINUX_JAVA_VM_TGZ}" manualJreEntry="true" />
     </unixInstaller>
   </mediaSets>