From d6c54502c07af9e32afdaceb8ea877a1def93305 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Sun, 8 Dec 2019 21:09:10 +0000 Subject: [PATCH] JAL-3449 Work in progress improving XML replacements by gradle --- build.gradle | 109 ++++++++++++++++--------- utils/install4j/install4j8_template.install4j | 6 ++ 2 files changed, 78 insertions(+), 37 deletions(-) diff --git a/build.gradle b/build.gradle index 37f1ad3..32816f3 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,10 @@ import org.gradle.internal.os.OperatingSystem import org.gradle.plugins.ide.eclipse.model.Output import org.gradle.plugins.ide.eclipse.model.Library import java.security.MessageDigest - import groovy.transform.ExternalizeMethods +import groovy.util.XmlSlurper +import groovy.util.XmlParser +import groovy.xml.XmlUtil buildscript { dependencies { @@ -1214,21 +1216,7 @@ install4j { task copyInstall4jTemplate(type: Copy) { dependsOn setGitVals - def install4jTemplateMd5 = "" - def digest = MessageDigest.getInstance("MD5") - digest.update( - (file("${install4jDir}/${install4j_template}").text + - file("${install4jDir}/${install4j_info_plist_file_associations}").text + - file("${install4jDir}/${install4j_installer_file_associations}").text).bytes) - def filesMd5 = new BigInteger(1, digest.digest()).toString(16) - if (filesMd5.length() >= 8) { - filesMd5 = filesMd5.substring(0,8) - } - install4jTemplateMd5 += filesMd5 - install4jTemplateMd5 += "_${gitHash}" - inputs.file("${install4jDir}/${install4j_template}") - inputs.file("${install4jDir}/${install4j_info_plist_file_associations}") inputs.file("${install4jDir}/${install4j_installer_file_associations}") outputs.files(install4jConfFile) @@ -1236,6 +1224,8 @@ task copyInstall4jTemplate(type: Copy) { include install4j_template rename (install4j_template, install4jConfFileName) // TODO change these ReplaceTokens to something better. Possibly ${compiler:variables} but also the ant.replaceregexp below, or perhaps a proper xmldom parse + + /* if (OSX_KEYPASS == "") { filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', @@ -1252,19 +1242,61 @@ task copyInstall4jTemplate(type: Copy) { ] ) } + */ } into install4jDir doLast { // include file associations in installer - def installerFileAssociationsXml = file("${install4jDir}/${install4j_installer_file_associations}").text + def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}") + def install4jFileAssociationsText = install4jFileAssociationsFile.text +/* ant.replaceregexp( byline: false, flags: "s", match: '', - replace: installerFileAssociationsXml, + replace: install4jFileAssociationsText, file: install4jConfFile ) +*/ + + def install4jFileAssociations = new XmlParser().parseText(''' + +${install4jFileAssociationsText} + +''' + ) + +println("TEXT=${install4jFileAssociationsText}") +println("ACTIONS") +install4jFileAssociationsXml.action.each { a -> + println("ACTION="+XmlUtil.serialize(a)) +} + + + def install4j = new XmlParser().parse(install4jConfFile) + + if (OSX_KEYPASS == "") { + install4j.application.codeSigning.each { codeSigning -> + codeSigning.'@macEnabled' = "false" + } + install4j.mediaSets.windows.each { windows -> + windows.'@runPostProcessor' = "false" + } + } + // reparse + //install4j = new XmlSlurper().parseText(XmlUtil.serialize(install4j)) + + install4j.'**'.action.each { a -> + if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') { + //a.replaceNode(install4jFileAssociationsXml.action[0]) + } + } + // reparse + //install4j = new XmlSlurper().parseText(XmlUtil.serialize(install4j)) + + file(install4jConfFile).text = XmlUtil.serialize(install4j) + /* // include uninstaller applescript app files in dmg def installerDMGUninstallerXml = file("$install4jDir/$install4j_DMG_uninstaller_app_files").text @@ -1307,28 +1339,30 @@ task installers(type: com.install4j.gradle.Install4jTask) { install4jTemplateMd5 += filesMd5 install4jTemplateMd5 += "_${gitHash}" def install4jTemplateVersion = "${JALVIEW_VERSION}_${install4jTemplateMd5}" + def infoPlistFileAssociations = file("${install4jDir}/${install4j_info_plist_file_associations}").text variables = [ - 'OSX_KEYSTORE': OSX_KEYSTORE, - 'JSIGN_SH': JSIGN_SH, - 'JALVIEW_VERSION': JALVIEW_VERSION, - 'JAVA_MIN_VERSION': JAVA_MIN_VERSION, - 'JAVA_MAX_VERSION': JAVA_MAX_VERSION, - 'JAVA_VERSION': JAVA_VERSION, - 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION, - 'VERSION': JALVIEW_VERSION, - 'MACOS_JAVA_VM_DIR': macosJavaVMDir, - 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz, - 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir, - 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz, - 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4j_info_plist_file_associations, - 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion, - 'COPYRIGHT_MESSAGE': install4j_copyright_message, - 'MACOS_BUNDLE_ID': install4j_macOS_bundle_id, - 'GETDOWN_RESOURCE_DIR': getdown_resource_dir, - 'GETDOWN_DIST_DIR': getdown_app_dir, - 'GETDOWN_ALT_DIR': getdown_app_dir_alt, - 'GETDOWN_INSTALL_DIR': getdown_install_dir + 'OSX_KEYSTORE': OSX_KEYSTORE, + 'JSIGN_SH': JSIGN_SH, + 'JALVIEW_VERSION': JALVIEW_VERSION, + 'JAVA_MIN_VERSION': JAVA_MIN_VERSION, + 'JAVA_MAX_VERSION': JAVA_MAX_VERSION, + 'JAVA_VERSION': JAVA_VERSION, + 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION, + 'VERSION': JALVIEW_VERSION, + 'MACOS_JAVA_VM_DIR': macosJavaVMDir, + 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz, + 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir, + 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz, + 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4j_info_plist_file_associations, + 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion, + 'COPYRIGHT_MESSAGE': install4j_copyright_message, + 'MACOS_BUNDLE_ID': install4j_macOS_bundle_id, + 'GETDOWN_RESOURCE_DIR': getdown_resource_dir, + 'GETDOWN_DIST_DIR': getdown_app_dir, + 'GETDOWN_ALT_DIR': getdown_app_dir_alt, + 'GETDOWN_INSTALL_DIR': getdown_install_dir, + 'INFO_PLIST_FILE_ASSOCIATIONS': infoPlistFileAssociations ] destination = "${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}" buildSelected = true @@ -1349,6 +1383,7 @@ task installers(type: com.install4j.gradle.Install4jTask) { inputs.dir(getdownWebsiteDir) inputs.file(install4jConfFile) + inputs.file("${install4jDir}/${install4j_info_plist_file_associations}") inputs.dir(macosJavaVMDir) inputs.dir(windowsJavaVMDir) outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}") diff --git a/utils/install4j/install4j8_template.install4j b/utils/install4j/install4j8_template.install4j index de8b133..bd504f3 100644 --- a/utils/install4j/install4j8_template.install4j +++ b/utils/install4j/install4j8_template.install4j @@ -29,6 +29,7 @@ + @@ -113,6 +114,8 @@ + + ${compiler:INFO_PLIST_FILE_ASSOCIATIONS} @@ -133,6 +136,8 @@ + + ${compiler:INFO_PLIST_FILE_ASSOCIATIONS} @@ -145,6 +150,7 @@ + ${compiler:INFO_PLIST_FILE_ASSOCIATIONS} -- 1.7.10.2