X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=f7233f1637beada539d8ab7d45dc7d07fe2817ce;hb=refs%2Fheads%2Fpatch%2FJAL-3561_JAL-3660_fileformatexport_CLI;hp=8dd61871bf3a88e0564761e6d0d2573481b1c4a4;hpb=dc70a1f7934471a4084c3f10e7bd630d72aa3bf3;p=jalview.git diff --git a/build.gradle b/build.gradle index 8dd6187..f7233f1 100644 --- a/build.gradle +++ b/build.gradle @@ -7,12 +7,18 @@ import groovy.transform.ExternalizeMethods import groovy.util.XmlParser import groovy.xml.XmlUtil + buildscript { + repositories { + mavenCentral() + mavenLocal() + } dependencies { classpath 'org.openclover:clover:4.4.1' } } + plugins { id 'java' id 'application' @@ -26,12 +32,6 @@ repositories { jcenter() mavenCentral() mavenLocal() - flatDir { - dirs gradlePluginsDir - } -} - -dependencies { } @@ -46,11 +46,21 @@ ext { jalviewDirRelativePath = jalviewDir // local build environment properties - def localProps = "${jalviewDirAbsolutePath}/local.properties" + // can be "projectDir/local.properties" + def localProps = "${projectDir}/local.properties" + def propsFile = null; if (file(localProps).exists()) { + propsFile = localProps + } + // or "../projectDir_local.properties" + def dirLocalProps = projectDir.getParent() + "/" + projectDir.getName() + "_local.properties" + if (file(dirLocalProps).exists()) { + propsFile = dirLocalProps + } + if (propsFile != null) { try { def p = new Properties() - def localPropsFIS = new FileInputStream(localProps) + def localPropsFIS = new FileInputStream(propsFile) p.load(localPropsFIS) localPropsFIS.close() p.each { @@ -58,9 +68,9 @@ ext { def oldval = findProperty(key) setProperty(key, val) if (oldval != null) { - println("Overriding property '${key}' ('${oldval}') with local.properties value '${val}'") + println("Overriding property '${key}' ('${oldval}') with ${file(propsFile).getName()} value '${val}'") } else { - println("Setting unknown property '${key}' with local.properties value '${val}'") + println("Setting unknown property '${key}' with ${file(propsFile).getName()}s value '${val}'") } } } catch (Exception e) { @@ -68,6 +78,26 @@ ext { } } + //// + // Import releaseProps from the RELEASE file + // or a file specified via JALVIEW_RELEASE_FILE if defined + // Expect jalview.version and target release branch in jalview.release + def releaseProps = new Properties(); + def releasePropFile = findProperty("JALVIEW_RELEASE_FILE"); + def defaultReleasePropFile = "${jalviewDirAbsolutePath}/RELEASE"; + try { + (new File(releasePropFile!=null ? releasePropFile : defaultReleasePropFile)).withInputStream { + releaseProps.load(it) + } + } catch (Exception fileLoadError) { + throw new Error("Couldn't load release properties file "+(releasePropFile==null ? defaultReleasePropFile : "from custom location: releasePropFile"),fileLoadError); + } + //// + // Set JALVIEW_VERSION if it is not already set + if (findProperty(JALVIEW_VERSION)==null || "".equals(JALVIEW_VERSION)) { + JALVIEW_VERSION = releaseProps.get("jalview.version") + } + // this property set when running Eclipse headlessly j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild") // this property set by Eclipse @@ -104,6 +134,7 @@ ext { // clover cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}") + cloverDb = string("${buildDir}/clover/clover.db") classesDir = string("${jalviewDir}/${classes_dir}") if (clover.equals("true")) { use_clover = true @@ -125,8 +156,14 @@ ext { getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}") getdownAppDistDir = getdown_app_dir_alt buildProperties = string("${classesDir}/${build_properties_file}") - reportRsyncCmd = false + reportRsyncCommand = false jvlChannelName = CHANNEL.toLowerCase() + install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build + install4jDSStore = "DS_Store-NON-RELEASE" + install4jDMGBackgroundImage = "jalview_dmg_background-NON-RELEASE.png" + install4jInstallerName = "${jalview_name} Non-Release Installer" + install4jExecutableName = jalview_name.replaceAll("[^\\w]+", "_").toLowerCase() + install4jExtraScheme = "jalviewx" switch (CHANNEL) { case "BUILD": @@ -135,11 +172,20 @@ ext { getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}") getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}") jvlChannelName += "_${getdownChannelName}" + // automatically add the test group Not-bamboo for exclusion + if ("".equals(testngExcludedGroups)) { + testngExcludedGroups = "Not-bamboo" + } + install4jExtraScheme = "jalviewb" break case "RELEASE": getdownAppDistDir = getdown_app_dir_release reportRsyncCommand = true + install4jSuffix = "" + install4jDSStore = "DS_Store" + install4jDMGBackgroundImage = "jalview_dmg_background.png" + install4jInstallerName = "${jalview_name} Installer" break case "ARCHIVE": @@ -154,6 +200,7 @@ ext { buildDist = false } reportRsyncCommand = true + install4jExtraScheme = "jalviewa" break case "ARCHIVELOCAL": @@ -169,14 +216,34 @@ ext { } reportRsyncCommand = true getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}") + install4jSuffix = "Archive" + install4jExtraScheme = "jalviewa" break case "DEVELOP": reportRsyncCommand = true + + // DEVELOP-RELEASE is usually associated with a Jalview release series so set the version + JALVIEW_VERSION=JALVIEW_VERSION+"-develop" + + install4jSuffix = "Develop" + install4jDSStore = "DS_Store-DEVELOP" + install4jDMGBackgroundImage = "jalview_dmg_background-DEVELOP.png" + install4jExtraScheme = "jalviewd" + install4jInstallerName = "${jalview_name} Develop Installer" break case "TEST-RELEASE": reportRsyncCommand = true + + // TEST-RELEASE is usually associated with a Jalview release series so set the version + JALVIEW_VERSION=JALVIEW_VERSION+"-test" + + install4jSuffix = "Test" + install4jDSStore = "DS_Store-TEST-RELEASE" + install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png" + install4jExtraScheme = "jalviewt" + install4jInstallerName = "${jalview_name} Test Installer" break case ~/^SCRATCH(|-[-\w]*)$/: @@ -184,6 +251,7 @@ ext { getdownDir = string("${getdownChannelName}/${JAVA_VERSION}") getdownAppBase = string("${getdown_channel_base}/${getdownDir}") reportRsyncCommand = true + install4jSuffix = "Scratch" break case "TEST-LOCAL": @@ -193,11 +261,18 @@ ext { getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString() getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}") } + JALVIEW_VERSION = "TEST" + install4jSuffix = "Test-Local" + install4jDSStore = "DS_Store-TEST-RELEASE" + install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png" + install4jExtraScheme = "jalviewt" + install4jInstallerName = "${jalview_name} Test Installer" break case "LOCAL": getdownAppBase = file(getdownWebsiteDir).toURI().toString() getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}") + install4jExtraScheme = "jalviewl" break default: // something wrong specified @@ -211,7 +286,37 @@ ext { println("Overriding getdown appbase with '${getdownAppBase}'") } // sanitise file name for jalview launcher file for this channel - jvlChannelName = jvlChannelName.replaceAll(/[^\w\-]/,"_") + jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_") + // install4j application and folder names + if (install4jSuffix == "") { + install4jApplicationName = "${jalview_name}" + install4jBundleId = "${install4j_bundle_id}" + install4jWinApplicationId = install4j_release_win_application_id + } else { + install4jApplicationName = "${jalview_name} ${install4jSuffix}" + install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase() + // add int hash of install4jSuffix to the last part of the application_id + def id = install4j_release_win_application_id + def idsplitreverse = id.split("-").reverse() + idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode() + install4jWinApplicationId = idsplitreverse.reverse().join("-") + } + // sanitise folder and id names + // install4jApplicationFolder = e.g. "Jalview Build" + install4jApplicationFolder = install4jApplicationName + .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \ + .replaceAll("_+", "_") // collapse __ + install4jInternalId = install4jApplicationName + .replaceAll(" ","_") + .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.] + .replaceAll("_+", "") // collapse __ + //.replaceAll("_*-_*", "-") // collapse _-_ + install4jUnixApplicationFolder = install4jApplicationName + .replaceAll(" ","_") + .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.] + .replaceAll("_+", "_") // collapse __ + .replaceAll("_*-_*", "-") // collapse _-_ + .toLowerCase() getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}") //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}" @@ -410,12 +515,13 @@ dependencies { } } - configurations { cloverRuntime cloverRuntime.extendsFrom cloverCompile } + +// eclipse project and settings files creation, also used by buildship eclipse { project { name = eclipse_project_name @@ -550,18 +656,24 @@ eclipse { } -task cloverInstr() { +task cloverInstr { // only instrument source, we build test classes as normal inputs.files files (sourceSets.main.allJava,sourceSets.test.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"])) outputs.dir cloverInstrDir doFirst { delete cloverInstrDir - def argsList = ["--initstring", "${buildDir}/clover/clover.db", - "-d", "${buildDir}/${cloverSourcesInstrDir}"] - argsList.addAll(inputs.files.files.collect({ file -> - file.absolutePath - })) + def argsList = [ + "--initstring", + cloverDb, + "-d", + cloverInstrDir.getPath(), + ] + argsList.addAll( + inputs.files.files.collect( + { file -> file.absolutePath } + ) + ) String[] args = argsList.toArray() println("About to instrument "+args.length +" files") com.atlassian.clover.CloverInstr.mainImpl(args) @@ -569,26 +681,57 @@ task cloverInstr() { } +cloverClasses.dependsOn cloverInstr + + task cloverReport { group = "Verification" - description = "Creates the Clover report" - inputs.dir "${buildDir}/clover" - outputs.dir "${reportsDir}/clover" - onlyIf { - file("${buildDir}/clover/clover.db").exists() - } + description = "Creates the Clover report" + inputs.dir "${buildDir}/clover" + outputs.dir "${reportsDir}/clover" + onlyIf { + file(cloverDb).exists() + } doFirst { - def argsList = ["--initstring", "${buildDir}/clover/clover.db", - "-o", "${reportsDir}/clover"] + def argsList = [ + "--initstring", + cloverDb, + "-o", + "${reportsDir}/clover" + ] String[] args = argsList.toArray() com.atlassian.clover.reporters.html.HtmlReporter.runReport(args) // and generate ${reportsDir}/clover/clover.xml - args = ["--initstring", "${buildDir}/clover/clover.db", - "-o", "${reportsDir}/clover/clover.xml"].toArray() + args = [ + "--initstring", + cloverDb, + "-o", + "${reportsDir}/clover/clover.xml" + ].toArray() com.atlassian.clover.reporters.xml.XMLReporter.runReport(args) } } + + +compileCloverJava { + + doFirst { + sourceCompatibility = compile_source_compatibility + targetCompatibility = compile_target_compatibility + options.compilerArgs += additional_compiler_args + print ("Setting target compatibility to "+targetCompatibility+"\n") + } + classpath += configurations.cloverRuntime +} + + +task cleanClover { + doFirst { + delete cloverInstrDir + delete cloverDb + } +} // end clover bits @@ -620,18 +763,6 @@ compileTestJava { } -compileCloverJava { - - doFirst { - sourceCompatibility = compile_source_compatibility - targetCompatibility = compile_target_compatibility - options.compilerArgs += additional_compiler_args - print ("Setting target compatibility to "+targetCompatibility+"\n") - } - classpath += configurations.cloverRuntime -} - - clean { doFirst { delete sourceSets.main.java.outputDir @@ -640,9 +771,9 @@ clean { cleanTest { + dependsOn cleanClover doFirst { delete sourceSets.test.java.outputDir - delete cloverInstrDir } } @@ -818,10 +949,13 @@ test { useTestNG() { includeGroups testngGroups + excludeGroups testngExcludedGroups preserveOrder true useDefaultListeners=true } + maxHeapSize = "1024m" + workingDir = jalviewDir //systemProperties 'clover.jar' System.properties.clover.jar sourceCompatibility = compile_source_compatibility @@ -1001,7 +1135,7 @@ task getdownWebsite() { } getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}" - // go through properties looking for getdown_txt_... + // set some getdown_txt_ properties then go through all properties looking for getdown_txt_... def props = project.properties.sort { it.key } if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) { props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion) @@ -1013,7 +1147,11 @@ task getdownWebsite() { props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation) } - props.put("getdown_txt_appbase", getdownAppBase) + props.put("getdown_txt_title", jalview_name) + props.put("getdown_txt_ui.name", install4jApplicationName) + + // start with appbase + getdownTextString += "appbase = ${getdownAppBase}\n" props.each{ prop, val -> if (prop.startsWith("getdown_txt_") && val != null) { if (prop.startsWith("getdown_txt_multi_")) { @@ -1102,7 +1240,7 @@ task getdownWebsite() { def getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl" def launchJvl = file("${getdownWebsiteDir}/${getdownLaunchJvl}") - launchJvl.write("appbase="+props.get("getdown_txt_appbase")) + launchJvl.write("appbase=${getdownAppBase}") copy { from getdownLauncher @@ -1162,8 +1300,10 @@ task getdownWebsite() { // a helper task to allow getdown digest of any dir: `gradle getdownDigestDir -PDIGESTDIR=/path/to/my/random/getdown/dir task getdownDigestDir(type: JavaExec) { + group "Help" + description "A task to run a getdown Digest on a dir with getdown.txt. Provide a DIGESTDIR property via -PDIGESTDIR=..." + def digestDirPropertyName = "DIGESTDIR" - description = "Digest a local dir (-P${digestDirPropertyName}=...) for getdown" doFirst { classpath = files(getdownLauncher) def digestDir = findProperty(digestDirPropertyName) @@ -1240,6 +1380,7 @@ task copyInstall4jTemplate { def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}") inputs.file(install4jTemplateFile) inputs.file(install4jFileAssociationsFile) + inputs.property("CHANNEL", { CHANNEL }) outputs.file(install4jConfFile) doLast { @@ -1266,7 +1407,7 @@ task copyInstall4jTemplate { // put file association actions where placeholder action is def install4jFileAssociationsText = install4jFileAssociationsFile.text def fileAssociationActions = new XmlParser().parseText("${install4jFileAssociationsText}") - install4jConfigXml.'**'.action.any { a -> + install4jConfigXml.'**'.action.any { a -> // .any{} stops after the first one that returns true if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') { def parent = a.parent() parent.remove(a) @@ -1278,6 +1419,36 @@ task copyInstall4jTemplate { } } + // use Windows Program Group with Examples folder for RELEASE, and Program Group without Examples for everything else + // NB we're deleting the /other/ one! + // Also remove the examples subdir from non-release versions + def customizedIdToDelete = "PROGRAM_GROUP_RELEASE" + // 2.11.1.0 NOT releasing with the Examples folder in the Program Group + if (false && CHANNEL=="RELEASE") { // remove 'false && ' to include Examples folder in RELEASE channel + customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE" + } else { + // remove the examples subdir from Full File Set + def files = install4jConfigXml.files[0] + def fileset = files.filesets.fileset.find { fs -> fs.'@customizedId' == "FULL_FILE_SET" } + def root = files.roots.root.find { r -> r.'@fileset' == fileset.'@id' } + def mountPoint = files.mountPoints.mountPoint.find { mp -> mp.'@root' == root.'@id' } + def dirEntry = files.entries.dirEntry.find { de -> de.'@mountPoint' == mountPoint.'@id' && de.'@subDirectory' == "examples" } + dirEntry.parent().remove(dirEntry) + } + install4jConfigXml.'**'.action.any { a -> + if (a.'@customizedId' == customizedIdToDelete) { + def parent = a.parent() + parent.remove(a) + return true + } + } + + // remove the "Uninstall Old Jalview (optional)" symlink from DMG for non-release DS_Stores + if (! (CHANNEL == "RELEASE" || CHANNEL == "TEST-RELEASE" ) ) { + def symlink = install4jConfigXml.'**'.topLevelFiles.symlink.find { sl -> sl.'@name' == "Uninstall Old Jalview (optional).app" } + symlink.parent().remove(symlink) + } + // write install4j file install4jConfFile.text = XmlUtil.serialize(install4jConfigXml) } @@ -1315,7 +1486,8 @@ task installers(type: com.install4j.gradle.Install4jTask) { def install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}" variables = [ - 'JALVIEW_NAME': getdown_txt_title, + 'JALVIEW_NAME': jalview_name, + 'JALVIEW_APPLICATION_NAME': install4jApplicationName, 'JALVIEW_DIR': "../..", 'OSX_KEYSTORE': OSX_KEYSTORE, 'JSIGN_SH': JSIGN_SH, @@ -1334,8 +1506,12 @@ task installers(type: com.install4j.gradle.Install4jTask) { 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz, 'LINUX_JAVA_VM_TGZ': linuxJavaVMTgz, 'COPYRIGHT_MESSAGE': install4j_copyright_message, - 'MACOS_BUNDLE_ID': install4j_macOS_bundle_id, - 'INSTALLER_NAME': install4j_installer_name, + 'BUNDLE_ID': install4jBundleId, + 'INTERNAL_ID': install4jInternalId, + 'WINDOWS_APPLICATION_ID': install4jWinApplicationId, + 'MACOS_DS_STORE': install4jDSStore, + 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage, + 'INSTALLER_NAME': install4jInstallerName, 'INSTALL4J_UTILS_DIR': install4j_utils_dir, 'GETDOWN_WEBSITE_DIR': getdown_website_dir, 'GETDOWN_FILES_DIR': getdown_files_dir, @@ -1345,8 +1521,16 @@ task installers(type: com.install4j.gradle.Install4jTask) { 'GETDOWN_INSTALL_DIR': getdown_install_dir, 'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations, 'BUILD_DIR': install4jBuildDir, + 'APPLICATION_CATEGORIES': install4j_application_categories, + 'APPLICATION_FOLDER': install4jApplicationFolder, + 'UNIX_APPLICATION_FOLDER': install4jUnixApplicationFolder, + 'EXECUTABLE_NAME': install4jExecutableName, + 'EXTRA_SCHEME': install4jExtraScheme, ] + //println("INSTALL4J VARIABLES:") + //variables.each{k,v->println("${k}=${v}")} + destination = "${jalviewDir}/${install4jBuildDir}" buildSelected = true