+
+ // turn off checksum creation for LOCAL channel
+ def e = install4jConfigXml.application[0]
+ if (CHANNEL == "LOCAL") {
+ e.'@createChecksums' = "false"
+ } else {
+ 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>")
+ 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)
+ 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
+ return true
+ }
+ }
+
+ // 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"
+ 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 ' 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]
+ 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)
+ // remove Examples folder from DMG
+ examplesFolderPlaceholder.parent().remove(examplesFolderPlaceholder)
+ }
+ install4jConfigXml.'**'.action.any { a ->
+ if (a.'@customizedId' == customizedIdToDelete) {
+ a.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)