X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=build.gradle;h=100bc59d8705aff75233dd119119df64a84d16bd;hp=09efce1c8b7223e879cf84e84a3dd9c2b7e20c12;hb=8d46b6025f358a2642fb5996be91a75885f8fc88;hpb=41e0150abd0df895ce6fd849accde0d7c875bb06 diff --git a/build.gradle b/build.gradle index 09efce1..100bc59 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,9 @@ import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension import com.vladsch.flexmark.ext.autolink.AutolinkExtension import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension import com.vladsch.flexmark.ext.toc.TocExtension +import com.google.common.hash.HashCode +import com.google.common.hash.Hashing +import com.google.common.io.Files buildscript { repositories { @@ -44,6 +47,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 { @@ -196,6 +201,7 @@ ext { getdownFullArchiveDir = null getdownTextLines = [] getdownLaunchJvl = null + getdownVersionLaunchJvl = null buildDist = true buildProperties = null @@ -1804,7 +1810,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 +1858,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() @@ -2011,12 +2018,11 @@ clean { 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-${JALVIEW_VERSION_UNDERSCORES}.json") doFirst { delete installersOutputTxt delete installersSha256 - delete installersJsonFile + delete hugoDataJsonFile } } @@ -2132,7 +2138,18 @@ 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) { + HashCode hash = Files.asByteSource(myFile).hash(Hashing.sha256()) + return myFile.exists() + ? [ + "filename" : myFile.getName(), + "filesize" : myFile.length(), + "sha256" : hash.toString() + ] + : 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 +2158,12 @@ def writeInstallersJsonFile(File installersOutputTxt, File installersSha256, Fil throw new GradleException("Required input file '${installersSha256.getPath()}' doesn't exist.") return null; } - def hash = ["channel":getdownChannelName,"date":getDate("yyyy-MM-dd HH:mm:ss")] + 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,36 +2188,26 @@ def writeInstallersJsonFile(File installersOutputTxt, File installersSha256, Fil def innerHash = (hash.(idHash."${filename}"))."sha256" = vals[0] } } - return installersJsonFile.write(new JsonBuilder(hash).toPrettyString()) -} - - -/* -ALSO COMPILE AND ADD IN TO THE JSON FILE INFO FOR EXECUTABLE JAR, VERSION JVL FILE, SOURCE TAR FILE -*/ + // executable JAR + def jarHash = getDataHash(file(shadowJar.archiveFile)) + if (jarHash != null) { + hash."JAR" = jarHash; + } - - - - -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") - - 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 { @@ -2206,13 +2218,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 } @@ -2350,6 +2361,26 @@ 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 hugoDataJsonFile = file("${jalviewDir}/${hugo_build_dir}/data/installers-${JALVIEW_VERSION_UNDERSCORES}.json") + + inputs.file(installersOutputTxt) + if (install4jCheckSums) { + inputs.file(installersSha256) + } + outputs.file(hugoDataJsonFile) + + doFirst { + writeDataJsonFile(installersOutputTxt, installersSha256, hugoDataJsonFile) + } +} task helppages { dependsOn copyHelp