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
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 {
getdownFullArchiveDir = null
getdownTextLines = []
getdownLaunchJvl = null
+ getdownVersionLaunchJvl = null
buildDist = true
buildProperties = null
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"
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()
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
}
}
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;
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("#")) {
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 {
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
}
}
}
+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