X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=1142388f541fb42f1e54ae5e38907fde4a6c25a4;hb=cf430e4a0397a2fd50a70e39a141b911b35e9a0b;hp=f2e4aeccb8cfd16701f479fafdc3b42153bc8193;hpb=12cbc82ecab52eb8696515580daa17b3f45e725b;p=jalview.git diff --git a/build.gradle b/build.gradle index f2e4aec..1142388 100644 --- a/build.gradle +++ b/build.gradle @@ -38,6 +38,7 @@ buildscript { dependencies { classpath "com.vladsch.flexmark:flexmark-all:0.62.0" classpath "org.jsoup:jsoup:1.14.3" + classpath "com.eowise:gradle-imagemagick:0.5.1" } } @@ -109,12 +110,12 @@ ext { getdownChannelName = CHANNEL.toLowerCase() // default to "default". Currently only has different cosmetics for "develop", "release", "default" propertiesChannelName = ["develop", "release", "test-release", "jalviewjs", "jalviewjs-release" ].contains(getdownChannelName) ? getdownChannelName : "default" + channelDirName = propertiesChannelName // Import channel_properties - if (getdownChannelName.startsWith("develop")) { - propertiesChannelName = file("${jalviewDir}/${channel_properties_dir}/${getdownChannelName}").exists() ? getdownChannelName : "develop" - println("SET propertiesChannelName to '${propertiesChannelName}'") + if (getdownChannelName.startsWith("develop-")) { + channelDirName = "develop-SUFFIX" } - channelDir = string("${jalviewDir}/${channel_properties_dir}/${propertiesChannelName}") + channelDir = string("${jalviewDir}/${channel_properties_dir}/${channelDirName}") channelGradleProperties = string("${channelDir}/channel_gradle.properties") channelPropsFile = string("${channelDir}/${resource_dir}/${channel_props}") overrideProperties(channelGradleProperties, false) @@ -203,6 +204,8 @@ ext { testSourceDir = useClover ? cloverTestInstrDir : testDir testClassesDir = useClover ? cloverTestClassesDir : "${jalviewDir}/${test_output_dir}" + channelSuffix = "" + backgroundImageText = BACKGROUNDIMAGETEXT getdownChannelDir = string("${getdown_website_dir}/${propertiesChannelName}") getdownAppBaseDir = string("${jalviewDir}/${getdownChannelDir}/${JAVA_VERSION}") getdownArchiveDir = string("${jalviewDir}/${getdown_archive_dir}") @@ -220,12 +223,15 @@ ext { getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}") getdownAppDistDir = getdown_app_dir_alt getdownImagesDir = string("${jalviewDir}/${getdown_images_dir}") + getdownImagesBuildDir = string("${buildDir}/imagemagick/getdown") getdownSetAppBaseProperty = false // whether to pass the appbase and appdistdir to the application reportRsyncCommand = false jvlChannelName = CHANNEL.toLowerCase() install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build install4jDMGDSStore = "${install4j_images_dir}/${install4j_dmg_ds_store}" - install4jDMGBackgroundImage = "${install4j_images_dir}/${install4j_dmg_background}" + install4jDMGBackgroundImageDir = "${install4j_images_dir}" + install4jDMGBackgroundImageBuildDir = "build/imagemagick/install4j" + install4jDMGBackgroundImageFile = "${install4j_dmg_background}" install4jInstallerName = "${jalview_name} Non-Release Installer" install4jExecutableName = install4j_executable_name install4jExtraScheme = "jalviewx" @@ -250,6 +256,7 @@ ext { testng_excluded_groups = "Not-bamboo" } install4jExtraScheme = "jalviewb" + backgroundImageText = true break case [ "RELEASE", "JALVIEWJS-RELEASE" ]: @@ -280,7 +287,7 @@ ext { getdownDir = string("${getdownChannelName}/${JAVA_VERSION}") getdownAppBase = file(getdownAppBaseDir).toURI().toString() if (!file("${ARCHIVEDIR}/${package_dir}").exists()) { - throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution") + throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution [did not find '${ARCHIVEDIR}/${package_dir}']") } else { package_dir = string("${ARCHIVEDIR}/${package_dir}") buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}") @@ -305,6 +312,8 @@ ext { getdownAppBaseDir = string("${jalviewDir}/${getdownChannelDir}/${JAVA_VERSION}") getdownDir = string("${getdownChannelName}/${JAVA_VERSION}") getdownAppBase = string("${getdown_channel_base}/${getdownDir}") + channelSuffix = string(suffix) + backgroundImageText = true break case "DEVELOP": @@ -316,6 +325,7 @@ ext { install4jSuffix = "Develop" install4jExtraScheme = "jalviewd" install4jInstallerName = "${jalview_name} Develop Installer" + backgroundImageText = true break case "TEST-RELEASE": @@ -330,6 +340,7 @@ ext { install4jSuffix = "Test" install4jExtraScheme = "jalviewt" install4jInstallerName = "${jalview_name} Test Installer" + backgroundImageText = true break case ~/^SCRATCH(|-[-\w]*)$/: @@ -353,6 +364,7 @@ ext { install4jSuffix = "Test-Local" install4jExtraScheme = "jalviewt" install4jInstallerName = "${jalview_name} Test Installer" + backgroundImageText = true break case [ "LOCAL", "JALVIEWJS" ]: @@ -429,7 +441,6 @@ ext { modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"]) modules_runtimeClasspath = modules_compileClasspath */ - gitHash = "SOURCE" gitBranch = "Source" try { @@ -534,6 +545,14 @@ ext { helpSourceDir = string("${helpParentDir}/${help_dir}") helpFile = string("${helpBuildDir}/${help_dir}/help.jhm") + convertBinary = null + convertBinaryExpectedLocation = imagemagick_convert + if (convertBinaryExpectedLocation.startsWith("~/")) { + convertBinaryExpectedLocation = System.getProperty("user.home") + convertBinaryExpectedLocation.substring(1) + } + if (file(convertBinaryExpectedLocation).exists()) { + convertBinary = convertBinaryExpectedLocation + } relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath()) jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs") @@ -1426,8 +1445,6 @@ def getMdSections(String content) { } return sections } - - task copyHelp(type: Copy) { def inputDir = helpSourceDir def outputDir = "${helpBuildDir}/${help_dir}" @@ -1598,8 +1615,6 @@ task releasesTemplates { outputs.file(releasesHtmlFile) outputs.file(whatsnewHtmlFile) } - - task copyResources(type: Copy) { group = "build" description = "Copy (and make text substitutions in) the resources dir to the build area" @@ -1639,7 +1654,19 @@ task copyChannelResources(type: Copy) { def inputDir = "${channelDir}/${resource_dir}" def outputDir = resourcesBuildDir - from inputDir + from(inputDir) { + include(channel_props) + filter(ReplaceTokens, + beginToken: '__', + endToken: '__', + tokens: [ + 'SUFFIX': channelSuffix + ] + ) + } + from(inputDir) { + exclude(channel_props) + } into outputDir inputs.dir(inputDir) @@ -1724,6 +1751,8 @@ test { excludeGroups testng_excluded_groups preserveOrder true useDefaultListeners=true + // Uncomment to show stdout and stderr for tests in gradle build output + // testLogging.showStandardStreams = true } maxHeapSize = "1024m" @@ -1891,10 +1920,58 @@ shadowJar { minimize() } +task getdownImagesCopy() { + inputs.dir getdownImagesDir + outputs.dir getdownImagesBuildDir + + doFirst { + copy { + from(getdownImagesDir) { + include("*getdown*.png") + } + into getdownImagesBuildDir + } + } +} + +task getdownImagesProcess() { + dependsOn getdownImagesCopy + + doFirst { + if (backgroundImageText) { + if (convertBinary == null) { + throw new StopExecutionException("No ImageMagick convert binary installed at '${convertBinaryExpectedLocation}'") + } + if (!project.hasProperty("getdown_background_image_text_suffix_cmd")) { + throw new StopExecutionException("No property 'getdown_background_image_text_suffix_cmd' defined. See channel_gradle.properties for channel ${CHANNEL}") + } + fileTree(dir: getdownImagesBuildDir, include: "*background*.png").getFiles().each { file -> + exec { + executable convertBinary + args = [ + file.getPath(), + '-font', getdown_background_image_text_font, + '-fill', getdown_background_image_text_colour, + '-draw', sprintf(getdown_background_image_text_suffix_cmd, channelSuffix), + '-draw', sprintf(getdown_background_image_text_commit_cmd, "git-commit: ${gitHash}"), + '-draw', sprintf(getdown_background_image_text_date_cmd, getDate("yyyy-MM-dd HH:mm:ss")), + file.getPath() + ] + } + } + } + } +} + +task getdownImages() { + dependsOn getdownImagesProcess +} task getdownWebsite() { group = "distribution" description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer" + + dependsOn getdownImages if (buildDist) { dependsOn makeDist } @@ -1917,6 +1994,13 @@ task getdownWebsite() { copy { from channelPropsFile + filter(ReplaceTokens, + beginToken: '__', + endToken: '__', + tokens: [ + 'SUFFIX': channelSuffix + ] + ) into getdownAppBaseDir } getdownWebsiteResourceFilenames += file(channelPropsFile).getName() @@ -1932,13 +2016,13 @@ task getdownWebsite() { if (getdownAltMultiJavaLocation != null && getdownAltMultiJavaLocation.length() > 0) { props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation) } - if (getdownImagesDir != null && file(getdownImagesDir).exists()) { - props.put("getdown_txt_ui.background_image", "${getdownImagesDir}/${getdown_background_image}") - props.put("getdown_txt_ui.instant_background_image", "${getdownImagesDir}/${getdown_instant_background_image}") - props.put("getdown_txt_ui.error_background", "${getdownImagesDir}/${getdown_error_background}") - props.put("getdown_txt_ui.progress_image", "${getdownImagesDir}/${getdown_progress_image}") - props.put("getdown_txt_ui.icon", "${getdownImagesDir}/${getdown_icon}") - props.put("getdown_txt_ui.mac_dock_icon", "${getdownImagesDir}/${getdown_mac_dock_icon}") + if (getdownImagesBuildDir != null && file(getdownImagesBuildDir).exists()) { + props.put("getdown_txt_ui.background_image", "${getdownImagesBuildDir}/${getdown_background_image}") + props.put("getdown_txt_ui.instant_background_image", "${getdownImagesBuildDir}/${getdown_instant_background_image}") + props.put("getdown_txt_ui.error_background", "${getdownImagesBuildDir}/${getdown_error_background}") + props.put("getdown_txt_ui.progress_image", "${getdownImagesBuildDir}/${getdown_progress_image}") + props.put("getdown_txt_ui.icon", "${getdownImagesBuildDir}/${getdown_icon}") + props.put("getdown_txt_ui.mac_dock_icon", "${getdownImagesBuildDir}/${getdown_mac_dock_icon}") } props.put("getdown_txt_title", jalview_name) @@ -2272,7 +2356,6 @@ task getdownArchive() { dependsOn getdownArchiveBuild dependsOn getdownArchiveDigest } - tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } @@ -2327,7 +2410,6 @@ task copyInstall4jTemplate { macosArchive.attributes().remove('executeSetupApp') macosArchive.attributes().remove('setupAppId') } - // turn off checksum creation for LOCAL channel def e = install4jConfigXml.application[0] e.'@createChecksums' = string(install4jCheckSums) @@ -2394,12 +2476,59 @@ task cleanInstallersDataFiles { } } +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() + ] + } + } + } + } +} + +task install4jDMGBackgroundImage { + dependsOn install4jDMGBackgroundImageProcess +} + task installerFiles(type: com.install4j.gradle.Install4jTask) { group = "distribution" description = "Create the install4j installers" dependsOn getdown dependsOn copyInstall4jTemplate dependsOn cleanInstallersDataFiles + dependsOn install4jDMGBackgroundImage projectFile = install4jConfFile @@ -2442,7 +2571,7 @@ task installerFiles(type: com.install4j.gradle.Install4jTask) { 'INTERNAL_ID': install4jInternalId, 'WINDOWS_APPLICATION_ID': install4jWinApplicationId, 'MACOS_DMG_DS_STORE': install4jDMGDSStore, - 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage, + 'MACOS_DMG_BG_IMAGE': "${install4jDMGBackgroundImageBuildDir}/${install4jDMGBackgroundImageFile}", 'WRAPPER_LINK': getdownWrapperLink, 'BASH_WRAPPER_SCRIPT': getdown_bash_wrapper_script, 'POWERSHELL_WRAPPER_SCRIPT': getdown_powershell_wrapper_script, @@ -2584,7 +2713,6 @@ task installers { dependsOn installerFiles } - spotless { java { eclipse().configFile(eclipse_codestyle_file) @@ -2759,7 +2887,6 @@ task dataInstallersJson { task helppages { group "help" description "Copies all help pages to build dir. Runs ant task 'pubhtmlhelp'." - dependsOn copyHelp dependsOn pubhtmlhelp