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 {
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)
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="',
]
)
}
+ */
}
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: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
- replace: installerFileAssociationsXml,
+ replace: install4jFileAssociationsText,
file: install4jConfFile
)
+*/
+
+ def install4jFileAssociations = new XmlParser().parseText('''
+<install4jFileAssociations>
+${install4jFileAssociationsText}
+</install4jFileAssociations>
+'''
+ )
+
+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
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
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}")