JAL-3588 Auto insert of Examples folder into DMG and an attempt to style both the... story/JAL-3588_Examples_folder_in_macOS_DMG_Finder_window
authorBen Soares <bsoares@dundee.ac.uk>
Wed, 8 Apr 2020 13:25:54 +0000 (14:25 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Wed, 8 Apr 2020 13:25:54 +0000 (14:25 +0100)
build.gradle
gradle.properties
utils/install4j/DMG.VolumeIcon.icns [new file with mode: 0644]
utils/install4j/DS_Store
utils/install4j/examples_folder.png [new file with mode: 0644]
utils/install4j/install4j8_template.install4j
utils/install4j/jalview_macos_examples_folder_icon [new file with mode: 0644]

index e99272c..1cccc68 100644 (file)
@@ -1374,6 +1374,18 @@ task copyInstall4jTemplate {
       e.'@createChecksums' = "true"
     }
 
+    // find largest @id value
+    def maxId = 0
+    /* NOT WORKING
+    install4jConfigXml.'**'.each { element ->
+      if ( element.'@id' != null && element.'@id'.toInteger() > maxId ) {
+        maxId = element.'@id'.toInteger()
+      }
+    }
+    */
+    maxId = 10000
+    def idCount = maxId + 1
+
     // put file association actions where placeholder action is
     def install4jFileAssociationsText = install4jFileAssociationsFile.text
     def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
@@ -1382,6 +1394,9 @@ task copyInstall4jTemplate {
         def parent = a.parent()
         parent.remove(a)
         fileAssociationActions.each { faa ->
+            if ( faa.'@id' != null ) {
+              faa.'@id' = idCount++
+            }
             parent.append(faa)
         }
         // don't need to continue in .any loop once replacements have been made
@@ -1393,8 +1408,29 @@ task copyInstall4jTemplate {
     // NB we're deleting the /other/ one!
     // Also remove the examples subdir from non-release versions
     def customizedIdToDelete = "PROGRAM_GROUP_RELEASE"
+    def macosArchive = install4jConfigXml.'**'.macosArchive.find { ma -> ma.'@customizedId' == "MACOS_DISK_IMAGE" }
+    def examplesFolderPlaceholder = macosArchive.topLevelFiles.file.find { f -> f.'@file' == "EXAMPLES_FOLDER_PLACEHOLDER" }
     if (CHANNEL=="RELEASE") {
       customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE"
+
+      // add all of examples folder
+      def tlf = examplesFolderPlaceholder.parent()
+      tlf.remove(examplesFolderPlaceholder)
+      def examplesFiles = fileTree(file(examples_dir)).findAll { f -> f.isFile() }
+      examplesFiles.each { f ->
+        def relativeFile = file(examples_dir).toPath().relativize(f.toPath())
+        tlf.append( new XmlParser().parseText(
+          "<file name='\${compiler:EXAMPLES_FOLDER}/${relativeFile}' file='\${compiler:JALVIEW_DIR}/${examples_dir}/${relativeFile}' />"
+        ) )
+      }
+      // let's see if we can add the snazzy Jalview Folder icon and Volume icon. Note the weird filename
+      tlf.append( new XmlParser().parseText(
+          "<file name='\${compiler:EXAMPLES_FOLDER}/Icon&#13;' file='\${compiler:JALVIEW_DIR}/${install4j_macos_examples_folder_icon}' />"
+      ) )
+      tlf.append( new XmlParser().parseText(
+          "<file name='.VolumeIcon.icns' file='\${compiler:JALVIEW_DIR}/${install4j_dmg_volume_icons}' />"
+      ) )
+
     } else {
       // remove the examples subdir from Full File Set
       def files = install4jConfigXml.files[0]
@@ -1403,11 +1439,12 @@ task copyInstall4jTemplate {
       def mountPoint = files.mountPoints.mountPoint.find { mp -> mp.'@root' == root.'@id' }
       def dirEntry = files.entries.dirEntry.find { de -> de.'@mountPoint' == mountPoint.'@id' && de.'@subDirectory' == "examples" }
       dirEntry.parent().remove(dirEntry)
+      // remove Examples folder from DMG
+      examplesFolderPlaceholder.parent().remove(examplesFolderPlaceholder)
     }
     install4jConfigXml.'**'.action.any { a ->
       if (a.'@customizedId' == customizedIdToDelete) {
-        def parent = a.parent()
-        parent.remove(a)
+        a.parent().remove(a)
         return true
       }
     }
@@ -1480,6 +1517,7 @@ task installers(type: com.install4j.gradle.Install4jTask) {
     'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
     'MACOS_DS_STORE': install4jDSStore,
     'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage,
+    'EXAMPLES_FOLDER': install4j_examples_folder,
     'INSTALLER_NAME': install4jInstallerName,
     'INSTALL4J_UTILS_DIR': install4j_utils_dir,
     'GETDOWN_WEBSITE_DIR': getdown_website_dir,
index 782a495..8d70654 100644 (file)
@@ -34,7 +34,7 @@ help_dir = help
 docDir = doc
 schemaDir = schemas
 classes_dir = classes
-examplesDir = examples
+examples_dir = examples
 clover = false
 use_clover = false
 cloverReportJVMHeap = 2g
@@ -120,6 +120,9 @@ install4j_info_plist_file_associations = file_associations_auto-Info_plist.xml
 install4j_installer_file_associations = file_associations_auto-install4j8.xml
 #install4j_DMG_uninstaller_app_files = uninstall_old_jalview_files.xml
 install4j_build_dir = build/install4j
+install4j_examples_folder = Examples
+install4j_macos_examples_folder_icon = utils/install4j/jalview_macos_examples_folder_icon
+install4j_dmg_volume_icons = utils/install4j/DMG.VolumeIcon.icns
 install4j_media_types = windows,macosArchive,unixArchive,unixInstaller
 install4j_faster = false
 install4j_application_categories = Science;Biology;Java;
diff --git a/utils/install4j/DMG.VolumeIcon.icns b/utils/install4j/DMG.VolumeIcon.icns
new file mode 100644 (file)
index 0000000..004bed9
Binary files /dev/null and b/utils/install4j/DMG.VolumeIcon.icns differ
index cada68d..c38208f 100644 (file)
Binary files a/utils/install4j/DS_Store and b/utils/install4j/DS_Store differ
diff --git a/utils/install4j/examples_folder.png b/utils/install4j/examples_folder.png
new file mode 100644 (file)
index 0000000..fa5cef2
Binary files /dev/null and b/utils/install4j/examples_folder.png differ
index eb585d9..b1372e9 100644 (file)
@@ -33,7 +33,8 @@
       <variable name="INTERNAL_ID" value="Jalview" />
       <variable name="WINDOWS_APPLICATION_ID" value="6595-2347-1923-0725" />
       <variable name="MACOS_DS_STORE" value="DS_Store" />
-      <variable name="MACOS_DMG_BG_IMAGE" />
+      <variable name="MACOS_DMG_BG_IMAGE" value="jalview_dmg_background.png" />
+      <variable name="EXAMPLES_FOLDER" value="Examples" />
       <variable name="INSTALLER_NAME" value="Jalview Installer" />
       <variable name="INSTALL4J_UTILS_DIR" value="utils/install4j" />
       <variable name="GETDOWN_WEBSITE_DIR" value="getdown/website" />
@@ -395,7 +396,7 @@ return console.askOkCancel(message, true);
                   <property name="programGroupEntryConfigs">
                     <add>
                       <object class="com.install4j.runtime.beans.screens.components.ProgramGroupFileConfig">
-                        <property name="name" type="string">Examples</property>
+                        <property name="name" type="string">${compiler:EXAMPLES_FOLDER}</property>
                         <property name="target">
                           <object class="java.io.File">
                             <string>examples</string>
@@ -1139,6 +1140,7 @@ return console.askYesNo(message, true);
         <file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/Jalview-File.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/Jalview-File.icns" />
         <file name="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/Jalview-Launch.icns" file="${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/Jalview-Launch.icns" />
         <symlink name="Uninstall Old Jalview (optional).app" target="${compiler:JALVIEW_APPLICATION_NAME}.app/Contents/Resources/app/Uninstall Old Jalview.app" />
+        <file name="${compiler:EXAMPLES_FOLDER}" file="EXAMPLES_FOLDER_PLACEHOLDER" />
       </topLevelFiles>
     </macosArchive>
     <unixInstaller name="Linux x64 Shell Installer" id="1595" mediaFileName="${compiler:UNIX_APPLICATION_FOLDER}-${compiler:JALVIEW_VERSION}-linux_x64-java_${compiler:JAVA_INTEGER_VERSION}" installDir="${compiler:UNIX_APPLICATION_FOLDER}" customInstallBaseDir="~/opt/">
diff --git a/utils/install4j/jalview_macos_examples_folder_icon b/utils/install4j/jalview_macos_examples_folder_icon
new file mode 100644 (file)
index 0000000..e69de29