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 {
id 'application'
id 'eclipse'
id 'com.github.johnrengelman.shadow' version '4.0.3'
- id 'com.install4j.gradle' version '7.0.9'
+ id 'com.install4j.gradle' version '8.0.2'
id 'com.dorongold.task-tree' version '1.4' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
}
} else {
println("HEADLESS BUILD")
}
-
+
J2S_ENABLED = (project.hasProperty('j2s.compiler.status') && project['j2s.compiler.status'] != null && project['j2s.compiler.status'] == "enable")
if (J2S_ENABLED) {
println("J2S ENABLED")
}
-
+
/* *-/
System.properties.sort { it.key }.each {
key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
getdownDir = string("")
reportRsyncCmd = false
buildDist = true
- buildProperties = string("${resourceDir}/${build_properties_file}")
+ buildProperties = build_properties_file
getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
switch (CHANNEL) {
getdown_channel_name = string("${bamboo_planKey}/${JAVA_VERSION}")
getdown_app_base = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
getdown_app_dir = getdown_app_dir_alt
- buildProperties = string("${resourceDir}/${build_properties_file}")
+ buildProperties = string("${classesDir}/${build_properties_file}")
break
case "RELEASE":
getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
getdown_app_dir = getdown_app_dir_release
- buildProperties = string("${resourceDir}/${build_properties_file}")
+ buildProperties = string("${classesDir}/${build_properties_file}")
reportRsyncCommand = true
break
exit
} else {
packageDir = string("${ARCHIVEDIR}/${packageDir}")
- buildProperties = string("${ARCHIVEDIR}/${resource_dir}/${build_properties_file}")
+ buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
buildDist = false
}
reportRsyncCommand = true
exit
} else {
packageDir = string("${ARCHIVEDIR}/${packageDir}")
- buildProperties = string("${ARCHIVEDIR}/${resource_dir}/${build_properties_file}")
+ buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
buildDist = false
}
reportRsyncCommand = true
getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
getdown_app_dir = getdown_app_dir_alt
- buildProperties = string("${resourceDir}/${build_properties_file}")
+ buildProperties = string("${classesDir}/${build_properties_file}")
reportRsyncCommand = true
break
getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
getdown_app_dir = getdown_app_dir_alt
- buildProperties = string("${resourceDir}/${build_properties_file}")
+ buildProperties = string("${classesDir}/${build_properties_file}")
reportRsyncCommand = true
break
getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
getdown_app_dir = getdown_app_dir_alt
- buildProperties = string("${resourceDir}/${build_properties_file}")
+ buildProperties = string("${classesDir}/${build_properties_file}")
reportRsyncCommand = true
break
case "LOCAL":
getdown_app_base = file(getdownWebsiteDir).toURI().toString()
getdown_app_dir = getdown_app_dir_alt
- buildProperties = string("${resourceDir}/${build_properties_file}")
+ buildProperties = string("${classesDir}/${build_properties_file}")
getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
break
// for install4j
+ JAVA_MIN_VERSION = JAVA_VERSION
+ JAVA_MAX_VERSION = JAVA_VERSION
macosJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre")
macosJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz")
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}/${install4jResourceDir}")
- install4jConfFileName = string("jalview-installers-java${JAVA_VERSION}.install4j")
- install4jConfFile = string("${install4jDir}/${install4jConfFileName}")
+ install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
+ 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)
+ }
+
buildingHTML = string("${jalviewDir}/${docDir}/building.html")
helpFile = string("${classesDir}/${help_dir}/help.jhm")
helpParentDir = string("${jalviewDir}/${help_parent_dir}")
- helpDir = string("${help_dir}")
- helpSourceDir = string("${helpParentDir}/${helpDir}")
+ helpSourceDir = string("${helpParentDir}/${help_dir}")
relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
resources {
srcDirs resourceDir
+ srcDirs += helpParentDir
}
jar.destinationDir = file("${jalviewDir}/${packageDir}")
compileClasspath = files(sourceSets.main.java.outputDir)
+ //compileClasspath += files(sourceSets.main.resources.srcDirs)
compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
runtimeClasspath = compileClasspath
}
cp.entries.removeAll(removeTheseToo)
- cp.entries += new Output("${eclipse_bin_dir}/main")
- if (file(helpSourceDir).isDirectory()) {
- cp.entries += new Library(fileReference(helpSourceDir))
+ //cp.entries += new Output("${eclipse_bin_dir}/main")
+ if (file(helpParentDir).isDirectory()) {
+ cp.entries += new Library(fileReference(helpParentDir))
}
if (file(resourceDir).isDirectory()) {
cp.entries += new Library(fileReference(resourceDir))
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 createBuildProperties(type: WriteProperties) {
- group = "build"
- description = "Create the ${buildProperties} file"
dependsOn setGitVals
inputs.dir(sourceDir)
inputs.dir(resourceDir)
}
-clean {
- doFirst {
- delete buildProperties
- }
-}
-
-
task cleanBuildingHTML(type: Delete) {
doFirst {
delete buildingHTML
task copyHelp(type: Copy) {
def inputDir = helpSourceDir
- def outputDir = "${classesDir}/${helpDir}"
+ def outputDir = "${classesDir}/${help_dir}"
from(inputDir) {
exclude '**/*.gif'
exclude '**/*.jpg'
task syncResources(type: Sync) {
- dependsOn createBuildProperties
from resourceDir
include "**/*.*"
into "${classesDir}"
dependsOn copyHelp
classpath = sourceSets.main.compileClasspath
main = "com.sun.java.help.search.Indexer"
- workingDir = "${classesDir}/${helpDir}"
+ workingDir = "${classesDir}/${help_dir}"
def argDir = "html"
args = [ argDir ]
inputs.dir("${workingDir}/${argDir}")
classpath = files("${jalviewDir}/${utilsDir}")
main = "HelpLinksChecker"
workingDir = jalviewDir
- def help = "${classesDir}/${helpDir}"
- args = [ "${classesDir}/${helpDir}", "-nointernet" ]
+ args = [ "${classesDir}/${help_dir}", "-nointernet" ]
def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
def errFOS = outFOS
outFOS,
errorOutput)
- inputs.dir("${classesDir}/${helpDir}")
+ inputs.dir("${classesDir}/${help_dir}")
outputs.file(helpLinksCheckerOutFile)
}
// import the pubhtmlhelp target
ant.properties.basedir = "${jalviewDir}"
-ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${helpDir}"
+ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
ant.importBuild "${utilsDir}/publishHelp.xml"
}
}
-
jar {
dependsOn linkCheck
dependsOn buildIndices
install4j {
- def install4jHomeDir = "/opt/install4j"
- def hostname = "hostname".execute().text.trim()
- if (hostname.equals("jv-bamboo")) {
- install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
- } else if (OperatingSystem.current().isMacOsX()) {
- install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
- if (! file(install4jHomeDir).exists()) {
- install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
- }
- } else if (OperatingSystem.current().isLinux()) {
+ if (file(install4jHomeDir).exists()) {
+ // good to go!
+ } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
+ } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
+ install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
}
- installDir = file(install4jHomeDir)
- mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
- if (install4jFaster.equals("true")) {
- faster = true
- }
+ installDir(file(install4jHomeDir))
+
+ mediaTypes = Arrays.asList(install4j_media_types.split(","))
}
-task copyInstall4jTemplate(type: Copy) {
- from (install4jDir) {
- include install4jTemplate
- rename (install4jTemplate, install4jConfFileName)
- filter(ReplaceTokens,
- beginToken: '',
- endToken: '',
- tokens: [
- '9999999999': JAVA_VERSION
- ]
- )
- filter(ReplaceTokens,
- beginToken: '$$',
- endToken: '$$',
- tokens: [
- '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': install4jInfoPlistFileAssociations,
- 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
- 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
- '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
- ]
- )
- 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
- outputs.files(install4jConfFile)
+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)
doLast {
- // include file associations in installer
- def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").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/$install4jDMGUninstallerAppFiles").text
- ant.replaceregexp(
- byline: false,
- flags: "s",
- match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
- replace: installerDMGUninstallerXml,
- file: install4jConfFile
- )
- */
+ def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
+
+ // turn off code signing if no OSX_KEYPASS
+ if (OSX_KEYPASS == "") {
+ install4jConfigXml.'**'.codeSigning.each { codeSigning ->
+ codeSigning.'@macEnabled' = "false"
+ }
+ install4jConfigXml.'**'.windows.each { windows ->
+ windows.'@runPostProcessor' = "false"
+ }
+ }
+
+ // 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)
- variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
- destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
+
+ projectFile = install4jConfFile
+
+ // create an md5 for the input files to use as version for install4j conf file
+ 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)
+ }
+ def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
+
+ variables = [
+ 'OSX_KEYSTORE': OSX_KEYSTORE,
+ 'JSIGN_SH': JSIGN_SH,
+ 'JRE_DIR': getdown_app_dir_java,
+ 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
+ '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,
+ '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 (install4j_faster.equals("true") || CHANNEL.startsWith("DEVELOP") || CHANNEL.startsWith("LOCAL")) {
+ // this doesn't seem to work
+ faster = true
+ disableSigning = 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}/${install4jBuildDir}/${JAVA_VERSION}")
+ 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
- inputs.dir("${classesDir}/${helpDir}")
- outputs.dir("${buildDir}/distributions/${helpDir}")
+ inputs.dir("${classesDir}/${help_dir}")
+ outputs.dir("${buildDir}/distributions/${help_dir}")
}
+
+
+// JALVIEWJS STUFF HERE
+
task j2sSetHeadlessBuild {
doFirst {
IN_ECLIPSE = false