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
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
-
- inputs.file("${install4jDir}/${install4j_template}")
- inputs.file("${install4jDir}/${install4j_installer_file_associations}")
- outputs.files(install4jConfFile)
-
- 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
+task copyInstall4jTemplate {
- /*
- 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'
- ]
- )
- }
- */
- }
- into install4jDir
+ def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
+ def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
+ inputs.file(install4jTemplateFile)
+ inputs.file(install4jFileAssociationsFile)
+ outputs.file(install4jConfFile)
doLast {
- // include file associations in installer
- 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: 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)
+ def install4j = new XmlParser().parse(install4jTemplateFile)
+ // turn off code signing if no OSX_KEYPASS
if (OSX_KEYPASS == "") {
- install4j.application.codeSigning.each { codeSigning ->
+ install4j.'**'.codeSigning.each { codeSigning ->
codeSigning.'@macEnabled' = "false"
}
- install4j.mediaSets.windows.each { windows ->
+ install4j.'**'.windows.each { windows ->
windows.'@runPostProcessor' = "false"
}
}
- // reparse
- //install4j = new XmlSlurper().parseText(XmlUtil.serialize(install4j))
- install4j.'**'.action.each { a ->
+ // put file association actions where placeholder action is
+ def install4jFileAssociationsText = install4jFileAssociationsFile.text
+ def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
+ install4j.'**'.action.any { a ->
if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
- //a.replaceNode(install4jFileAssociationsXml.action[0])
+ 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
}
}
- // 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
- ant.replaceregexp(
- byline: false,
- flags: "s",
- match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
- replace: installerDMGUninstallerXml,
- file: install4jConfFile
- )
- */
+ // write install4j file
+ install4jConfFile.text = XmlUtil.serialize(install4j)
}
}
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(
}
if (OSX_KEYPASS) {
- macKeystorePassword=OSX_KEYPASS
+ macKeystorePassword = OSX_KEYPASS
}
doFirst {
}
-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