merge from develop: the rest of the changes
authorsoares <bsoares@dundee.ac.uk>
Tue, 7 Apr 2020 19:14:19 +0000 (20:14 +0100)
committersoares <bsoares@dundee.ac.uk>
Tue, 7 Apr 2020 19:14:19 +0000 (20:14 +0100)
build.gradle
gradle.properties

index 989c6e0..dbc2d42 100644 (file)
@@ -148,6 +148,12 @@ ext {
   buildProperties = string("${resourceDir}/${build_properties_file}")
   reportRsyncCommand = false
   jvlChannelName = CHANNEL.toLowerCase()
+  install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build
+  install4jDSStore = "DS_Store-NON-RELEASE"
+  install4jDMGBackgroundImage = "jalview_dmg_background-NON-RELEASE.png"
+  install4jInstallerName = "${jalview_name} Non-Release Installer"
+  install4jExecutableName = jalview_name.replaceAll("[^\\w]+", "_").toLowerCase()
+  install4jExtraScheme = "jalviewx"
   switch (CHANNEL) {
 
     case "BUILD":
@@ -160,6 +166,7 @@ ext {
     if ("".equals(testngExcludedGroups)) { 
       testngExcludedGroups = "Not-bamboo"
     }
+    install4jExtraScheme = "jalviewb"
     break
 
     case "RELEASE":
@@ -170,6 +177,10 @@ ext {
       jalviewjs_ignore_transpile_errors = "false"
       println("Setting jalviewjs_ignore_transpile_errors to 'false'")
     }
+    install4jSuffix = ""
+    install4jDSStore = "DS_Store"
+    install4jDMGBackgroundImage = "jalview_dmg_background.png"
+    install4jInstallerName = "${jalview_name} Installer"
     break
 
     case "ARCHIVE":
@@ -184,6 +195,7 @@ ext {
       buildDist = false
     }
     reportRsyncCommand = true
+    install4jExtraScheme = "jalviewa"
     break
 
     case "ARCHIVELOCAL":
@@ -199,10 +211,16 @@ ext {
     }
     reportRsyncCommand = true
     getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
+    install4jSuffix = "Archive"
+    install4jExtraScheme = "jalviewa"
     break
 
     case "DEVELOP":
     reportRsyncCommand = true
+    install4jDSStore = "DS_Store-DEVELOP"
+    install4jDMGBackgroundImage = "jalview_dmg_background-DEVELOP.png"
+    install4jExtraScheme = "jalviewd"
+    install4jInstallerName = "${jalview_name} Develop Installer"
     break
 
     case "TEST-RELEASE":
@@ -212,6 +230,12 @@ ext {
       jalviewjs_ignore_transpile_errors = "false"
       println("Setting jalviewjs_ignore_transpile_errors to 'false'")
     }
+    JALVIEW_VERSION = "TEST"
+    install4jSuffix = "Test"
+    install4jDSStore = "DS_Store-TEST-RELEASE"
+    install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
+    install4jExtraScheme = "jalviewt"
+    install4jInstallerName = "${jalview_name} Test Installer"
     break
 
     case ~/^SCRATCH(|-[-\w]*)$/:
@@ -219,6 +243,7 @@ ext {
     getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
     getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
     reportRsyncCommand = true
+    install4jSuffix = "Scratch"
     break
 
     case "TEST-LOCAL":
@@ -228,11 +253,18 @@ ext {
       getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
       getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
     }
+    JALVIEW_VERSION = "TEST"
+    install4jSuffix = "Test-Local"
+    install4jDSStore = "DS_Store-TEST-RELEASE"
+    install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
+    install4jExtraScheme = "jalviewt"
+    install4jInstallerName = "${jalview_name} Test Installer"
     break
 
     case "LOCAL":
     getdownAppBase = file(getdownWebsiteDir).toURI().toString()
     getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
+    install4jExtraScheme = "jalviewl"
     break
 
     default: // something wrong specified
@@ -246,7 +278,37 @@ ext {
     println("Overriding getdown appbase with '${getdownAppBase}'")
   }
   // sanitise file name for jalview launcher file for this channel
-  jvlChannelName = jvlChannelName.replaceAll(/[^\w\-]/,"_")
+  jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_")
+  // install4j application and folder names
+  if (install4jSuffix == "") {
+    install4jApplicationName = "${jalview_name}"
+    install4jBundleId = "${install4j_bundle_id}"
+    install4jWinApplicationId = install4j_release_win_application_id
+  } else {
+    install4jApplicationName = "${jalview_name} ${install4jSuffix}"
+    install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase()
+    // add int hash of install4jSuffix to the last part of the application_id
+    def id = install4j_release_win_application_id
+    def idsplitreverse = id.split("-").reverse()
+    idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode()
+    install4jWinApplicationId = idsplitreverse.reverse().join("-")
+  }
+  // sanitise folder and id names
+  // install4jApplicationFolder = e.g. "Jalview Build"
+  install4jApplicationFolder = install4jApplicationName
+                                    .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \
+                                    .replaceAll("_+", "_") // collapse __
+  install4jInternalId = install4jApplicationName
+                                    .replaceAll(" ","_")
+                                    .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
+                                    .replaceAll("_+", "") // collapse __
+                                    //.replaceAll("_*-_*", "-") // collapse _-_
+  install4jUnixApplicationFolder = install4jApplicationName
+                                    .replaceAll(" ","_")
+                                    .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
+                                    .replaceAll("_+", "_") // collapse __
+                                    .replaceAll("_*-_*", "-") // collapse _-_
+                                    .toLowerCase()
 
   getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
   //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
@@ -816,6 +878,7 @@ task setGitVals {
 task createBuildProperties(type: WriteProperties) {
   group = "build"
   description = "Create the ${buildProperties} file"
+  
   dependsOn setGitVals
   inputs.dir(sourceDir)
   inputs.dir(resourceDir)
@@ -1144,7 +1207,7 @@ task getdownWebsite() {
     }
     getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
 
-    // go through properties looking for getdown_txt_...
+    // set some getdown_txt_ properties then go through all properties looking for getdown_txt_...
     def props = project.properties.sort { it.key }
     if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) {
       props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion)
@@ -1156,7 +1219,11 @@ task getdownWebsite() {
       props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
     }
 
-    props.put("getdown_txt_appbase", getdownAppBase)
+    props.put("getdown_txt_title", jalview_name)
+    props.put("getdown_txt_ui.name", install4jApplicationName)
+
+    // start with appbase
+    getdownTextString += "appbase = ${getdownAppBase}\n"
     props.each{ prop, val ->
       if (prop.startsWith("getdown_txt_") && val != null) {
         if (prop.startsWith("getdown_txt_multi_")) {
@@ -1245,7 +1312,7 @@ task getdownWebsite() {
 
     def getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl"
     def launchJvl = file("${getdownWebsiteDir}/${getdownLaunchJvl}")
-    launchJvl.write("appbase="+props.get("getdown_txt_appbase"))
+    launchJvl.write("appbase=${getdownAppBase}")
 
     copy {
       from getdownLauncher
@@ -1383,6 +1450,7 @@ task copyInstall4jTemplate {
   def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
   inputs.file(install4jTemplateFile)
   inputs.file(install4jFileAssociationsFile)
+  inputs.property("CHANNEL", { CHANNEL })
   outputs.file(install4jConfFile)
 
   doLast {
@@ -1409,7 +1477,7 @@ task copyInstall4jTemplate {
     // put file association actions where placeholder action is
     def install4jFileAssociationsText = install4jFileAssociationsFile.text
     def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
-    install4jConfigXml.'**'.action.any { a ->
+    install4jConfigXml.'**'.action.any { a -> // .any{} stops after the first one that returns true
       if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
         def parent = a.parent()
         parent.remove(a)
@@ -1421,6 +1489,35 @@ task copyInstall4jTemplate {
       }
     }
 
+    // use Windows Program Group with Examples folder for RELEASE, and Program Group without Examples for everything else
+    // NB we're deleting the /other/ one!
+    // Also remove the examples subdir from non-release versions
+    def customizedIdToDelete = "PROGRAM_GROUP_RELEASE"
+    if (CHANNEL=="RELEASE") {
+      customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE"
+    } else {
+      // remove the examples subdir from Full File Set
+      def files = install4jConfigXml.files[0]
+      def fileset = files.filesets.fileset.find { fs -> fs.'@customizedId' == "FULL_FILE_SET" }
+      def root = files.roots.root.find { r -> r.'@fileset' == fileset.'@id' }
+      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)
+    }
+    install4jConfigXml.'**'.action.any { a ->
+      if (a.'@customizedId' == customizedIdToDelete) {
+        def parent = a.parent()
+        parent.remove(a)
+        return true
+      }
+    }
+
+    // remove the "Uninstall Old Jalview (optional)" symlink from DMG for non-release DS_Stores
+    if (! (CHANNEL == "RELEASE" || CHANNEL == "TEST-RELEASE" ) ) {
+      def symlink = install4jConfigXml.'**'.topLevelFiles.symlink.find { sl -> sl.'@name' == "Uninstall Old Jalview (optional).app" }
+      symlink.parent().remove(symlink)
+    }
+
     // write install4j file
     install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
   }
@@ -1458,7 +1555,8 @@ task installers(type: com.install4j.gradle.Install4jTask) {
   def install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}"
 
   variables = [
-    'JALVIEW_NAME': getdown_txt_title,
+    'JALVIEW_NAME': jalview_name,
+    'JALVIEW_APPLICATION_NAME': install4jApplicationName,
     'JALVIEW_DIR': "../..",
     'OSX_KEYSTORE': OSX_KEYSTORE,
     'JSIGN_SH': JSIGN_SH,
@@ -1479,6 +1577,12 @@ task installers(type: com.install4j.gradle.Install4jTask) {
     'COPYRIGHT_MESSAGE': install4j_copyright_message,
     'MACOS_BUNDLE_ID': install4j_macOS_bundle_id,
     'INSTALLER_NAME': install4j_installer_name,
+    'BUNDLE_ID': install4jBundleId,
+    'INTERNAL_ID': install4jInternalId,
+    'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
+    'MACOS_DS_STORE': install4jDSStore,
+    'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage,
+    'INSTALLER_NAME': install4jInstallerName,
     'INSTALL4J_UTILS_DIR': install4j_utils_dir,
     'GETDOWN_WEBSITE_DIR': getdown_website_dir,
     'GETDOWN_FILES_DIR': getdown_files_dir,
@@ -1488,8 +1592,16 @@ task installers(type: com.install4j.gradle.Install4jTask) {
     'GETDOWN_INSTALL_DIR': getdown_install_dir,
     'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
     'BUILD_DIR': install4jBuildDir,
+    'APPLICATION_CATEGORIES': install4j_application_categories,
+    'APPLICATION_FOLDER': install4jApplicationFolder,
+    'UNIX_APPLICATION_FOLDER': install4jUnixApplicationFolder,
+    'EXECUTABLE_NAME': install4jExecutableName,
+    'EXTRA_SCHEME': install4jExtraScheme,
   ]
 
+  //println("INSTALL4J VARIABLES:")
+  //variables.each{k,v->println("${k}=${v}")}
+
   destination = "${jalviewDir}/${install4jBuildDir}"
   buildSelected = true
 
index a401411..1507117 100644 (file)
@@ -56,7 +56,7 @@ mainClass = jalview.bin.Jalview
 shadowJarMainClass = jalview.bin.Launcher
 launcherClass = jalview.bin.Jalview
 
-gradlePluginsDir = gradle/plugins
+jalview_name = Jalview
 
 getdown_local = false
 getdown_website_dir = getdown/website
@@ -70,7 +70,6 @@ getdown_launcher_new = getdown-launcher-new.jar
 getdown_core = getdown/lib/getdown-core.jar
 getdown_build_properties = build_properties
 getdown_launch_jvl_name = channel_launch
-getdown_txt_title = Jalview
 getdown_txt_allow_offline = true
 getdown_txt_max_concurrent_downloads = 10
 # now got better defaults when not set
@@ -79,8 +78,6 @@ getdown_txt_max_concurrent_downloads = 10
 #getdown_txt_jalview.jvmmemmax = 32G
 getdown_txt_multi_jvmarg = -Dgetdownappdir=%APPDIR%
 getdown_txt_strict_comments = true
-getdown_txt_title = Jalview
-getdown_txt_ui.name = Jalview
 getdown_txt_ui.progress_sync_before_shown = true
 getdown_txt_ui.progress_sync_after_shown = false
 getdown_txt_ui.keep_on_top = true
@@ -116,16 +113,17 @@ j11modules = com.sun.istack.runtime,com.sun.xml.bind,com.sun.xml.fastinfoset,com
 
 install4j_home_dir = ~/buildtools/install4j8
 install4j_copyright_message = ...
-install4j_macOS_bundle_id = org.jalview.jalview-desktop
+install4j_bundle_id = org.jalview.jalview-desktop
 install4j_utils_dir = utils/install4j
 install4j_template = install4j8_template.install4j
 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_media_types = windows,macosArchive,linuxRPM,linuxDeb,unixArchive,unixInstaller
+install4j_media_types = windows,macosArchive,unixArchive,unixInstaller
 install4j_faster = false
-install4j_installer_name = Jalview Installer
+install4j_application_categories = Science;Biology;Java;
+install4j_release_win_application_id = 6595-2347-1923-0725
 
 OSX_KEYSTORE =
 OSX_KEYPASS =