X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=4d2c350ee8ede255e3720560c92848fc34aa55ef;hb=db198a0eadd949de630aeef94c98321ffb6473f9;hp=420d37cf2a17888b6890573fd68cf3644138fd19;hpb=ecdae8027a9bad9e43f0ab12c54aec09fade15a1;p=jalview.git diff --git a/build.gradle b/build.gradle index 420d37c..4d2c350 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,7 @@ import groovy.transform.ExternalizeMethods import groovy.util.XmlParser import groovy.xml.XmlUtil import groovy.json.JsonBuilder +import org.gradle.internal.hash.HashUtil import com.vladsch.flexmark.util.ast.Node import com.vladsch.flexmark.html.HtmlRenderer import com.vladsch.flexmark.parser.Parser @@ -44,6 +45,8 @@ plugins { id 'com.install4j.gradle' version '9.0.6' id 'com.dorongold.task-tree' version '1.5' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree id 'com.palantir.git-version' version '0.13.0' apply false +// id 'org.gradle.crypto.checksum' version '1.4.0' + } repositories { @@ -97,6 +100,7 @@ def overrideProperties(String propsFileName, boolean output = false) { ext { jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath() jalviewDirRelativePath = jalviewDir + date = new Date() getdownChannelName = CHANNEL.toLowerCase() // default to "default". Currently only has different cosmetics for "develop", "release", "default" @@ -195,6 +199,7 @@ ext { getdownFullArchiveDir = null getdownTextLines = [] getdownLaunchJvl = null + getdownVersionLaunchJvl = null buildDist = true buildProperties = null @@ -1054,7 +1059,6 @@ cleanTest { // format is a string like date.format("dd MMMM yyyy") def getDate(format) { - def date = new Date() return date.format(format) } @@ -1804,7 +1808,8 @@ task getdownArchiveBuild() { def v = "v${JALVIEW_VERSION_UNDERSCORES}" def vDir = "${getdownArchiveDir}/${v}" getdownFullArchiveDir = "${vDir}/getdown" - def vLaunchVersionJvl = "${vDir}/jalview-${v}.jvl" + getdownVersionLaunchJvl = "${vDir}/jalview-${v}.jvl" + def vAltDir = "alt_${v}" def archiveImagesDir = "${jalviewDir}/${channel_properties_dir}/old/images" @@ -1851,7 +1856,7 @@ task getdownArchiveBuild() { getdownArchiveTxt.write(getdownArchiveTextLines.join("\n")) - def vLaunchJvl = file(vLaunchVersionJvl) + def vLaunchJvl = file(getdownVersionLaunchJvl) vLaunchJvl.getParentFile().mkdirs() vLaunchJvl.write("appbase=${getdownFullArchiveAppBase}\n") def vLaunchJvlPath = vLaunchJvl.toPath().toAbsolutePath() @@ -2012,11 +2017,11 @@ task cleanInstallersDataFiles { def installersOutputTxt = file("${jalviewDir}/${install4jBuildDir}/output.txt") def installersSha256 = file("${jalviewDir}/${install4jBuildDir}/sha256sums") def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_") - def installersJsonFile = file("${jalviewDir}/${install4jBuildDir}/installers-${VERSION_UNDERSCORES}.json") + def hugoDataJsonFile = file("${jalviewDir}/${install4jBuildDir}/installers-${VERSION_UNDERSCORES}.json") doFirst { delete installersOutputTxt delete installersSha256 - delete installersJsonFile + delete hugoDataJsonFile } } @@ -2132,7 +2137,17 @@ task installerFiles(type: com.install4j.gradle.Install4jTask) { outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}") } -def writeInstallersJsonFile(File installersOutputTxt, File installersSha256, File installersJsonFile) { +def getDataHash(File myFile) { + return myFile.exists() + ? [ + "filename" : myFile.getName(), + "filesize" : myFile.length(), + "sha256" : HashUtil.createHash(myFile, "SHA-256").asHexString() + ] + : null +} + +def writeDataJsonFile(File installersOutputTxt, File installersSha256, File hugoDataJsonFile) { if (!installersOutputTxt.exists()) { throw new GradleException("Required input file '${installersOutputTxt.getPath()}' doesn't exist.") return null; @@ -2141,7 +2156,12 @@ def writeInstallersJsonFile(File installersOutputTxt, File installersSha256, Fil throw new GradleException("Required input file '${installersSha256.getPath()}' doesn't exist.") return null; } - def hash = [:] + def hash = [ + "channel" : getdownChannelName, + "date" : getDate("yyyy-MM-dd HH:mm:ss"), + "git-commit" : "${gitHash} [${gitBranch}]", + "version" : JALVIEW_VERSION + ] def idHash = [:] installersOutputTxt.readLines().each { def line -> if (line.startsWith("#")) { @@ -2166,26 +2186,26 @@ def writeInstallersJsonFile(File installersOutputTxt, File installersSha256, Fil def innerHash = (hash.(idHash."${filename}"))."sha256" = vals[0] } } - return installersJsonFile.write(new JsonBuilder(hash).toPrettyString()) -} - -task makeInstallersJsonFile { - dependsOn installerFiles - def installersOutputTxt = file("${jalviewDir}/${install4jBuildDir}/output.txt") - def installersSha256 = file("${jalviewDir}/${install4jBuildDir}/sha256sums") - def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_") - def installersJsonFile = file("${jalviewDir}/${install4jBuildDir}/installers-${VERSION_UNDERSCORES}.json") + // executable JAR + def jarHash = getDataHash(file(shadowJar.archiveFile)) + if (jarHash != null) { + hash."JAR" = jarHash; + } - inputs.file(installersOutputTxt) - if (install4jCheckSums) { - inputs.file(installersSha256) + // version JVL + def jvlHash =getDataHash(file(getdownVersionLaunchJvl)) + if (jvlHash != null) { + hash."JVL" = jvlHash; } - outputs.file(installersJsonFile) - doFirst { - writeInstallersJsonFile(installersOutputTxt, installersSha256, installersJsonFile) + // source TGZ + def tarHash = getDataHash(file(sourceDist.archiveFile)) + if (tarHash != null) { + hash."SOURCE" = tarHash; } + + return hugoDataJsonFile.write(new JsonBuilder(hash).toPrettyString()) } task staticMakeInstallersJsonFile { @@ -2196,13 +2216,12 @@ task staticMakeInstallersJsonFile { if (output == null || sha256 == null || json == null) { throw new GradleException("Must provide paths to all of output.txt, sha256sums, and output.json with '-Pi4j_output=... -Pi4j_sha256=... -Pi4j_json=...") } - writeInstallersJsonFile(file(output), file(sha256), file(json)) + writeDataJsonFile(file(output), file(sha256), file(json)) } } task installers { dependsOn installerFiles - dependsOn makeInstallersJsonFile } @@ -2340,6 +2359,27 @@ task sourceDist(type: Tar) { } } +task makeDataJsonFile { + dependsOn installerFiles + dependsOn sourceDist + dependsOn getdownArchive + dependsOn shadowJar + + def installersOutputTxt = file("${jalviewDir}/${install4jBuildDir}/output.txt") + def installersSha256 = file("${jalviewDir}/${install4jBuildDir}/sha256sums") + def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_") + def hugoDataJsonFile = file("${jalviewDir}/${hugo_build_dir}/data/installers-${VERSION_UNDERSCORES}.json") + + inputs.file(installersOutputTxt) + if (install4jCheckSums) { + inputs.file(installersSha256) + } + outputs.file(hugoDataJsonFile) + + doFirst { + writeDataJsonFile(installersOutputTxt, installersSha256, hugoDataJsonFile) + } +} task helppages { dependsOn copyHelp