+task cleanInstallersDataFiles {
+ def installersOutputTxt = file("${jalviewDir}/${install4jBuildDir}/output.txt")
+ def installersSha256 = file("${jalviewDir}/${install4jBuildDir}/sha256sums")
+ def hugoDataJsonFile = file("${jalviewDir}/${install4jBuildDir}/installers-${JALVIEW_VERSION_UNDERSCORES}.json")
+ doFirst {
+ delete installersOutputTxt
+ delete installersSha256
+ delete hugoDataJsonFile
+ }
+}
+
+task install4jDMGBackgroundImageCopy {
+ inputs.file "${install4jDMGBackgroundImageDir}/${install4jDMGBackgroundImageFile}"
+ outputs.dir "${install4jDMGBackgroundImageBuildDir}"
+ doFirst {
+ copy {
+ from(install4jDMGBackgroundImageDir) {
+ include(install4jDMGBackgroundImageFile)
+ }
+ into install4jDMGBackgroundImageBuildDir
+ }
+ }
+}
+
+task install4jDMGBackgroundImageProcess {
+ dependsOn install4jDMGBackgroundImageCopy
+
+ doFirst {
+ if (backgroundImageText) {
+ if (convertBinary == null) {
+ throw new StopExecutionException("No ImageMagick convert binary installed at '${convertBinaryExpectedLocation}'")
+ }
+ if (!project.hasProperty("install4j_background_image_text_suffix_cmd")) {
+ throw new StopExecutionException("No property 'install4j_background_image_text_suffix_cmd' defined. See channel_gradle.properties for channel ${CHANNEL}")
+ }
+ fileTree(dir: install4jDMGBackgroundImageBuildDir, include: "*.png").getFiles().each { file ->
+ exec {
+ executable convertBinary
+ args = [
+ file.getPath(),
+ '-font', install4j_background_image_text_font,
+ '-fill', install4j_background_image_text_colour,
+ '-draw', sprintf(install4j_background_image_text_suffix_cmd, channelSuffix),
+ '-draw', sprintf(install4j_background_image_text_commit_cmd, "git-commit: ${gitHash}"),
+ '-draw', sprintf(install4j_background_image_text_date_cmd, getDate("yyyy-MM-dd HH:mm:ss")),
+ file.getPath()
+ ]
+ }
+ }
+ }
+ }
+}
+
+
+python {
+ pip 'ds_store:1.3.0'
+}
+
+task install4jCustomiseDS_StoreX64(type: PythonTask) {
+ inputs.file(install4jDMGDSStore)
+ outputs.file(install4jDMGFixedDSStoreX64)
+ def command_args = [ jalview_customise_ds_store,
+ '--input', install4jDMGDSStore,
+ '--output', install4jDMGFixedDSStoreX64,
+ '--volumename', install4jmacOSArchiveX64Name,
+ '--backgroundfile', install4j_dmg_background_filename,
+ '--dmg', install4jmacOSArchiveX64DMGFilename + ".dmg",
+ '--appname', "${applicationName}.app",
+ ]
+ if (file(install4jDMGDSStoreJSON).exists()) {
+ command_args += [ '--config', install4jDMGDSStoreJSON ]
+ inputs.file(install4jDMGDSStoreJSON)
+ }
+ command = command_args
+ doFirst {
+ println("Running command '${command_args.join(' ')}'")
+ }
+}
+
+task install4jCustomiseDS_StoreAarch64(type: PythonTask) {
+ inputs.file(install4jDMGDSStore)
+ outputs.file(install4jDMGFixedDSStoreAarch64)
+ def command_args = [ jalview_customise_ds_store,
+ '--input', install4jDMGDSStore,
+ '--output', install4jDMGFixedDSStoreAarch64,
+ '--volumename', install4jmacOSArchiveAarch64Name,
+ '--backgroundfile', install4j_dmg_background_filename,
+ '--dmg', install4jmacOSArchiveAarch64DMGFilename + ".dmg",
+ '--appname', "${applicationName}.app",
+ ]
+ if (file(install4jDMGDSStoreJSON).exists()) {
+ command_args += [ '--config', install4jDMGDSStoreJSON ]
+ inputs.file(install4jDMGDSStoreJSON)
+ }
+ command = command_args
+ doFirst {
+ def print_args = []
+ for (int i = 0; i < command_args.size(); i++) {
+ def arg = command_args[i]
+ print_args += (i > 0 && !arg.startsWith("-")) ? "\"${arg}\"" : arg
+ }
+ println("Running command '${print_args.join(' ')}'")
+ }
+}
+
+task install4jCustomiseDS_Store {
+ dependsOn install4jCustomiseDS_StoreX64
+ dependsOn install4jCustomiseDS_StoreAarch64
+}
+
+task install4jDMGVmoptionsFile(type: Copy) {
+ def inputDir = "${jalviewDir}/${install4j_utils_dir}"
+ def outputDir = "${jalviewDir}/${install4j_build_dir}/tmp"
+
+ def installDateTime = getDate("yyyy-MM-dd HH:mm:ss") + " (build time)"
+
+ from(inputDir) {
+ include(string("${install4j_default_vmoptions}"))
+ rename(string("${install4j_default_vmoptions}"), string("${install4j_default_vmoptions}.X64"))
+
+ filter(ReplaceTokens,
+ beginToken: '__',
+ endToken: '__',
+ tokens: [
+ 'INSTALLERFILENAME': string("${install4jmacOSArchiveX64DMGFilename}.dmg"),
+ 'INSTALLDATETIME': installDateTime
+ ]
+ )
+
+ }
+
+ from(inputDir) {
+ include(string("${install4j_default_vmoptions}"))
+ rename(string("${install4j_default_vmoptions}"), string("${install4j_default_vmoptions}.AARCH64"))
+
+ filter(ReplaceTokens,
+ beginToken: '__',
+ endToken: '__',
+ tokens: [
+ 'INSTALLERFILENAME': string("${install4jmacOSArchiveAarch64DMGFilename}.dmg"),
+ 'INSTALLDATETIME': installDateTime
+ ]
+ )
+ }
+
+ into outputDir
+
+ inputs.file("${inputDir}/${install4j_default_vmoptions}")
+ outputs.file("${outputDir}/${install4j_default_vmoptions}.X64")
+ outputs.file("${outputDir}/${install4j_default_vmoptions}.AARCH64")
+}
+
+task install4jDMGProcesses {
+ dependsOn install4jDMGBackgroundImageProcess
+ dependsOn install4jCustomiseDS_Store
+ dependsOn install4jDMGVmoptionsFile
+}