Merge branch 'develop' of http://source.jalview.org/git/jalview into develop
[jalview.git] / build.gradle
index 16c31b3..492d7c1 100644 (file)
@@ -56,6 +56,7 @@ ext {
   reportRsyncCmd = false
   buildDist = true
   buildProperties = buildPropertiesFile
+  getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher
   switch (CHANNEL) {
 
     case "BUILD":
@@ -103,6 +104,7 @@ ext {
       buildDist = false
     }
     reportRsyncCommand = true
+    getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher_local
     break
 
     case "DEVELOP":
@@ -123,7 +125,7 @@ ext {
     reportRsyncCommand = true
     break
 
-    case ~/^SCRATCH(|-\w*)$/:
+    case ~/^SCRATCH(|-[-\w]*)$/:
     getdown_channel_name = CHANNEL
     getdownDir = getdown_channel_name + "/" + JAVA_VERSION
     getdown_app_base = getdown_channel_base + "/" + getdownDir
@@ -136,6 +138,7 @@ ext {
     getdown_app_base = file(getdownWebsiteDir).toURI().toString()
     getdown_app_dir = getdown_app_dir_alt
     buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
+    getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher_local
     break
 
     default: // something wrong specified
@@ -150,11 +153,12 @@ ext {
   //getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
   getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
   getdownInstallDir = getdownWebsiteDir + '/' + getdown_install_dir
-  getdownLauncher = jalviewDir + '/' + getdown_launcher
   getdownFilesDir = jalviewDir + '/' + getdown_files_dir + '/' + JAVA_VERSION + '/'
   getdownFilesInstallDir = getdownFilesDir+"/"+getdown_install_dir
+  /* compile without modules -- using classpath libraries
   modules_compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
   modules_runtimeClasspath = modules_compileClasspath
+  */
   gitHash = ""
   gitBranch = ""
 }
@@ -163,6 +167,7 @@ def JAVA_INTEGER_VERSION
 def additional_compiler_args = []
 // these are getdown.txt properties defined dependent on the JAVA_VERSION
 def getdown_alt_java_min_version
+def getdown_alt_java_max_version
 // this property is assigned below and expanded to multiple lines in the getdown task
 def getdown_alt_multi_java_location
 // this property is for the Java library used in eclipse
@@ -175,6 +180,7 @@ if (JAVA_VERSION.equals("1.8")) {
   compile_source_compatibility = 1.8
   compile_target_compatibility = 1.8
   getdown_alt_java_min_version = getdown_alt_java8_min_version
+  getdown_alt_java_max_version = getdown_alt_java8_max_version
   getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
   eclipse_java_runtime_name = "JavaSE-1.8"
 } else if (JAVA_VERSION.equals("11")) {
@@ -184,12 +190,15 @@ if (JAVA_VERSION.equals("1.8")) {
   compile_source_compatibility = 11
   compile_target_compatibility = 11
   getdown_alt_java_min_version = getdown_alt_java11_min_version
+  getdown_alt_java_max_version = getdown_alt_java11_max_version
   getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
   eclipse_java_runtime_name = "JavaSE-11"
+  /* compile without modules -- using classpath libraries
   additional_compiler_args += [
   '--module-path', ext.modules_compileClasspath.asPath,
   '--add-modules', j11modules
   ]
+  */
 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
   JAVA_INTEGER_VERSION = JAVA_VERSION
   libDir = j11libDir
@@ -197,12 +206,15 @@ if (JAVA_VERSION.equals("1.8")) {
   compile_source_compatibility = JAVA_VERSION
   compile_target_compatibility = JAVA_VERSION
   getdown_alt_java_min_version = getdown_alt_java11_min_version
+  getdown_alt_java_max_version = getdown_alt_java11_max_version
   getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
   eclipse_java_runtime_name = "JavaSE-11"
+  /* compile without modules -- using classpath libraries
   additional_compiler_args += [
   '--module-path', ext.modules_compileClasspath.asPath,
   '--add-modules', j11modules
   ]
+  */
 } else {
   throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
 }
@@ -590,10 +602,13 @@ task convertBuildingMD(type: Exec) {
     pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
   }
 
-  if (pandoc != null && file(pandoc).exists()) {
-    commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
-  } else {
-    commandLine "true"
+  doFirst {
+    if (pandoc != null && file(pandoc).exists()) {
+        commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
+    } else {
+        println("Cannot find pandoc. Skipping convert building.md to HTML")
+        throw new StopExecutionException()
+    }
   }
 
   ignoreExitValue true
@@ -623,7 +638,7 @@ task copyHelp(type: Copy) {
     exclude '**/*.gif'
       exclude '**/*.jpg'
       exclude '**/*.png'
-      filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
+      filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
   }
   from(inputDir) {
     include '**/*.gif'
@@ -717,7 +732,7 @@ task compileLinkCheck(type: JavaCompile) {
   outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
 }
 
-def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
+def helplinkscheckertouchfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.touch")
 task linkCheck(type: JavaExec) {
   dependsOn prepare, compileLinkCheck
   classpath = files("$jalviewDir/$utilsDir")
@@ -726,14 +741,20 @@ task linkCheck(type: JavaExec) {
   def help = "$classes/$helpDir"
   args = [ "$classes/$helpDir", "-nointernet" ]
 
-  doFirst {
-    helplinkscheckeroutputfile.createNewFile()
-    standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
+  doLast {
+    helplinkscheckertouchfile.createNewFile()
   }
 
-  outputs.file(helplinkscheckeroutputfile)
+  inputs.dir("$classes/$helpDir")
+  outputs.file(helplinkscheckertouchfile)
 }
 
+// import the pubhtmlhelp target
+ant.properties.basedir = "$jalviewDir"
+ant.properties.helpBuildDir = jalviewDirAbsolutePath+"/$classes/$helpDir"
+ant.importBuild "$utilsDir/publishHelp.xml"
+
+
 task cleanPackageDir(type: Delete) {
   delete fileTree("$jalviewDir/$packageDir").include("*.jar")
 }
@@ -833,14 +854,19 @@ task getdownWebsite() {
     copy {
       from buildProperties
       rename(buildPropertiesFile, getdown_build_properties)
-      into project.ext.getdownWebsiteDir
+      into project.ext.getdownAppDir
     }
-    getdownWebsiteResourceFilenames += getdown_build_properties
+    getdownWebsiteResourceFilenames += getdown_app_dir+"/"+getdown_build_properties
 
     // go through properties looking for getdown_txt_...
     def props = project.properties.sort { it.key }
-    props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
-    props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
+       if (getdown_alt_java_min_version.length() > 0) {
+               props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
+       }
+       if (getdown_alt_java_max_version.length() > 0) {
+               props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
+       }
+       props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
 
     props.put("getdown_txt_appbase", getdown_app_base)
     props.each{ prop, val ->
@@ -938,6 +964,9 @@ task getdownWebsite() {
 
     copy {
       from getdownLauncher
+      if (file(getdownLauncher).getName() != getdown_launcher) {
+        rename(file(getdownLauncher).getName(), getdown_launcher)
+      }
       into project.ext.getdownWebsiteDir
     }
 
@@ -946,6 +975,9 @@ task getdownWebsite() {
         from getdown_txt
         from getdownLauncher
         from getdownWebsiteDir+"/"+getdown_build_properties
+        if (file(getdownLauncher).getName() != getdown_launcher) {
+          rename(file(getdownLauncher).getName(), getdown_launcher)
+        }
         into getdownInstallDir
       }
 
@@ -960,6 +992,9 @@ task getdownWebsite() {
       from launch_jvl
       from getdownLauncher
       from getdownWebsiteDir+"/"+getdown_build_properties
+      if (file(getdownLauncher).getName() != getdown_launcher) {
+        rename(file(getdownLauncher).getName(), getdown_launcher)
+      }
       into getdownFilesDir
     }
 
@@ -980,7 +1015,9 @@ task getdownDigest(type: JavaExec) {
   group = "distribution"
   description = "Digest the getdown website folder"
   dependsOn getdownWebsite
-  classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
+  doFirst {
+    classpath = files(getdownWebsiteDir + '/' + getdown_launcher)
+  }
   main = "com.threerings.getdown.tools.Digester"
   args project.ext.getdownWebsiteDir
   inputs.dir(project.ext.getdownWebsiteDir)
@@ -996,7 +1033,7 @@ task getdown() {
       def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith("/")?"":"/")
       def toDir = getdown_rsync_dest + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
       println "LIKELY RSYNC COMMAND:"
-      println "rsync -avh --delete '$fromDir' '$toDir'"
+      println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
       if (RUNRSYNC == "true") {
         exec {
           commandLine "mkdir", "-p", toDir
@@ -1130,3 +1167,76 @@ clean {
   delete install4jConf
 }
 
+task sourceDist (type: Tar) {
+  
+  def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
+  def outputFileName = project.name + "_" + VERSION_UNDERSCORES + ".tar.gz"
+  // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
+  try {
+    archiveFileName = outputFileName
+  } catch (Exception e) {
+    archiveName = outputFileName
+  }
+  
+  compression Compression.GZIP
+  
+  from jalviewDir
+  into project.name
+   
+  exclude (".*")
+  exclude ("**/.*")
+  exclude ("*.class")
+  exclude ("**/*.class")
+  include (eclipse_extra_jdt_prefs_file)
+  include ("AUTHORS")
+  include ("CITATION")
+  include ("FEATURETODO")
+  include ("JAVA-11-README")
+  include ("FEATURETODO")
+  include ("LICENSE")
+  include ("README")
+  include ("RELEASE")
+  include ("THIRDPARTYLIBS")
+  include ("build.gradle")
+  include ("gradle.properties")
+  include ("$sourceDir/*.java")
+  include ("$sourceDir/**/*.java")
+  include ("$sourceDir/**/*.cdr")
+  include ("$j8libDir/**/*.jar")
+  include ("$j11libDir/**/*.jar")
+  include ("$resourceDir/**/*")
+  include ("$helpDir/**/*")
+  include ("$schemaDir/**/*")
+  include ("$utilsDir/**/*")
+  include ("$docDir/**/*")
+  include ("$examplesDir/**/*")
+  include ("getdown/**/*")
+  //include ("jalview-jalopy.xml")
+  //include ("JalviewApplet.jpx")
+  //include ("JalviewX.jpx")
+  //include ("nbbuild.xml")
+  //include ("nbproject/genfiles.properties")
+  //include ("nbproject/project.properties")
+  //include ("nbproject/project.xml")
+  
+  exclude ("appletlib")
+  exclude ("**/*locales")
+  exclude ("*locales/**")
+  exclude ("utils/InstallAnywhere")
+  exclude (libDir)
+  exclude (getdown_files_dir)
+  exclude (getdown_website_dir)
+
+  // exluding these as not using jars as modules yet
+  exclude ("$j11modDir/**/*.jar")
+
+}
+
+task helppages  {
+  dependsOn copyHelp
+  dependsOn pubhtmlhelp
+  
+  inputs.dir("$classes/$helpDir")
+  outputs.dir("$helpOutputDir")
+}