X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=36c78a2a96ec7055732ceb5140ea9030ffd24307;hb=f3213c0763f9a1d1b911ad5d64074b971f5b8e8b;hp=c451100cdceabf2eb136ce4c5b0b5bc0f491b337;hpb=ed71244bc1c77e2168a8eb64a3ef8100cb56e2c1;p=jalview.git diff --git a/build.gradle b/build.gradle index c451100..36c78a2 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,9 @@ 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.XmlParser +import groovy.xml.XmlUtil buildscript { dependencies { @@ -17,7 +18,7 @@ plugins { 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 } @@ -83,12 +84,12 @@ ext { } 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}'") @@ -123,7 +124,7 @@ ext { 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) { @@ -133,7 +134,7 @@ ext { 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": @@ -141,7 +142,7 @@ ext { 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 @@ -155,7 +156,7 @@ ext { 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 @@ -171,7 +172,7 @@ ext { 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 @@ -183,7 +184,7 @@ ext { 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 @@ -192,7 +193,7 @@ ext { 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 @@ -201,14 +202,14 @@ ext { 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 @@ -288,20 +289,26 @@ ext { // 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()) @@ -339,11 +346,13 @@ sourceSets { 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 @@ -451,9 +460,9 @@ eclipse { } 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)) @@ -461,7 +470,7 @@ eclipse { HashMap 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 @@ -481,7 +490,6 @@ eclipse { } } - //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()) { @@ -670,8 +678,6 @@ task setGitVals { task createBuildProperties(type: WriteProperties) { - group = "build" - description = "Create the ${buildProperties} file" dependsOn setGitVals inputs.dir(sourceDir) inputs.dir(resourceDir) @@ -687,13 +693,6 @@ task createBuildProperties(type: WriteProperties) { } -clean { - doFirst { - delete buildProperties - } -} - - task cleanBuildingHTML(type: Delete) { doFirst { delete buildingHTML @@ -754,7 +753,7 @@ task syncDocs(type: Sync) { task copyHelp(type: Copy) { def inputDir = helpSourceDir - def outputDir = "${classesDir}/${helpDir}" + def outputDir = "${classesDir}/${help_dir}" from(inputDir) { exclude '**/*.gif' exclude '**/*.jpg' @@ -789,7 +788,6 @@ task syncLib(type: Sync) { task syncResources(type: Sync) { - dependsOn createBuildProperties from resourceDir include "**/*.*" into "${classesDir}" @@ -837,7 +835,7 @@ task buildIndices(type: JavaExec) { 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}") @@ -873,8 +871,7 @@ task linkCheck(type: JavaExec) { 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 @@ -885,13 +882,13 @@ task linkCheck(type: JavaExec) { 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" @@ -901,7 +898,6 @@ task cleanPackageDir(type: Delete) { } } - jar { dependsOn linkCheck dependsOn buildIndices @@ -1208,98 +1204,56 @@ clean { 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: '', - replace: installerFileAssociationsXml, - file: install4jConfFile - ) - /* - // include uninstaller applescript app files in dmg - def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text - ant.replaceregexp( - byline: false, - flags: "s", - match: '', - 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("${install4jFileAssociationsText}") + 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) } } @@ -1314,15 +1268,59 @@ clean { 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 { @@ -1331,13 +1329,14 @@ 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}/${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" @@ -1415,15 +1414,19 @@ task sourceDist (type: Tar) { } -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