JAL-3449 More tidying of build.gradle for CHANNEL selection
authorBen Soares <bsoares@dundee.ac.uk>
Thu, 13 Feb 2020 10:50:37 +0000 (10:50 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Thu, 13 Feb 2020 10:50:37 +0000 (10:50 +0000)
build.gradle

index c64eb59..cba67d5 100644 (file)
@@ -117,39 +117,36 @@ ext {
   classes = classesDir
 
   getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
-  getdownDir = string("")
-  reportRsyncCmd = false
   buildDist = true
-  buildProperties = build_properties_file
+
+  // the following values might be overridden by the CHANNEL switch
+  getdown_channel_name = CHANNEL.toLowerCase()
+  getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
+  getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
   getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
+  getdownAppDir = getdown_app_dir_alt
+  buildProperties = string("${classesDir}/${build_properties_file}")
+  reportRsyncCmd = false
   switch (CHANNEL) {
 
     case "BUILD":
     // TODO: get bamboo build artifact URL for getdown artifacts
     getdown_channel_base = bamboo_channelbase
     getdown_channel_name = string("${bamboo_planKey}/${JAVA_VERSION}")
-    getdown_app_base = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
-    getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
     break
 
     case "RELEASE":
-    getdown_channel_name = CHANNEL.toLowerCase()
-    getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
-    getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
-    getdown_app_dir = getdown_app_dir_release
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    getdownAppDir = getdown_app_dir_release
     reportRsyncCommand = true
     break
 
     case "ARCHIVE":
     getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
-    getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
-    getdown_app_dir = getdown_app_dir_alt
+    getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
     if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
-      print "Must provide an ARCHIVEDIR value to produce an archive distribution"
-      exit
+      throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
     } else {
       packageDir = string("${ARCHIVEDIR}/${packageDir}")
       buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
@@ -161,11 +158,9 @@ ext {
     case "ARCHIVELOCAL":
     getdown_channel_name = string("archive/${JALVIEW_VERSION}")
     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
-    getdown_app_base = file(getdownWebsiteDir).toURI().toString()
-    getdown_app_dir = getdown_app_dir_alt
+    getdownAppBase = file(getdownWebsiteDir).toURI().toString()
     if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
-      print "Must provide an ARCHIVEDIR value to produce an archive distribution"
-      exit
+      throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
     } else {
       packageDir = string("${ARCHIVEDIR}/${packageDir}")
       buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
@@ -176,52 +171,37 @@ ext {
     break
 
     case "DEVELOP":
-    getdown_channel_name = CHANNEL.toLowerCase()
-    getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
-    getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
-    getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
     reportRsyncCommand = true
     break
 
     case "TEST-RELEASE":
-    getdown_channel_name = CHANNEL.toLowerCase()
-    getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
-    getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
-    getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
     reportRsyncCommand = true
     break
 
     case ~/^SCRATCH(|-[-\w]*)$/:
     getdown_channel_name = CHANNEL
     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
-    getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
-    getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
     reportRsyncCommand = true
     break
 
     case "LOCAL":
-    getdown_app_base = file(getdownWebsiteDir).toURI().toString()
-    getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    getdownAppBase = file(getdownWebsiteDir).toURI().toString()
     getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
     break
 
     default: // something wrong specified
-    println("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
-    exit
+    throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
     break
 
   }
-  // override getdown_app_base if requested
+  // override getdownAppBase if requested
   if (findProperty("getdown_appbase_override") != null) {
-    getdown_app_base = string(getProperty("getdown_appbase_override"))
-    println("Overriding getdown appbase with '${getdown_app_base}'")
+    getdownAppBase = string(getProperty("getdown_appbase_override"))
+    println("Overriding getdown appbase with '${getdownAppBase}'")
   }
 
-  getdownAppDir = string("${getdownWebsiteDir}/${getdown_app_dir}")
+  getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDir}")
   //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
   getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
   getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
@@ -1008,7 +988,7 @@ task getdownWebsite() {
       rename(build_properties_file, getdown_build_properties)
       into getdownAppDir
     }
-    getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
+    getdownWebsiteResourceFilenames += "${getdownAppDir}/${getdown_build_properties}"
 
     // go through properties looking for getdown_txt_...
     def props = project.properties.sort { it.key }
@@ -1022,7 +1002,7 @@ task getdownWebsite() {
       props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
     }
 
-    props.put("getdown_txt_appbase", getdown_app_base)
+    props.put("getdown_txt_appbase", getdownAppBase)
     props.each{ prop, val ->
       if (prop.startsWith("getdown_txt_") && val != null) {
         if (prop.startsWith("getdown_txt_multi_")) {
@@ -1077,7 +1057,7 @@ task getdownWebsite() {
     }
     codeFiles.sort().each{f ->
       def name = f.getName()
-      def line = "code = ${getdown_app_dir}/${name}\n"
+      def line = "code = ${getdownAppDir}/${name}\n"
       getdownTextString += line
       copy {
         from f.getPath()
@@ -1322,7 +1302,7 @@ task installers(type: com.install4j.gradle.Install4jTask) {
     'GETDOWN_WEBSITE_DIR': getdown_website_dir,
     'GETDOWN_FILES_DIR': getdown_files_dir,
     'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
-    'GETDOWN_DIST_DIR': getdown_app_dir,
+    'GETDOWN_DIST_DIR': getdownAppDir,
     'GETDOWN_ALT_DIR': getdown_app_dir_alt,
     'GETDOWN_INSTALL_DIR': getdown_install_dir,
     'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,