JAL-3477 Added appbase override option at buildtime for testing in general, but speci...
[jalview.git] / build.gradle
1 import org.apache.tools.ant.filters.ReplaceTokens
2 import org.gradle.internal.os.OperatingSystem
3 import org.gradle.plugins.ide.eclipse.model.Output
4 import org.gradle.plugins.ide.eclipse.model.Library
5 import java.security.MessageDigest
6 import groovy.transform.ExternalizeMethods
7 import groovy.util.XmlParser
8 import groovy.xml.XmlUtil
9
10 buildscript {
11   dependencies {
12     classpath 'org.openclover:clover:4.3.1'
13   }
14 }
15
16 plugins {
17   id 'java'
18   id 'application'
19   id 'eclipse'
20   id 'com.github.johnrengelman.shadow' version '4.0.3'
21   id 'com.install4j.gradle' version '8.0.2'
22   id 'com.dorongold.task-tree' version '1.4' // only needed to display task dependency tree with  gradle task1 [task2 ...] taskTree
23 }
24
25 repositories {
26   jcenter()
27   mavenCentral()
28   mavenLocal()
29   flatDir {
30     dirs gradlePluginsDir
31   }
32 }
33
34 dependencies {
35   compile 'org.apache.commons:commons-compress:1.18'
36 }
37
38
39 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
40 def string(Object o) {
41   return o.toString()
42 }
43
44
45 ext {
46   jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
47   jalviewDirRelativePath = jalviewDir
48
49   // local build environment properties
50   def localProps = "${jalviewDirAbsolutePath}/local.properties"
51   if (file(localProps).exists()) {
52     try {
53       def p = new Properties()
54       def localPropsFIS = new FileInputStream(localProps)
55       p.load(localPropsFIS)
56       localPropsFIS.close()
57       p.each {
58         key, val -> 
59           def over = getProperty(key) != null
60           setProperty(key, val)
61           if (over) {
62             println("Overriding property '${key}' with local.properties value '${val}'")
63           }
64       }
65     } catch (Exception e) {
66       System.out.println("Exception reading local.properties")
67     }
68   }
69
70   // this property set when running Eclipse headlessly
71   j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
72   // this property set by Eclipse
73   eclipseApplicationProperty = string("eclipse.application")
74   // CHECK IF RUNNING FROM WITHIN ECLIPSE
75   def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
76   IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
77   // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
78   if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
79     println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
80     IN_ECLIPSE = false
81   }
82   if (IN_ECLIPSE) {
83     println("WITHIN ECLIPSE IDE")
84   } else {
85     println("HEADLESS BUILD")
86   }
87   /* *-/
88   System.properties.sort { it.key }.each {
89     key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
90   }
91   /-* *-/
92   if (false && IN_ECLIPSE) {
93     jalviewDir = jalviewDirAbsolutePath
94   }
95   */
96
97   // essentials
98   bareSourceDir = string(source_dir)
99   sourceDir = string("${jalviewDir}/${bareSourceDir}")
100   resourceDir = string("${jalviewDir}/${resource_dir}")
101   bareTestSourceDir = string(test_source_dir)
102   testSourceDir = string("${jalviewDir}/${bareTestSourceDir}")
103
104   // clover
105   cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
106   classesDir = string("${jalviewDir}/${classes_dir}")
107   if (clover.equals("true")) {
108     use_clover = true
109     classesDir = string("${buildDir}/${cloverClassesDir}")
110   } else {
111     use_clover = false
112     classesDir = string("${jalviewDir}/${classes_dir}")
113   }
114
115   classes = classesDir
116
117   getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
118   getdownDir = string("")
119   reportRsyncCmd = false
120   buildDist = true
121   buildProperties = build_properties_file
122   getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
123   switch (CHANNEL) {
124
125     case "BUILD":
126     // TODO: get bamboo build artifact URL for getdown artifacts
127     getdown_channel_base = bamboo_channelbase
128     getdown_channel_name = string("${bamboo_planKey}/${JAVA_VERSION}")
129     getdown_app_base = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
130     getdown_app_dir = getdown_app_dir_alt
131     buildProperties = string("${classesDir}/${build_properties_file}")
132     break
133
134     case "RELEASE":
135     getdown_channel_name = CHANNEL.toLowerCase()
136     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
137     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
138     getdown_app_dir = getdown_app_dir_release
139     buildProperties = string("${classesDir}/${build_properties_file}")
140     reportRsyncCommand = true
141     break
142
143     case "ARCHIVE":
144     getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
145     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
146     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
147     getdown_app_dir = getdown_app_dir_alt
148     if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
149       print "Must provide an ARCHIVEDIR value to produce an archive distribution"
150       exit
151     } else {
152       packageDir = string("${ARCHIVEDIR}/${packageDir}")
153       buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
154       buildDist = false
155     }
156     reportRsyncCommand = true
157     break
158
159     case "ARCHIVELOCAL":
160     getdown_channel_name = string("archive/${JALVIEW_VERSION}")
161     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
162     getdown_app_base = file(getdownWebsiteDir).toURI().toString()
163     getdown_app_dir = getdown_app_dir_alt
164     if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
165       print "Must provide an ARCHIVEDIR value to produce an archive distribution"
166       exit
167     } else {
168       packageDir = string("${ARCHIVEDIR}/${packageDir}")
169       buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
170       buildDist = false
171     }
172     reportRsyncCommand = true
173     getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
174     break
175
176     case "DEVELOP":
177     getdown_channel_name = CHANNEL.toLowerCase()
178     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
179     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
180     getdown_app_dir = getdown_app_dir_alt
181     buildProperties = string("${classesDir}/${build_properties_file}")
182     reportRsyncCommand = true
183     break
184
185     case "TEST-RELEASE":
186     getdown_channel_name = CHANNEL.toLowerCase()
187     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
188     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
189     getdown_app_dir = getdown_app_dir_alt
190     buildProperties = string("${classesDir}/${build_properties_file}")
191     reportRsyncCommand = true
192     break
193
194     case ~/^SCRATCH(|-[-\w]*)$/:
195     getdown_channel_name = CHANNEL
196     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
197     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
198     getdown_app_dir = getdown_app_dir_alt
199     buildProperties = string("${classesDir}/${build_properties_file}")
200     reportRsyncCommand = true
201     break
202
203     case "LOCAL":
204     getdown_app_base = file(getdownWebsiteDir).toURI().toString()
205     getdown_app_dir = getdown_app_dir_alt
206     buildProperties = string("${classesDir}/${build_properties_file}")
207     getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
208     break
209
210     default: // something wrong specified
211     println("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
212     exit
213     break
214
215   }
216   // override getdown_app_base if requested
217   if (getProperty("getdown_appbase_override") != null) {
218     getdown_app_base = string(getProperty("getdown_appbase_override"))
219     println("Overriding getdown appbase with '${getdown_app_base}'")
220   }
221
222   getdownAppDir = string("${getdownWebsiteDir}/${getdown_app_dir}")
223   //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
224   getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
225   getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
226   getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
227   getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
228   /* compile without modules -- using classpath libraries
229   modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
230   modules_runtimeClasspath = modules_compileClasspath
231   */
232   gitHash = string("")
233   gitBranch = string("")
234
235   println("Using a ${CHANNEL} profile.")
236
237   additional_compiler_args = []
238   // configure classpath/args for j8/j11 compilation
239   if (JAVA_VERSION.equals("1.8")) {
240     JAVA_INTEGER_VERSION = string("8")
241     //libDir = j8libDir
242     libDir = j11libDir
243     libDistDir = j8libDir
244     compile_source_compatibility = 1.8
245     compile_target_compatibility = 1.8
246     // these are getdown.txt properties defined dependent on the JAVA_VERSION
247     getdown_alt_java_min_version = getdown_alt_java8_min_version
248     getdown_alt_java_max_version = getdown_alt_java8_max_version
249     // this property is assigned below and expanded to multiple lines in the getdown task
250     getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
251     // this property is for the Java library used in eclipse
252     eclipse_java_runtime_name = string("JavaSE-1.8")
253   } else if (JAVA_VERSION.equals("11")) {
254     JAVA_INTEGER_VERSION = string("11")
255     libDir = j11libDir
256     libDistDir = j11libDir
257     compile_source_compatibility = 11
258     compile_target_compatibility = 11
259     getdown_alt_java_min_version = getdown_alt_java11_min_version
260     getdown_alt_java_max_version = getdown_alt_java11_max_version
261     getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
262     eclipse_java_runtime_name = string("JavaSE-11")
263     /* compile without modules -- using classpath libraries
264     additional_compiler_args += [
265     '--module-path', modules_compileClasspath.asPath,
266     '--add-modules', j11modules
267     ]
268      */
269   } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
270     JAVA_INTEGER_VERSION = JAVA_VERSION
271     libDir = j11libDir
272     libDistDir = j11libDir
273     compile_source_compatibility = JAVA_VERSION
274     compile_target_compatibility = JAVA_VERSION
275     getdown_alt_java_min_version = getdown_alt_java11_min_version
276     getdown_alt_java_max_version = getdown_alt_java11_max_version
277     getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
278     eclipse_java_runtime_name = string("JavaSE-11")
279     /* compile without modules -- using classpath libraries
280     additional_compiler_args += [
281     '--module-path', modules_compileClasspath.asPath,
282     '--add-modules', j11modules
283     ]
284      */
285   } else {
286     throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
287   }
288
289
290   // for install4j
291   JAVA_MIN_VERSION = JAVA_VERSION
292   JAVA_MAX_VERSION = JAVA_VERSION
293   macosJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre")
294   macosJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz")
295   windowsJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre")
296   windowsJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz")
297   install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
298   install4jConfFileName = string("jalview-install4j-conf.install4j")
299   install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
300   install4jHomeDir = install4j_home_dir
301   if (install4jHomeDir.startsWith("~/")) {
302     install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
303   }
304
305
306
307   buildingHTML = string("${jalviewDir}/${docDir}/building.html")
308   helpFile = string("${classesDir}/${help_dir}/help.jhm")
309   helpParentDir = string("${jalviewDir}/${help_parent_dir}")
310   helpSourceDir = string("${helpParentDir}/${help_dir}")
311
312
313   relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
314   jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
315   jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
316   if (IN_ECLIPSE) {
317     jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
318   } else {
319     jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
320   }
321   jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
322   jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
323   jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
324   jalviewjsJalviewCoreHtmlFile = string("")
325   jalviewjsJalviewCoreName = string(jalviewjs_core_name)
326   jalviewjsCoreClasslists = []
327   jalviewjsJalviewTemplateName = string(jalviewjs_name)
328   jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
329   jalviewjsJ2sProps = null
330
331   eclipseWorkspace = null
332   eclipseBinary = string("")
333   eclipseVersion = string("")
334   eclipseDebug = false
335   // ENDEXT
336 }
337
338
339 sourceSets {
340   main {
341     java {
342       srcDirs sourceDir
343       outputDir = file(classesDir)
344     }
345
346     resources {
347       srcDirs resourceDir
348       srcDirs += helpParentDir
349     }
350
351     jar.destinationDir = file("${jalviewDir}/${packageDir}")
352
353     compileClasspath = files(sourceSets.main.java.outputDir)
354     //compileClasspath += files(sourceSets.main.resources.srcDirs)
355     compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
356
357     runtimeClasspath = compileClasspath
358   }
359
360   clover {
361     java {
362       srcDirs = [ cloverInstrDir ]
363       outputDir = file("${buildDir}/${cloverClassesDir}")
364     }
365
366     resources {
367       srcDirs = sourceSets.main.resources.srcDirs
368     }
369     compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
370     compileClasspath += files(sourceSets.main.java.outputDir)
371     compileClasspath += sourceSets.main.compileClasspath
372     compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
373     compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
374
375     runtimeClasspath = compileClasspath
376   }
377
378   test {
379     java {
380       srcDirs testSourceDir
381       outputDir = file("${jalviewDir}/${testOutputDir}")
382     }
383
384     resources {
385       srcDirs = sourceSets.main.resources.srcDirs
386     }
387
388     compileClasspath = files( sourceSets.test.java.outputDir )
389
390     if (use_clover) {
391       compileClasspath += sourceSets.clover.compileClasspath
392     } else {
393       compileClasspath += files(sourceSets.main.java.outputDir)
394     }
395
396     compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
397     compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
398     compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
399
400     runtimeClasspath = compileClasspath
401   }
402 }
403
404
405 // clover bits
406 dependencies {
407   if (use_clover) {
408     cloverCompile 'org.openclover:clover:4.3.1'
409     testCompile 'org.openclover:clover:4.3.1'
410   }
411 }
412
413
414 configurations {
415   cloverRuntime
416   cloverRuntime.extendsFrom cloverCompile
417 }
418
419 eclipse {
420   project {
421     name = eclipse_project_name
422
423     natures 'org.eclipse.jdt.core.javanature',
424     'org.eclipse.jdt.groovy.core.groovyNature',
425     'org.eclipse.buildship.core.gradleprojectnature'
426
427     buildCommand 'org.eclipse.jdt.core.javabuilder'
428     buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
429   }
430
431   classpath {
432     //defaultOutputDir = sourceSets.main.java.outputDir
433     def removeThese = []
434     configurations.each{
435       if (it.isCanBeResolved()) {
436         removeThese += it
437       }
438     }
439
440     minusConfigurations += removeThese
441     plusConfigurations = [ ]
442     file {
443
444       whenMerged { cp ->
445         def removeTheseToo = []
446         HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
447         cp.entries.each { entry ->
448           // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
449           // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
450           // we add the resources and help/help dirs in as libs afterwards (see below)
451           if (entry.kind == 'src') {
452             if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
453               removeTheseToo += entry
454             } else {
455               alreadyAddedSrcPath.putAt(entry.path, true)
456             }
457           }
458
459         }
460         cp.entries.removeAll(removeTheseToo)
461
462         //cp.entries += new Output("${eclipse_bin_dir}/main")
463         if (file(helpParentDir).isDirectory()) {
464           cp.entries += new Library(fileReference(helpParentDir))
465         }
466         if (file(resourceDir).isDirectory()) {
467           cp.entries += new Library(fileReference(resourceDir))
468         }
469
470         HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
471
472         sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
473           //don't want to add outputDir as eclipse is using its own output dir in bin/main
474           if (it.isDirectory() || ! it.exists()) {
475             // don't add dirs to classpath, especially if they don't exist
476             return false // groovy "continue" in .any closure
477           }
478           def itPath = it.toString()
479           if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
480             // make relative path
481             itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
482           }
483           if (alreadyAddedLibPath.get(itPath)) {
484             //println("Not adding duplicate entry "+itPath)
485           } else {
486             //println("Adding entry "+itPath)
487             cp.entries += new Library(fileReference(itPath))
488             alreadyAddedLibPath.put(itPath, true)
489           }
490         }
491
492         sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
493           //no longer want to add outputDir as eclipse is using its own output dir in bin/main
494           if (it.isDirectory() || ! it.exists()) {
495             // don't add dirs to classpath
496             return false // groovy "continue" in .any closure
497           }
498
499           def itPath = it.toString()
500           if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
501             itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
502           }
503           if (alreadyAddedLibPath.get(itPath)) {
504             // don't duplicate
505           } else {
506             def lib = new Library(fileReference(itPath))
507             lib.entryAttributes["test"] = "true"
508             cp.entries += lib
509             alreadyAddedLibPath.put(itPath, true)
510           }
511         }
512
513       } // whenMerged
514
515     } // file
516
517     containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
518
519   } // classpath
520
521   jdt {
522     // for the IDE, use java 11 compatibility
523     sourceCompatibility = compile_source_compatibility
524     targetCompatibility = compile_target_compatibility
525     javaRuntimeName = eclipse_java_runtime_name
526
527     // add in jalview project specific properties/preferences into eclipse core preferences
528     file {
529       withProperties { props ->
530         def jalview_prefs = new Properties()
531         def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
532         jalview_prefs.load(ins)
533         ins.close()
534         jalview_prefs.forEach { t, v ->
535           if (props.getAt(t) == null) {
536             props.putAt(t, v)
537           }
538         }
539       }
540     }
541
542   } // jdt
543
544   if (IN_ECLIPSE) {
545     // Don't want these to be activated if in headless build
546     synchronizationTasks "eclipseSynchronizationTask"
547     autoBuildTasks "eclipseAutoBuildTask"
548
549   }
550 }
551
552
553 task cloverInstr() {
554   // only instrument source, we build test classes as normal
555   inputs.files files (sourceSets.main.allJava) // , fileTree(dir: testSourceDir, include: ["**/*.java"]))
556   outputs.dir cloverInstrDir
557
558   doFirst {
559     delete cloverInstrDir
560     def argsList = ["--initstring", "${buildDir}/clover/clover.db",
561     "-d", "${buildDir}/${cloverSourcesInstrDir}"]
562     argsList.addAll(inputs.files.files.collect({ file ->
563       file.absolutePath
564     }))
565     String[] args = argsList.toArray()
566     println("About to instrument "+args.length +" files")
567     com.atlassian.clover.CloverInstr.mainImpl(args)
568   }
569 }
570
571
572 task cloverReport {
573   group = "Verification"
574     description = "Createst the Clover report"
575     inputs.dir "${buildDir}/clover"
576     outputs.dir "${reportsDir}/clover"
577     onlyIf {
578       file("${buildDir}/clover/clover.db").exists()
579     }
580   doFirst {
581     def argsList = ["--initstring", "${buildDir}/clover/clover.db",
582     "-o", "${reportsDir}/clover"]
583     String[] args = argsList.toArray()
584     com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
585
586     // and generate ${reportsDir}/clover/clover.xml
587     args = ["--initstring", "${buildDir}/clover/clover.db",
588     "-o", "${reportsDir}/clover/clover.xml"].toArray()
589     com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
590   }
591 }
592 // end clover bits
593
594
595 compileJava {
596
597   doFirst {
598     sourceCompatibility = compile_source_compatibility
599     targetCompatibility = compile_target_compatibility
600     options.compilerArgs = additional_compiler_args
601     print ("Setting target compatibility to "+targetCompatibility+"\n")
602   }
603
604 }
605
606
607 compileTestJava {
608   if (use_clover) {
609     dependsOn compileCloverJava
610     classpath += configurations.cloverRuntime
611   } else {
612     classpath += sourceSets.main.runtimeClasspath
613   }
614   doFirst {
615     sourceCompatibility = compile_source_compatibility
616     targetCompatibility = compile_target_compatibility
617     options.compilerArgs = additional_compiler_args
618     print ("Setting target compatibility to "+targetCompatibility+"\n")
619   }
620 }
621
622
623 compileCloverJava {
624
625   doFirst {
626     sourceCompatibility = compile_source_compatibility
627     targetCompatibility = compile_target_compatibility
628     options.compilerArgs += additional_compiler_args
629     print ("Setting target compatibility to "+targetCompatibility+"\n")
630   }
631   classpath += configurations.cloverRuntime
632 }
633
634
635 clean {
636   doFirst {
637     delete sourceSets.main.java.outputDir
638   }
639 }
640
641
642 cleanTest {
643   doFirst {
644     delete sourceSets.test.java.outputDir
645     delete cloverInstrDir
646   }
647 }
648
649
650 // format is a string like date.format("dd MMMM yyyy")
651 def getDate(format) {
652   def date = new Date()
653   return date.format(format)
654 }
655
656
657 task setGitVals {
658   def hashStdOut = new ByteArrayOutputStream()
659   exec {
660     commandLine "git", "rev-parse", "--short", "HEAD"
661     standardOutput = hashStdOut
662     ignoreExitValue true
663   }
664
665   def branchStdOut = new ByteArrayOutputStream()
666   exec {
667     commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
668     standardOutput = branchStdOut
669     ignoreExitValue true
670   }
671
672   gitHash = hashStdOut.toString().trim()
673   gitBranch = branchStdOut.toString().trim()
674
675   outputs.upToDateWhen { false }
676 }
677
678
679 task createBuildProperties(type: WriteProperties) {
680   dependsOn setGitVals
681   inputs.dir(sourceDir)
682   inputs.dir(resourceDir)
683   file(buildProperties).getParentFile().mkdirs()
684   outputFile (buildProperties)
685   // taking time specific comment out to allow better incremental builds
686   comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
687   //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
688   property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
689   property "VERSION", JALVIEW_VERSION
690   property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
691   outputs.file(outputFile)
692 }
693
694
695 task cleanBuildingHTML(type: Delete) {
696   doFirst {
697     delete buildingHTML
698   }
699 }
700
701
702 task convertBuildingMD(type: Exec) {
703   dependsOn cleanBuildingHTML
704   def buildingMD = "${jalviewDir}/${docDir}/building.md"
705   def css = "${jalviewDir}/${docDir}/github.css"
706
707   def pandoc = null
708   pandoc_exec.split(",").each {
709     if (file(it.trim()).exists()) {
710       pandoc = it.trim()
711       return true
712     }
713   }
714
715   def hostname = "hostname".execute().text.trim()
716   if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
717     pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
718   }
719
720   doFirst {
721     if (pandoc != null && file(pandoc).exists()) {
722         commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
723     } else {
724         println("Cannot find pandoc. Skipping convert building.md to HTML")
725         throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
726     }
727   }
728
729   ignoreExitValue true
730
731   inputs.file(buildingMD)
732   inputs.file(css)
733   outputs.file(buildingHTML)
734 }
735
736
737 clean {
738   doFirst {
739     delete buildingHTML
740   }
741 }
742
743
744 task syncDocs(type: Sync) {
745   dependsOn convertBuildingMD
746   def syncDir = "${classesDir}/${docDir}"
747   from fileTree("${jalviewDir}/${docDir}")
748   into syncDir
749
750 }
751
752
753 task copyHelp(type: Copy) {
754   def inputDir = helpSourceDir
755   def outputDir = "${classesDir}/${help_dir}"
756   from(inputDir) {
757     exclude '**/*.gif'
758     exclude '**/*.jpg'
759     exclude '**/*.png'
760     filter(ReplaceTokens,
761       beginToken: '$$',
762       endToken: '$$',
763       tokens: [
764         'Version-Rel': JALVIEW_VERSION,
765         'Year-Rel': getDate("yyyy")
766       ]
767     )
768   }
769   from(inputDir) {
770     include '**/*.gif'
771     include '**/*.jpg'
772     include '**/*.png'
773   }
774   into outputDir
775
776   inputs.dir(inputDir)
777   outputs.files(helpFile)
778   outputs.dir(outputDir)
779 }
780
781
782 task syncLib(type: Sync) {
783   def syncDir = "${classesDir}/${libDistDir}"
784   from fileTree("${jalviewDir}/${libDistDir}")
785   into syncDir
786 }
787
788
789 task syncResources(type: Sync) {
790   from resourceDir
791   include "**/*.*"
792   into "${classesDir}"
793   preserve {
794     include "**"
795   }
796 }
797
798
799 task prepare {
800   dependsOn syncResources
801   dependsOn syncDocs
802   dependsOn copyHelp
803 }
804
805
806 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
807 test {
808   dependsOn prepare
809   dependsOn compileJava
810   if (use_clover) {
811     dependsOn cloverInstr
812   }
813
814   if (use_clover) {
815     print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
816   }
817
818   useTestNG() {
819     includeGroups testngGroups
820     preserveOrder true
821     useDefaultListeners=true
822   }
823
824   workingDir = jalviewDir
825   //systemProperties 'clover.jar' System.properties.clover.jar
826   sourceCompatibility = compile_source_compatibility
827   targetCompatibility = compile_target_compatibility
828   jvmArgs += additional_compiler_args
829
830 }
831
832
833 task buildIndices(type: JavaExec) {
834   dependsOn copyHelp
835   classpath = sourceSets.main.compileClasspath
836   main = "com.sun.java.help.search.Indexer"
837   workingDir = "${classesDir}/${help_dir}"
838   def argDir = "html"
839   args = [ argDir ]
840   inputs.dir("${workingDir}/${argDir}")
841
842   outputs.dir("${classesDir}/doc")
843   outputs.dir("${classesDir}/help")
844   outputs.file("${workingDir}/JavaHelpSearch/DOCS")
845   outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
846   outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
847   outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
848   outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
849   outputs.file("${workingDir}/JavaHelpSearch/TMAP")
850 }
851
852
853 task compileLinkCheck(type: JavaCompile) {
854   options.fork = true
855   classpath = files("${jalviewDir}/${utilsDir}")
856   destinationDir = file("${jalviewDir}/${utilsDir}")
857   source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
858
859   inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
860   inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
861   outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
862   outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
863 }
864
865
866 task linkCheck(type: JavaExec) {
867   dependsOn prepare, compileLinkCheck
868
869   def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
870   classpath = files("${jalviewDir}/${utilsDir}")
871   main = "HelpLinksChecker"
872   workingDir = jalviewDir
873   args = [ "${classesDir}/${help_dir}", "-nointernet" ]
874
875   def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
876   def errFOS = outFOS
877   standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
878     outFOS,
879     standardOutput)
880   errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
881     outFOS,
882     errorOutput)
883
884   inputs.dir("${classesDir}/${help_dir}")
885   outputs.file(helpLinksCheckerOutFile)
886 }
887
888 // import the pubhtmlhelp target
889 ant.properties.basedir = "${jalviewDir}"
890 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
891 ant.importBuild "${utilsDir}/publishHelp.xml"
892
893
894 task cleanPackageDir(type: Delete) {
895   doFirst {
896     delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
897   }
898 }
899
900 jar {
901   dependsOn linkCheck
902   dependsOn buildIndices
903   dependsOn createBuildProperties
904
905   manifest {
906     attributes "Main-Class": mainClass,
907     "Permissions": "all-permissions",
908     "Application-Name": "Jalview Desktop",
909     "Codebase": application_codebase
910   }
911
912   destinationDir = file("${jalviewDir}/${packageDir}")
913   archiveName = rootProject.name+".jar"
914
915   exclude "cache*/**"
916   exclude "*.jar"
917   exclude "*.jar.*"
918   exclude "**/*.jar"
919   exclude "**/*.jar.*"
920
921   inputs.dir(classesDir)
922   outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
923 }
924
925
926 task copyJars(type: Copy) {
927   from fileTree(dir: classesDir, include: "**/*.jar").files
928   into "${jalviewDir}/${packageDir}"
929 }
930
931
932 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
933 task syncJars(type: Sync) {
934   from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
935   into "${jalviewDir}/${packageDir}"
936   preserve {
937     include jar.archiveName
938   }
939 }
940
941
942 task makeDist {
943   group = "build"
944   description = "Put all required libraries in dist"
945   // order of "cleanPackageDir", "copyJars", "jar" important!
946   jar.mustRunAfter cleanPackageDir
947   syncJars.mustRunAfter cleanPackageDir
948   dependsOn cleanPackageDir
949   dependsOn syncJars
950   dependsOn jar
951   outputs.dir("${jalviewDir}/${packageDir}")
952 }
953
954
955 task cleanDist {
956   dependsOn cleanPackageDir
957   dependsOn cleanTest
958   dependsOn clean
959 }
960
961 shadowJar {
962   group = "distribution"
963   if (buildDist) {
964     dependsOn makeDist
965   }
966   from ("${jalviewDir}/${libDistDir}") {
967     include("*.jar")
968   }
969   manifest {
970     attributes 'Implementation-Version': JALVIEW_VERSION
971   }
972   mainClassName = shadowJarMainClass
973   mergeServiceFiles()
974   classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
975   minimize()
976 }
977
978
979 task getdownWebsite() {
980   group = "distribution"
981   description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
982   if (buildDist) {
983     dependsOn makeDist
984   }
985
986   def getdownWebsiteResourceFilenames = []
987   def getdownTextString = ""
988   def getdownResourceDir = getdownResourceDir
989   def getdownAppDir = getdownAppDir
990   def getdownResourceFilenames = []
991
992   doFirst {
993     // clean the getdown website and files dir before creating getdown folders
994     delete getdownWebsiteDir
995     delete getdownFilesDir
996
997     copy {
998       from buildProperties
999       rename(build_properties_file, getdown_build_properties)
1000       into getdownAppDir
1001     }
1002     getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
1003
1004     // go through properties looking for getdown_txt_...
1005     def props = project.properties.sort { it.key }
1006     if (getdown_alt_java_min_version.length() > 0) {
1007       props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
1008     }
1009     if (getdown_alt_java_max_version.length() > 0) {
1010       props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
1011     }
1012     props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
1013
1014     props.put("getdown_txt_appbase", getdown_app_base)
1015     props.each{ prop, val ->
1016       if (prop.startsWith("getdown_txt_") && val != null) {
1017         if (prop.startsWith("getdown_txt_multi_")) {
1018           def key = prop.substring(18)
1019           val.split(",").each{ v ->
1020             def line = "${key} = ${v}\n"
1021             getdownTextString += line
1022           }
1023         } else {
1024           // file values rationalised
1025           if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1026             def r = null
1027             if (val.indexOf('/') == 0) {
1028               // absolute path
1029               r = file(val)
1030             } else if (val.indexOf('/') > 0) {
1031               // relative path (relative to jalviewDir)
1032               r = file( "${jalviewDir}/${val}" )
1033             }
1034             if (r.exists()) {
1035               val = "${getdown_resource_dir}/" + r.getName()
1036               getdownWebsiteResourceFilenames += val
1037               getdownResourceFilenames += r.getPath()
1038             }
1039           }
1040           if (! prop.startsWith("getdown_txt_resource")) {
1041             def line = prop.substring(12) + " = ${val}\n"
1042             getdownTextString += line
1043           }
1044         }
1045       }
1046     }
1047
1048     getdownWebsiteResourceFilenames.each{ filename ->
1049       getdownTextString += "resource = ${filename}\n"
1050     }
1051     getdownResourceFilenames.each{ filename ->
1052       copy {
1053         from filename
1054         into getdownResourceDir
1055       }
1056     }
1057
1058     def codeFiles = []
1059     fileTree(file(packageDir)).each{ f ->
1060       if (f.isDirectory()) {
1061         def files = fileTree(dir: f, include: ["*"]).getFiles()
1062         codeFiles += files
1063       } else if (f.exists()) {
1064         codeFiles += f
1065       }
1066     }
1067     codeFiles.sort().each{f ->
1068       def name = f.getName()
1069       def line = "code = ${getdown_app_dir}/${name}\n"
1070       getdownTextString += line
1071       copy {
1072         from f.getPath()
1073         into getdownAppDir
1074       }
1075     }
1076
1077     // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1078     /*
1079     if (JAVA_VERSION.equals("11")) {
1080     def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1081     j11libFiles.sort().each{f ->
1082     def name = f.getName()
1083     def line = "code = ${getdown_j11lib_dir}/${name}\n"
1084     getdownTextString += line
1085     copy {
1086     from f.getPath()
1087     into getdownJ11libDir
1088     }
1089     }
1090     }
1091      */
1092
1093     // getdown-launcher.jar should not be in main application class path so the main application can move it when updated.  Listed as a resource so it gets updated.
1094     //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1095     getdownTextString += "resource = ${getdown_launcher_new}\n"
1096     getdownTextString += "class = ${mainClass}\n"
1097
1098     def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1099     getdown_txt.write(getdownTextString)
1100
1101     def launch_jvl = file("${getdownWebsiteDir}/${getdown_launch_jvl}")
1102     launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
1103
1104     copy {
1105       from getdownLauncher
1106       rename(file(getdownLauncher).getName(), getdown_launcher_new)
1107       into getdownWebsiteDir
1108     }
1109
1110     copy {
1111       from getdownLauncher
1112       if (file(getdownLauncher).getName() != getdown_launcher) {
1113         rename(file(getdownLauncher).getName(), getdown_launcher)
1114       }
1115       into getdownWebsiteDir
1116     }
1117
1118     if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1119       copy {
1120         from getdown_txt
1121         from getdownLauncher
1122         from "${getdownWebsiteDir}/${getdown_build_properties}"
1123         if (file(getdownLauncher).getName() != getdown_launcher) {
1124           rename(file(getdownLauncher).getName(), getdown_launcher)
1125         }
1126         into getdownInstallDir
1127       }
1128
1129       copy {
1130         from getdownInstallDir
1131         into getdownFilesInstallDir
1132       }
1133     }
1134
1135     copy {
1136       from getdown_txt
1137       from launch_jvl
1138       from getdownLauncher
1139       from "${getdownWebsiteDir}/${getdown_build_properties}"
1140       if (file(getdownLauncher).getName() != getdown_launcher) {
1141         rename(file(getdownLauncher).getName(), getdown_launcher)
1142       }
1143       into getdownFilesDir
1144     }
1145
1146     copy {
1147       from getdownResourceDir
1148       into "${getdownFilesDir}/${getdown_resource_dir}"
1149     }
1150   }
1151
1152   if (buildDist) {
1153     inputs.dir("${jalviewDir}/${packageDir}")
1154   }
1155   outputs.dir(getdownWebsiteDir)
1156   outputs.dir(getdownFilesDir)
1157 }
1158
1159
1160 task getdownDigest(type: JavaExec) {
1161   group = "distribution"
1162   description = "Digest the getdown website folder"
1163   dependsOn getdownWebsite
1164   doFirst {
1165     classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1166   }
1167   main = "com.threerings.getdown.tools.Digester"
1168   args getdownWebsiteDir
1169   inputs.dir(getdownWebsiteDir)
1170   outputs.file("${getdownWebsiteDir}/digest2.txt")
1171 }
1172
1173
1174 task getdown() {
1175   group = "distribution"
1176   description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1177   dependsOn getdownDigest
1178   doLast {
1179     if (reportRsyncCommand) {
1180       def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1181       def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1182       println "LIKELY RSYNC COMMAND:"
1183       println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1184       if (RUNRSYNC == "true") {
1185         exec {
1186           commandLine "mkdir", "-p", toDir
1187         }
1188         exec {
1189           commandLine "rsync", "-avh", "--delete", fromDir, toDir
1190         }
1191       }
1192     }
1193   }
1194 }
1195
1196
1197 clean {
1198   doFirst {
1199     delete getdownWebsiteDir
1200     delete getdownFilesDir
1201   }
1202 }
1203
1204
1205 install4j {
1206   if (file(install4jHomeDir).exists()) {
1207     // good to go!
1208   } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
1209     install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1210   } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
1211     install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
1212   }
1213   installDir(file(install4jHomeDir))
1214
1215   mediaTypes = Arrays.asList(install4j_media_types.split(","))
1216 }
1217
1218
1219 task copyInstall4jTemplate {
1220   def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
1221   def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
1222   inputs.file(install4jTemplateFile)
1223   inputs.file(install4jFileAssociationsFile)
1224   outputs.file(install4jConfFile)
1225
1226   doLast {
1227     def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
1228
1229     // turn off code signing if no OSX_KEYPASS
1230     if (OSX_KEYPASS == "") {
1231       install4jConfigXml.'**'.codeSigning.each { codeSigning ->
1232         codeSigning.'@macEnabled' = "false"
1233       }
1234       install4jConfigXml.'**'.windows.each { windows ->
1235         windows.'@runPostProcessor' = "false"
1236       }
1237     }
1238
1239     // put file association actions where placeholder action is
1240     def install4jFileAssociationsText = install4jFileAssociationsFile.text
1241     def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
1242     install4jConfigXml.'**'.action.any { a ->
1243       if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
1244         def parent = a.parent()
1245         parent.remove(a)
1246         fileAssociationActions.each { faa ->
1247             parent.append(faa)
1248         }
1249         // don't need to continue in .any loop once replacements have been made
1250         return true
1251       }
1252     }
1253
1254     // write install4j file
1255     install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
1256   }
1257 }
1258
1259
1260 clean {
1261   doFirst {
1262     delete install4jConfFile
1263   }
1264 }
1265
1266
1267 task installers(type: com.install4j.gradle.Install4jTask) {
1268   group = "distribution"
1269   description = "Create the install4j installers"
1270   dependsOn setGitVals
1271   dependsOn getdown
1272   dependsOn copyInstall4jTemplate
1273
1274   projectFile = install4jConfFile
1275
1276   // create an md5 for the input files to use as version for install4j conf file
1277   def digest = MessageDigest.getInstance("MD5")
1278   digest.update(
1279     (file("${install4jDir}/${install4j_template}").text + 
1280     file("${install4jDir}/${install4j_info_plist_file_associations}").text +
1281     file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
1282   def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
1283   if (filesMd5.length() >= 8) {
1284     filesMd5 = filesMd5.substring(0,8)
1285   }
1286   def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
1287
1288   variables = [
1289     'OSX_KEYSTORE': OSX_KEYSTORE,
1290     'JSIGN_SH': JSIGN_SH,
1291     'JRE_DIR': getdown_app_dir_java,
1292     'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
1293     'JALVIEW_VERSION': JALVIEW_VERSION,
1294     'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
1295     'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
1296     'JAVA_VERSION': JAVA_VERSION,
1297     'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1298     'VERSION': JALVIEW_VERSION,
1299     'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1300     'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1301     'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1302     'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1303     'COPYRIGHT_MESSAGE': install4j_copyright_message,
1304     'MACOS_BUNDLE_ID': install4j_macOS_bundle_id,
1305     'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1306     'GETDOWN_DIST_DIR': getdown_app_dir,
1307     'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1308     'GETDOWN_INSTALL_DIR': getdown_install_dir,
1309     'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
1310   ]
1311
1312   destination = "${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}"
1313   buildSelected = true
1314
1315   if (install4j_faster.equals("true") || CHANNEL.startsWith("DEVELOP") || CHANNEL.startsWith("LOCAL")) {
1316     // this doesn't seem to work
1317     faster = true
1318     disableSigning = true
1319   }
1320
1321   if (OSX_KEYPASS) {
1322     macKeystorePassword = OSX_KEYPASS
1323   }
1324
1325   doFirst {
1326     println("Using projectFile "+projectFile)
1327   }
1328
1329   inputs.dir(getdownWebsiteDir)
1330   inputs.file(install4jConfFile)
1331   inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
1332   inputs.dir(macosJavaVMDir)
1333   inputs.dir(windowsJavaVMDir)
1334   outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
1335 }
1336
1337
1338 task sourceDist(type: Tar) {
1339   
1340   def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1341   def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1342   // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1343   try {
1344     archiveFileName = outputFileName
1345   } catch (Exception e) {
1346     archiveName = outputFileName
1347   }
1348   
1349   compression Compression.GZIP
1350   
1351   into project.name
1352
1353   def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1354   ,".*"
1355   ,"benchmarking/*"
1356   ,"**/.*"
1357   ,"*.class"
1358   ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1359   ,"*locales/**",
1360   ,"utils/InstallAnywhere"] 
1361   def PROCESS_FILES=[   "AUTHORS",
1362   "CITATION",
1363   "FEATURETODO",
1364   "JAVA-11-README",
1365   "FEATURETODO",
1366   "LICENSE",
1367   "**/README",
1368   "RELEASE",
1369   "THIRDPARTYLIBS","TESTNG",
1370   "build.gradle",
1371   "gradle.properties",
1372   "**/*.java",
1373   "**/*.html",
1374   "**/*.xml",
1375   "**/*.gradle",
1376   "**/*.groovy",
1377   "**/*.properties",
1378   "**/*.perl",
1379   "**/*.sh"]
1380
1381   from(jalviewDir) {
1382     exclude (EXCLUDE_FILES)
1383     include (PROCESS_FILES)
1384     filter(ReplaceTokens,
1385       beginToken: '$$',
1386       endToken: '$$',
1387       tokens: [
1388         'Version-Rel': JALVIEW_VERSION,
1389         'Year-Rel': getDate("yyyy")
1390       ]
1391     )
1392   }
1393   from(jalviewDir) {
1394     exclude (EXCLUDE_FILES)
1395     exclude (PROCESS_FILES)
1396     exclude ("appletlib")
1397     exclude ("**/*locales")
1398     exclude ("*locales/**")
1399     exclude ("utils/InstallAnywhere")
1400
1401     exclude (getdown_files_dir)
1402     exclude (getdown_website_dir)
1403
1404     // exluding these as not using jars as modules yet
1405     exclude ("${j11modDir}/**/*.jar")
1406   }
1407   //  from (jalviewDir) {
1408   //    // explicit includes for stuff that seemed to not get included
1409   //    include(fileTree("test/**/*."))
1410   //    exclude(EXCLUDE_FILES)
1411   //    exclude(PROCESS_FILES)
1412   //  }
1413 }
1414
1415
1416 task helppages {
1417   dependsOn copyHelp
1418   dependsOn pubhtmlhelp
1419   
1420   inputs.dir("${classesDir}/${help_dir}")
1421   outputs.dir("${buildDir}/distributions/${help_dir}")
1422 }
1423
1424 // LARGE AMOUNT OF JALVIEWJS STUFF DELETED HERE
1425 task eclipseAutoBuildTask {}
1426 task eclipseSynchronizationTask {}