JAL-4111 Allow -PCHANNEL=DEVELOP-version for new appbase. Add a utils/channel/develo...
[jalview.git] / build.gradle
index 51c7eb2..f2e4aec 100644 (file)
@@ -9,6 +9,7 @@ import org.gradle.util.ConfigureUtil
 import org.gradle.plugins.ide.eclipse.model.Output
 import org.gradle.plugins.ide.eclipse.model.Library
 import java.security.MessageDigest
+import java.util.regex.Matcher
 import groovy.transform.ExternalizeMethods
 import groovy.util.XmlParser
 import groovy.xml.XmlUtil
@@ -48,7 +49,7 @@ plugins {
   id "com.diffplug.gradle.spotless" version "3.28.0"
   id 'com.github.johnrengelman.shadow' version '4.0.3'
   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.dorongold.task-tree' version '2.1.0' // only needed to display task dependency tree with  gradle task1 [task2 ...] taskTree
   id 'com.palantir.git-version' version '0.13.0' apply false
 }
 
@@ -109,6 +110,10 @@ ext {
   // default to "default". Currently only has different cosmetics for "develop", "release", "default"
   propertiesChannelName = ["develop", "release", "test-release", "jalviewjs", "jalviewjs-release" ].contains(getdownChannelName) ? getdownChannelName : "default"
   // Import channel_properties
+  if (getdownChannelName.startsWith("develop")) {
+    propertiesChannelName = file("${jalviewDir}/${channel_properties_dir}/${getdownChannelName}").exists() ? getdownChannelName : "develop"
+    println("SET propertiesChannelName to '${propertiesChannelName}'")
+  }
   channelDir = string("${jalviewDir}/${channel_properties_dir}/${propertiesChannelName}")
   channelGradleProperties = string("${channelDir}/channel_gradle.properties")
   channelPropsFile = string("${channelDir}/${resource_dir}/${channel_props}")
@@ -287,6 +292,21 @@ ext {
     install4jExtraScheme = "jalviewa"
     break
 
+    case ~/^DEVELOP-([\.\-\w]*)$/:
+    def suffix = Matcher.lastMatcher[0][1]
+    reportRsyncCommand = true
+    getdownSetAppBaseProperty = true
+    JALVIEW_VERSION=JALVIEW_VERSION+"-d${suffix}-${buildDate}"
+    install4jSuffix = "Develop ${suffix}"
+    install4jExtraScheme = "jalviewd"
+    install4jInstallerName = "${jalview_name} Develop ${suffix} Installer"
+    getdownChannelName = string("develop-${suffix}")
+    getdownChannelDir = string("${getdown_website_dir}/${getdownChannelName}")
+    getdownAppBaseDir = string("${jalviewDir}/${getdownChannelDir}/${JAVA_VERSION}")
+    getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
+    getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
+    break
+
     case "DEVELOP":
     reportRsyncCommand = true
     getdownSetAppBaseProperty = true
@@ -1407,14 +1427,52 @@ def getMdSections(String content) {
   return sections
 }
 
+
+task copyHelp(type: Copy) {
+  def inputDir = helpSourceDir
+  def outputDir = "${helpBuildDir}/${help_dir}"
+  from(inputDir) {
+    include('**/*.txt')
+    include('**/*.md')
+    include('**/*.html')
+    include('**/*.hs')
+    include('**/*.xml')
+    include('**/*.jhm')
+    filter(ReplaceTokens,
+      beginToken: '$$',
+      endToken: '$$',
+      tokens: [
+        'Version-Rel': JALVIEW_VERSION,
+        'Year-Rel': getDate("yyyy")
+      ]
+    )
+  }
+  from(inputDir) {
+    exclude('**/*.txt')
+    exclude('**/*.md')
+    exclude('**/*.html')
+    exclude('**/*.hs')
+    exclude('**/*.xml')
+    exclude('**/*.jhm')
+  }
+  into outputDir
+
+  inputs.dir(inputDir)
+  outputs.files(helpFile)
+  outputs.dir(outputDir)
+}
+
+
 task releasesTemplates {
   group "help"
   description "Recreate whatsNew.html and releases.html from markdown files and templates in help"
 
+  dependsOn copyHelp
+
   def releasesTemplateFile = file("${jalviewDir}/${releases_template}")
   def whatsnewTemplateFile = file("${jalviewDir}/${whatsnew_template}")
-  def releasesHtmlFile = file("${helpSourceDir}/${releases_html}")
-  def whatsnewHtmlFile = file("${helpSourceDir}/${whatsnew_html}")
+  def releasesHtmlFile = file("${helpBuildDir}/${help_dir}/${releases_html}")
+  def whatsnewHtmlFile = file("${helpBuildDir}/${help_dir}/${whatsnew_html}")
   def releasesMdDir = "${jalviewDir}/${releases_dir}"
   def whatsnewMdDir = "${jalviewDir}/${whatsnew_dir}"
 
@@ -1478,16 +1536,16 @@ task releasesTemplates {
       }
       def displayDate = releaseFilesDates[rFile].format("dd/MM/yyyy")
 
-        def lm = null
-        def rContentProcessed = ""
-        rContent.eachLine { line ->
-          if (lm = line =~ /^(\s*-)(\s*<!--[^>]*?-->)(.*)$/) {
-            line = "${lm[0][1]}${lm[0][3]}${lm[0][2]}"
-        } else if (lm = line =~ /^###([^#]+.*)$/) {
-            line = "_${lm[0][1].trim()}_"
-          }
-          rContentProcessed += line + "\n"
+      def lm = null
+      def rContentProcessed = ""
+      rContent.eachLine { line ->
+        if (lm = line =~ /^(\s*-)(\s*<!--[^>]*?-->)(.*)$/) {
+          line = "${lm[0][1]}${lm[0][3]}${lm[0][2]}"
+      } else if (lm = line =~ /^###([^#]+.*)$/) {
+          line = "_${lm[0][1].trim()}_"
         }
+        rContentProcessed += line + "\n"
+      }
 
       def rContentSections = getMdSections(rContentProcessed)
       def rVersion = versionTemplate
@@ -1523,9 +1581,12 @@ task releasesTemplates {
       whatsnewHtml = whatsnewTemplateFile.text.replaceAll("__WHATS_NEW__", whatsnewHtml)
       whatsnewHtmlFile.text = hugoTemplateSubstitutions(whatsnewHtml,
         [
+            VERSION: JALVIEW_VERSION,
           DISPLAY_DATE: wnDisplayDate
         ]
       )
+    } else if (gradle.taskGraph.hasTask(":linkCheck")) {
+      whatsnewHtmlFile.text = "Development build " + getDate("yyyy-MM-dd HH:mm:ss")
     }
 
   }
@@ -1539,43 +1600,6 @@ task releasesTemplates {
 }
 
 
-task copyHelp(type: Copy) {
-  dependsOn releasesTemplates
-
-  def inputDir = helpSourceDir
-  def outputDir = "${helpBuildDir}/${help_dir}"
-  from(inputDir) {
-    include('**/*.txt')
-    include('**/*.md')
-    include('**/*.html')
-    include('**/*.hs')
-    include('**/*.xml')
-    include('**/*.jhm')
-    filter(ReplaceTokens,
-      beginToken: '$$',
-      endToken: '$$',
-      tokens: [
-        'Version-Rel': JALVIEW_VERSION,
-        'Year-Rel': getDate("yyyy")
-      ]
-    )
-  }
-  from(inputDir) {
-    exclude('**/*.txt')
-    exclude('**/*.md')
-    exclude('**/*.html')
-    exclude('**/*.hs')
-    exclude('**/*.xml')
-    exclude('**/*.jhm')
-  }
-  into outputDir
-
-  inputs.dir(inputDir)
-  outputs.files(helpFile)
-  outputs.dir(outputDir)
-}
-
-
 task copyResources(type: Copy) {
   group = "build"
   description = "Copy (and make text substitutions in) the resources dir to the build area"
@@ -1636,6 +1660,7 @@ task createBuildProperties(type: WriteProperties) {
   property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
   property "VERSION", JALVIEW_VERSION
   property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
+  property "JAVA_COMPILE_VERSION", JAVA_INTEGER_VERSION
   if (getdownSetAppBaseProperty) {
     property "GETDOWNAPPBASE", getdownAppBase
     property "GETDOWNAPPDISTDIR", getdownAppDistDir
@@ -1673,6 +1698,7 @@ task prepare {
   dependsOn buildResources
   dependsOn copyDocs
   dependsOn copyHelp
+  dependsOn releasesTemplates
   dependsOn convertMdFiles
   dependsOn buildIndices
 }
@@ -1745,7 +1771,7 @@ task linkCheck(type: JavaExec) {
   def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out")
   classpath = files("${jalviewDir}/${utils_dir}")
   main = "HelpLinksChecker"
-  workingDir = jalviewDir
+  workingDir = "${helpBuildDir}"
   args = [ "${helpBuildDir}/${help_dir}", "-nointernet" ]
 
   def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append