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.XmlParser
+import groovy.xml.XmlUtil
buildscript {
dependencies {
windowsJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre")
windowsJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz")
install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
- install4jConfFileName = string("jalview-installers-java${JAVA_VERSION}.install4j")
- install4jConfFile = string("${install4jDir}/${install4jConfFileName}")
+ install4jConfFileName = string("jalview-install4j-conf.install4j")
+ install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
install4jHomeDir = install4j_home_dir
if (install4jHomeDir.startsWith("~/")) {
install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
- sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
+ sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
//don't want to add outputDir as eclipse is using its own output dir in bin/main
if (it.isDirectory() || ! it.exists()) {
// don't add dirs to classpath, especially if they don't exist
}
}
- //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
//no longer want to add outputDir as eclipse is using its own output dir in bin/main
if (it.isDirectory() || ! it.exists()) {
}
-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}"
+task copyInstall4jTemplate {
+ def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
+ def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
+ inputs.file(install4jTemplateFile)
+ inputs.file(install4jFileAssociationsFile)
+ outputs.file(install4jConfFile)
- inputs.file("${install4jDir}/${install4j_template}")
- inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
- inputs.file("${install4jDir}/${install4j_installer_file_associations}")
- outputs.files(install4jConfFile)
+ doLast {
+ def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
- from (install4jDir) {
- 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
+ // turn off code signing if no OSX_KEYPASS
if (OSX_KEYPASS == "") {
- filter(ReplaceTokens,
- beginToken: 'codeSigning macEnabled="',
- endToken: '"',
- tokens: [
- 'true': 'codeSigning macEnabled="false"'
- ]
- )
- filter(ReplaceTokens,
- beginToken: 'runPostProcessor="true" ',
- endToken: 'Processor',
- tokens: [
- 'post': 'runPostProcessor="false" postProcessor'
- ]
- )
+ install4jConfigXml.'**'.codeSigning.each { codeSigning ->
+ codeSigning.'@macEnabled' = "false"
+ }
+ install4jConfigXml.'**'.windows.each { windows ->
+ windows.'@runPostProcessor' = "false"
+ }
}
- }
- into install4jDir
- doLast {
- // include file associations in installer
- def installerFileAssociationsXml = file("${install4jDir}/${install4j_installer_file_associations}").text
- ant.replaceregexp(
- byline: false,
- flags: "s",
- match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
- replace: installerFileAssociationsXml,
- file: install4jConfFile
- )
- /*
- // include uninstaller applescript app files in dmg
- def installerDMGUninstallerXml = file("$install4jDir/$install4j_DMG_uninstaller_app_files").text
- ant.replaceregexp(
- byline: false,
- flags: "s",
- match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
- replace: installerDMGUninstallerXml,
- file: install4jConfFile
- )
- */
+ // put file association actions where placeholder action is
+ def install4jFileAssociationsText = install4jFileAssociationsFile.text
+ def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
+ install4jConfigXml.'**'.action.any { a ->
+ if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
+ def parent = a.parent()
+ parent.remove(a)
+ fileAssociationActions.each { faa ->
+ parent.append(faa)
+ }
+ // don't need to continue in .any loop once replacements have been made
+ return true
+ }
+ }
+
+ // write install4j file
+ install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
}
}
task installers(type: com.install4j.gradle.Install4jTask) {
group = "distribution"
description = "Create the install4j installers"
+ dependsOn setGitVals
dependsOn getdown
dependsOn copyInstall4jTemplate
- projectFile = file(install4jConfFile)
+ projectFile = install4jConfFile
+
+ // create an md5 for the input files to use as version for install4j conf file
def install4jTemplateMd5 = ""
def digest = MessageDigest.getInstance("MD5")
digest.update(
def install4jTemplateVersion = "${JALVIEW_VERSION}_${install4jTemplateMd5}"
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_FILE': "${install4j_info_plist_file_associations}",
]
destination = "${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}"
buildSelected = true
}
if (OSX_KEYPASS) {
- macKeystorePassword=OSX_KEYPASS
+ macKeystorePassword = OSX_KEYPASS
}
doFirst {
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}")
}
-task sourceDist (type: Tar) {
+task sourceDist(type: Tar) {
def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
}
-task helppages {
+task helppages {
dependsOn copyHelp
dependsOn pubhtmlhelp