JAL-3521 Updated debian build.gradle in utils/debian/debian_build.gradle and patch...
[jalview.git] / utils / debian / build_gradle.patch
1 diff --git a/build.gradle b/build.gradle
2 index ca599a85a..ce7f13634 100644
3 --- a/build.gradle
4 +++ b/build.gradle
5 @@ -2,66 +2,12 @@
6   * For properties set within build.gradle, use camelCaseNoSpace.
7   */
8  import org.apache.tools.ant.filters.ReplaceTokens
9 -import org.gradle.internal.os.OperatingSystem
10 -import org.gradle.plugins.ide.internal.generator.PropertiesPersistableConfigurationObject
11 -import org.gradle.api.internal.PropertiesTransformer
12 -import org.gradle.util.ConfigureUtil
13 -import org.gradle.plugins.ide.eclipse.model.Output
14 -import org.gradle.plugins.ide.eclipse.model.Library
15 -import java.security.MessageDigest
16 -import java.util.regex.Matcher
17 -import groovy.transform.ExternalizeMethods
18 -import groovy.util.XmlParser
19 -import groovy.xml.XmlUtil
20 -import groovy.json.JsonBuilder
21 -import com.vladsch.flexmark.util.ast.Node
22 -import com.vladsch.flexmark.html.HtmlRenderer
23 -import com.vladsch.flexmark.parser.Parser
24 -import com.vladsch.flexmark.util.data.MutableDataSet
25 -import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension
26 -import com.vladsch.flexmark.ext.tables.TablesExtension
27 -import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension
28 -import com.vladsch.flexmark.ext.autolink.AutolinkExtension
29 -import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension
30 -import com.vladsch.flexmark.ext.toc.TocExtension
31 -import com.google.common.hash.HashCode
32 -import com.google.common.hash.Hashing
33 -import com.google.common.io.Files
34 -import org.jsoup.Jsoup
35 -import org.jsoup.nodes.Element
36 -
37 -buildscript {
38 -  repositories {
39 -    mavenCentral()
40 -    mavenLocal()
41 -  }
42 -  dependencies {
43 -    classpath "com.vladsch.flexmark:flexmark-all:0.62.0"
44 -    classpath "org.jsoup:jsoup:1.14.3"
45 -    classpath "com.eowise:gradle-imagemagick:0.5.1"
46 -  }
47 -}
48 -
49  
50  plugins {
51    id 'java'
52    id 'application'
53 -  id 'eclipse'
54 -  id "com.diffplug.gradle.spotless" version "3.28.0"
55 -  id 'com.github.johnrengelman.shadow' version '4.0.3'
56 -  id 'com.install4j.gradle' version '10.0.3'
57 -  id 'com.dorongold.task-tree' version '2.1.1' // only needed to display task dependency tree with  gradle task1 [task2 ...] taskTree
58 -  id 'com.palantir.git-version' version '0.13.0' apply false
59 -}
60 -
61 -repositories {
62 -  jcenter()
63 -  mavenCentral()
64 -  mavenLocal()
65  }
66  
67 -
68 -
69  // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
70  def string(Object o) {
71    return o == null ? "" : o.toString()
72 @@ -102,34 +48,20 @@ def overrideProperties(String propsFileName, boolean output = false) {
73    }
74  }
75  
76 -ext {
77 +project.ext {
78    jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
79    jalviewDirRelativePath = jalviewDir
80 -  date = new Date()
81  
82 -  getdownChannelName = CHANNEL.toLowerCase()
83 -  // default to "default". Currently only has different cosmetics for "develop", "release", "default"
84 -  propertiesChannelName = ["develop", "release", "test-release", "jalviewjs", "jalviewjs-release" ].contains(getdownChannelName) ? getdownChannelName : "default"
85 -  channelDirName = propertiesChannelName
86 -  // Import channel_properties
87 -  if (getdownChannelName.startsWith("develop-")) {
88 -    channelDirName = "develop-SUFFIX"
89 -  }
90 -  channelDir = string("${jalviewDir}/${channel_properties_dir}/${channelDirName}")
91 +  propertiesChannelName = "release"
92 +  channelDir = string("${jalviewDir}/${channel_properties_dir}/${propertiesChannelName}")
93    channelGradleProperties = string("${channelDir}/channel_gradle.properties")
94 -  channelPropsFile = string("${channelDir}/${resource_dir}/${channel_props}")
95    overrideProperties(channelGradleProperties, false)
96 -  // local build environment properties
97 -  // can be "projectDir/local.properties"
98 -  overrideProperties("${projectDir}/local.properties", true)
99 -  // or "../projectDir_local.properties"
100 -  overrideProperties(projectDir.getParent() + "/" + projectDir.getName() + "_local.properties", true)
101 -
102 +  
103    ////  
104    // Import releaseProps from the RELEASE file
105    // or a file specified via JALVIEW_RELEASE_FILE if defined
106    // Expect jalview.version and target release branch in jalview.release        
107 -  releaseProps = new Properties();
108 +  def releaseProps = new Properties();
109    def releasePropFile = findProperty("JALVIEW_RELEASE_FILE");
110    def defaultReleasePropFile = "${jalviewDirAbsolutePath}/RELEASE";
111    try {
112 @@ -144,42 +76,6 @@ ext {
113    if (findProperty("JALVIEW_VERSION")==null || "".equals(JALVIEW_VERSION)) {
114      JALVIEW_VERSION = releaseProps.get("jalview.version")
115    }
116 -  println("JALVIEW_VERSION is set to '${JALVIEW_VERSION}'")
117 -  
118 -  // this property set when running Eclipse headlessly
119 -  j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
120 -  // this property set by Eclipse
121 -  eclipseApplicationProperty = string("eclipse.application")
122 -  // CHECK IF RUNNING FROM WITHIN ECLIPSE
123 -  def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
124 -  IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
125 -  // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
126 -  if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
127 -    println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
128 -    IN_ECLIPSE = false
129 -  }
130 -  if (IN_ECLIPSE) {
131 -    println("WITHIN ECLIPSE IDE")
132 -  } else {
133 -    println("HEADLESS BUILD")
134 -  }
135 -  
136 -  J2S_ENABLED = (project.hasProperty('j2s.compiler.status') && project['j2s.compiler.status'] != null && project['j2s.compiler.status'] == "enable")
137 -  if (J2S_ENABLED) {
138 -    println("J2S ENABLED")
139 -  } 
140 -  /* *-/
141 -  System.properties.sort { it.key }.each {
142 -    key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
143 -  }
144 -  /-* *-/
145 -  if (false && IN_ECLIPSE) {
146 -    jalviewDir = jalviewDirAbsolutePath
147 -  }
148 -  */
149 -
150 -  // datestamp
151 -  buildDate = new Date().format("yyyyMMdd")
152  
153    // essentials
154    bareSourceDir = string(source_dir)
155 @@ -190,273 +86,18 @@ ext {
156  
157    classesDir = string("${jalviewDir}/${classes_dir}")
158  
159 -  // clover
160 -  useClover = clover.equals("true")
161 -  cloverBuildDir = "${buildDir}/clover"
162 -  cloverInstrDir = file("${cloverBuildDir}/clover-instr")
163 -  cloverClassesDir = file("${cloverBuildDir}/clover-classes")
164 -  cloverReportDir = file("${buildDir}/reports/clover")
165 -  cloverTestInstrDir = file("${cloverBuildDir}/clover-test-instr")
166 -  cloverTestClassesDir = file("${cloverBuildDir}/clover-test-classes")
167 -  //cloverTestClassesDir = cloverClassesDir
168 -  cloverDb = string("${cloverBuildDir}/clover.db")
169 +  useClover = false
170  
171 -  testSourceDir = useClover ? cloverTestInstrDir : testDir
172 -  testClassesDir = useClover ? cloverTestClassesDir : "${jalviewDir}/${test_output_dir}"
173 +  resourceClassesDir = classesDir
174  
175 -  channelSuffix = ""
176 -  backgroundImageText = BACKGROUNDIMAGETEXT
177 -  getdownChannelDir = string("${getdown_website_dir}/${propertiesChannelName}")
178 -  getdownAppBaseDir = string("${jalviewDir}/${getdownChannelDir}/${JAVA_VERSION}")
179 -  getdownArchiveDir = string("${jalviewDir}/${getdown_archive_dir}")
180 -  getdownFullArchiveDir = null
181 -  getdownTextLines = []
182 -  getdownLaunchJvl = null
183 -  getdownVersionLaunchJvl = null
184 -  buildDist = true
185 -  buildProperties = null
186 +  testSourceDir = testDir
187 +  testClassesDir = "${jalviewDir}/${test_output_dir}"
188  
189 -  // the following values might be overridden by the CHANNEL switch
190 -  getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
191 -  getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
192 -  getdownArchiveAppBase = getdown_archive_base
193 -  getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
194 -  getdownAppDistDir = getdown_app_dir_alt
195 -  getdownImagesDir = string("${jalviewDir}/${getdown_images_dir}")
196 -  getdownImagesBuildDir = string("${buildDir}/imagemagick/getdown")
197 +  buildProperties = string("${classesDir}/${build_properties_file}")
198    getdownSetAppBaseProperty = false // whether to pass the appbase and appdistdir to the application
199 -  reportRsyncCommand = false
200 -  jvlChannelName = CHANNEL.toLowerCase()
201 -  install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build
202 -  install4jDMGDSStore = "${install4j_images_dir}/${install4j_dmg_ds_store}"
203 -  install4jDMGBackgroundImageDir = "${install4j_images_dir}"
204 -  install4jDMGBackgroundImageBuildDir = "build/imagemagick/install4j"
205 -  install4jDMGBackgroundImageFile = "${install4j_dmg_background}"
206 -  install4jInstallerName = "${jalview_name} Non-Release Installer"
207 -  install4jExecutableName = install4j_executable_name
208 -  install4jExtraScheme = "jalviewx"
209 -  install4jMacIconsFile = string("${install4j_images_dir}/${install4j_mac_icons_file}")
210 -  install4jWindowsIconsFile = string("${install4j_images_dir}/${install4j_windows_icons_file}")
211 -  install4jPngIconFile = string("${install4j_images_dir}/${install4j_png_icon_file}")
212 -  install4jBackground = string("${install4j_images_dir}/${install4j_background}")
213 -  install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}"
214 -  install4jCheckSums = true
215 -
216 -  applicationName = "${jalview_name}"
217 -  switch (CHANNEL) {
218 -
219 -    case "BUILD":
220 -    // TODO: get bamboo build artifact URL for getdown artifacts
221 -    getdown_channel_base = bamboo_channelbase
222 -    getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
223 -    getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
224 -    jvlChannelName += "_${getdownChannelName}"
225 -    // automatically add the test group Not-bamboo for exclusion 
226 -    if ("".equals(testng_excluded_groups)) { 
227 -      testng_excluded_groups = "Not-bamboo"
228 -    }
229 -    install4jExtraScheme = "jalviewb"
230 -    backgroundImageText = true
231 -    break
232 -
233 -    case [ "RELEASE", "JALVIEWJS-RELEASE" ]:
234 -    getdownAppDistDir = getdown_app_dir_release
235 -    getdownSetAppBaseProperty = true
236 -    reportRsyncCommand = true
237 -    install4jSuffix = ""
238 -    install4jInstallerName = "${jalview_name} Installer"
239 -    break
240 -
241 -    case "ARCHIVE":
242 -    getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
243 -    getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
244 -    getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
245 -    if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
246 -      throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
247 -    } else {
248 -      package_dir = string("${ARCHIVEDIR}/${package_dir}")
249 -      buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
250 -      buildDist = false
251 -    }
252 -    reportRsyncCommand = true
253 -    install4jExtraScheme = "jalviewa"
254 -    break
255 -
256 -    case "ARCHIVELOCAL":
257 -    getdownChannelName = string("archive/${JALVIEW_VERSION}")
258 -    getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
259 -    getdownAppBase = file(getdownAppBaseDir).toURI().toString()
260 -    if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
261 -      throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution [did not find '${ARCHIVEDIR}/${package_dir}']")
262 -    } else {
263 -      package_dir = string("${ARCHIVEDIR}/${package_dir}")
264 -      buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
265 -      buildDist = false
266 -    }
267 -    reportRsyncCommand = true
268 -    getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
269 -    install4jSuffix = "Archive"
270 -    install4jExtraScheme = "jalviewa"
271 -    break
272 -
273 -    case ~/^DEVELOP-([\.\-\w]*)$/:
274 -    def suffix = Matcher.lastMatcher[0][1]
275 -    reportRsyncCommand = true
276 -    getdownSetAppBaseProperty = true
277 -    JALVIEW_VERSION=JALVIEW_VERSION+"-d${suffix}-${buildDate}"
278 -    install4jSuffix = "Develop ${suffix}"
279 -    install4jExtraScheme = "jalviewd"
280 -    install4jInstallerName = "${jalview_name} Develop ${suffix} Installer"
281 -    getdownChannelName = string("develop-${suffix}")
282 -    getdownChannelDir = string("${getdown_website_dir}/${getdownChannelName}")
283 -    getdownAppBaseDir = string("${jalviewDir}/${getdownChannelDir}/${JAVA_VERSION}")
284 -    getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
285 -    getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
286 -    channelSuffix = string(suffix)
287 -    backgroundImageText = true
288 -    break
289 -
290 -    case "DEVELOP":
291 -    reportRsyncCommand = true
292 -    getdownSetAppBaseProperty = true
293 -    // DEVELOP-RELEASE is usually associated with a Jalview release series so set the version
294 -    JALVIEW_VERSION=JALVIEW_VERSION+"-d${buildDate}"
295 -    
296 -    install4jSuffix = "Develop"
297 -    install4jExtraScheme = "jalviewd"
298 -    install4jInstallerName = "${jalview_name} Develop Installer"
299 -    backgroundImageText = true
300 -    break
301 -
302 -    case "TEST-RELEASE":
303 -    reportRsyncCommand = true
304 -    getdownSetAppBaseProperty = true
305 -    // Don't ignore transpile errors for release build
306 -    if (jalviewjs_ignore_transpile_errors.equals("true")) {
307 -      jalviewjs_ignore_transpile_errors = "false"
308 -      println("Setting jalviewjs_ignore_transpile_errors to 'false'")
309 -    }
310 -    JALVIEW_VERSION = JALVIEW_VERSION+"-test"
311 -    install4jSuffix = "Test"
312 -    install4jExtraScheme = "jalviewt"
313 -    install4jInstallerName = "${jalview_name} Test Installer"
314 -    backgroundImageText = true
315 -    break
316 -
317 -    case ~/^SCRATCH(|-[-\w]*)$/:
318 -    getdownChannelName = CHANNEL
319 -    JALVIEW_VERSION = JALVIEW_VERSION+"-"+CHANNEL
320 -    
321 -    getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
322 -    getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
323 -    reportRsyncCommand = true
324 -    install4jSuffix = "Scratch"
325 -    break
326 -
327 -    case "TEST-LOCAL":
328 -    if (!file("${LOCALDIR}").exists()) {
329 -      throw new GradleException("Must provide a LOCALDIR value to produce a local distribution")
330 -    } else {
331 -      getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
332 -      getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
333 -    }
334 -    JALVIEW_VERSION = "TEST"
335 -    install4jSuffix = "Test-Local"
336 -    install4jExtraScheme = "jalviewt"
337 -    install4jInstallerName = "${jalview_name} Test Installer"
338 -    backgroundImageText = true
339 -    break
340 -
341 -    case [ "LOCAL", "JALVIEWJS" ]:
342 -    JALVIEW_VERSION = "TEST"
343 -    getdownAppBase = file(getdownAppBaseDir).toURI().toString()
344 -    getdownArchiveAppBase = file("${jalviewDir}/${getdown_archive_dir}").toURI().toString()
345 -    getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
346 -    install4jExtraScheme = "jalviewl"
347 -    install4jCheckSums = false
348 -    break
349 -
350 -    default: // something wrong specified
351 -    throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
352 -    break
353 -
354 -  }
355 -  JALVIEW_VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
356 -  hugoDataJsonFile = file("${jalviewDir}/${hugo_build_dir}/${hugo_data_installers_dir}/installers-${JALVIEW_VERSION_UNDERSCORES}.json")
357 -  hugoArchiveMdFile = file("${jalviewDir}/${hugo_build_dir}/${hugo_version_archive_dir}/Version-${JALVIEW_VERSION_UNDERSCORES}/_index.md")
358 -  // override getdownAppBase if requested
359 -  if (findProperty("getdown_appbase_override") != null) {
360 -    // revert to LOCAL if empty string
361 -    if (string(getdown_appbase_override) == "") {
362 -      getdownAppBase = file(getdownAppBaseDir).toURI().toString()
363 -      getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
364 -    } else if (string(getdown_appbase_override).startsWith("file://")) {
365 -      getdownAppBase = string(getdown_appbase_override)
366 -      getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
367 -    } else {
368 -      getdownAppBase = string(getdown_appbase_override)
369 -    }
370 -    println("Overriding getdown appbase with '${getdownAppBase}'")
371 -  }
372 -  // sanitise file name for jalview launcher file for this channel
373 -  jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_")
374 -  // install4j application and folder names
375 -  if (install4jSuffix == "") {
376 -    install4jBundleId = "${install4j_bundle_id}"
377 -    install4jWinApplicationId = install4j_release_win_application_id
378 -  } else {
379 -    applicationName = "${jalview_name} ${install4jSuffix}"
380 -    install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase()
381 -    // add int hash of install4jSuffix to the last part of the application_id
382 -    def id = install4j_release_win_application_id
383 -    def idsplitreverse = id.split("-").reverse()
384 -    idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode()
385 -    install4jWinApplicationId = idsplitreverse.reverse().join("-")
386 -  }
387 -  // sanitise folder and id names
388 -  // install4jApplicationFolder = e.g. "Jalview Build"
389 -  install4jApplicationFolder = applicationName
390 -                                    .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \
391 -                                    .replaceAll("_+", "_") // collapse __
392 -  install4jInternalId = applicationName
393 -                                    .replaceAll(" ","_")
394 -                                    .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
395 -                                    .replaceAll("_+", "") // collapse __
396 -                                    //.replaceAll("_*-_*", "-") // collapse _-_
397 -  install4jUnixApplicationFolder = applicationName
398 -                                    .replaceAll(" ","_")
399 -                                    .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
400 -                                    .replaceAll("_+", "_") // collapse __
401 -                                    .replaceAll("_*-_*", "-") // collapse _-_
402 -                                    .toLowerCase()
403 -
404 -  getdownWrapperLink = install4jUnixApplicationFolder // e.g. "jalview_local"
405 -  getdownAppDir = string("${getdownAppBaseDir}/${getdownAppDistDir}")
406 -  //getdownJ11libDir = "${getdownAppBaseDir}/${getdown_j11lib_dir}"
407 -  getdownResourceDir = string("${getdownAppBaseDir}/${getdown_resource_dir}")
408 -  getdownInstallDir = string("${getdownAppBaseDir}/${getdown_install_dir}")
409 -  getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
410 -  getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
411 -  /* compile without modules -- using classpath libraries
412 -  modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
413 -  modules_runtimeClasspath = modules_compileClasspath
414 -  */
415 -
416 -  gitHash = "SOURCE"
417 -  gitBranch = "Source"
418 -  try {
419 -    apply plugin: "com.palantir.git-version"
420 -    def details = versionDetails()
421 -    gitHash = details.gitHash
422 -    gitBranch = details.branchName
423 -  } catch(org.gradle.api.internal.plugins.PluginApplicationException e) {
424 -    println("Not in a git repository. Using git values from RELEASE properties file.")
425 -    gitHash = releaseProps.getProperty("git.hash")
426 -    gitBranch = releaseProps.getProperty("git.branch")
427 -  } catch(java.lang.RuntimeException e1) {
428 -    throw new GradleException("Error with git-version plugin.  Directory '.git' exists but versionDetails() cannot be found.")
429 -  }
430  
431 +  install4jApplicationName = "${jalview_name}"
432 +  
433    println("Using a ${CHANNEL} profile.")
434  
435    additional_compiler_args = []
436 @@ -468,65 +109,16 @@ ext {
437      libDistDir = j8libDir
438      compile_source_compatibility = 1.8
439      compile_target_compatibility = 1.8
440 -    // these are getdown.txt properties defined dependent on the JAVA_VERSION
441 -    getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version"))
442 -    getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version"))
443 -    // this property is assigned below and expanded to multiple lines in the getdown task
444 -    getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location"))
445 -    // this property is for the Java library used in eclipse
446 -    eclipseJavaRuntimeName = string("JavaSE-1.8")
447    } else if (JAVA_VERSION.equals("11")) {
448      JAVA_INTEGER_VERSION = string("11")
449      libDir = j11libDir
450      libDistDir = j11libDir
451      compile_source_compatibility = 11
452      compile_target_compatibility = 11
453 -    getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
454 -    getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
455 -    getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
456 -    eclipseJavaRuntimeName = string("JavaSE-11")
457 -    /* compile without modules -- using classpath libraries
458 -    additional_compiler_args += [
459 -    '--module-path', modules_compileClasspath.asPath,
460 -    '--add-modules', j11modules
461 -    ]
462 -     */
463 -  } else if (JAVA_VERSION.equals("17")) {
464 -    JAVA_INTEGER_VERSION = string("17")
465 -    libDir = j17libDir
466 -    libDistDir = j17libDir
467 -    compile_source_compatibility = 17
468 -    compile_target_compatibility = 17
469 -    getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
470 -    getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
471 -    getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
472 -    eclipseJavaRuntimeName = string("JavaSE-17")
473 -    /* compile without modules -- using classpath libraries
474 -    additional_compiler_args += [
475 -    '--module-path', modules_compileClasspath.asPath,
476 -    '--add-modules', j11modules
477 -    ]
478 -     */
479    } else {
480      throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
481    }
482  
483 -
484 -  // for install4j
485 -  JAVA_MIN_VERSION = JAVA_VERSION
486 -  JAVA_MAX_VERSION = JAVA_VERSION
487 -  jreInstallsDir = string(jre_installs_dir)
488 -  if (jreInstallsDir.startsWith("~/")) {
489 -    jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1)
490 -  }
491 -  install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
492 -  install4jConfFileName = string("jalview-install4j-conf.install4j")
493 -  install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
494 -  install4jHomeDir = install4j_home_dir
495 -  if (install4jHomeDir.startsWith("~/")) {
496 -    install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
497 -  }
498 -
499    resourceBuildDir = string("${buildDir}/resources")
500    resourcesBuildDir = string("${resourceBuildDir}/resources_build")
501    helpBuildDir = string("${resourceBuildDir}/help_build")
502 @@ -540,39 +132,6 @@ ext {
503    helpSourceDir = string("${helpParentDir}/${help_dir}")
504    helpFile = string("${helpBuildDir}/${help_dir}/help.jhm")
505  
506 -  convertBinary = null
507 -  convertBinaryExpectedLocation = imagemagick_convert
508 -  if (convertBinaryExpectedLocation.startsWith("~/")) {
509 -    convertBinaryExpectedLocation = System.getProperty("user.home") + convertBinaryExpectedLocation.substring(1)
510 -  }
511 -  if (file(convertBinaryExpectedLocation).exists()) {
512 -    convertBinary = convertBinaryExpectedLocation
513 -  }
514 -
515 -  relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
516 -  jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
517 -  jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
518 -  if (IN_ECLIPSE) {
519 -    jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
520 -  } else {
521 -    jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
522 -  }
523 -  jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
524 -  jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
525 -  jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
526 -  jalviewjsJalviewCoreHtmlFile = string("")
527 -  jalviewjsJalviewCoreName = string(jalviewjs_core_name)
528 -  jalviewjsCoreClasslists = []
529 -  jalviewjsJalviewTemplateName = string(jalviewjs_name)
530 -  jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
531 -  jalviewjsJ2sAltSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_alt_settings}")
532 -  jalviewjsJ2sProps = null
533 -  jalviewjsJ2sPlugin = jalviewjs_j2s_plugin
534 -
535 -  eclipseWorkspace = null
536 -  eclipseBinary = string("")
537 -  eclipseVersion = string("")
538 -  eclipseDebug = false
539    // ENDEXT
540  }
541  
542 @@ -591,27 +150,12 @@ sourceSets {
543      compileClasspath = files(sourceSets.main.java.outputDir)
544      compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
545  
546 -    runtimeClasspath = compileClasspath
547 -    runtimeClasspath += files(sourceSets.main.resources.srcDirs)
548 -  }
549 -
550 -  clover {
551 -    java {
552 -      srcDirs cloverInstrDir
553 -      outputDir = cloverClassesDir
554 -    }
555 -
556 -    resources {
557 -      srcDirs = sourceSets.main.resources.srcDirs
558 -    }
559  
560 -    compileClasspath = files( sourceSets.clover.java.outputDir )
561 -    //compileClasspath += files( testClassesDir )
562 +    compileClasspath = files(sourceSets.main.java.outputDir)
563      compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
564 -    compileClasspath += fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
565 -    compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
566  
567      runtimeClasspath = compileClasspath
568 +    runtimeClasspath += files(sourceSets.main.resources.srcDirs)
569    }
570  
571    test {
572 @@ -631,453 +175,41 @@ sourceSets {
573      runtimeClasspath = compileClasspath
574      runtimeClasspath += files(sourceSets.test.resources.srcDirs)
575    }
576 -
577 -}
578 -
579 -
580 -// eclipse project and settings files creation, also used by buildship
581 -eclipse {
582 -  project {
583 -    name = eclipse_project_name
584 -
585 -    natures 'org.eclipse.jdt.core.javanature',
586 -    'org.eclipse.jdt.groovy.core.groovyNature',
587 -    'org.eclipse.buildship.core.gradleprojectnature'
588 -
589 -    buildCommand 'org.eclipse.jdt.core.javabuilder'
590 -    buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
591 -  }
592 -
593 -  classpath {
594 -    //defaultOutputDir = sourceSets.main.java.outputDir
595 -    configurations.each{ c->
596 -      if (c.isCanBeResolved()) {
597 -        minusConfigurations += [c]
598 -      }
599 -    }
600 -
601 -    plusConfigurations = [ ]
602 -    file {
603 -
604 -      whenMerged { cp ->
605 -        def removeTheseToo = []
606 -        HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
607 -        cp.entries.each { entry ->
608 -          // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
609 -          // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
610 -          // we add the resources and help/help dirs in as libs afterwards (see below)
611 -          if (entry.kind == 'src') {
612 -            if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
613 -              removeTheseToo += entry
614 -            } else {
615 -              alreadyAddedSrcPath.putAt(entry.path, true)
616 -            }
617 -          }
618 -
619 -        }
620 -        cp.entries.removeAll(removeTheseToo)
621 -
622 -        //cp.entries += new Output("${eclipse_bin_dir}/main")
623 -        if (file(helpParentDir).isDirectory()) {
624 -          cp.entries += new Library(fileReference(helpParentDir))
625 -        }
626 -        if (file(resourceDir).isDirectory()) {
627 -          cp.entries += new Library(fileReference(resourceDir))
628 -        }
629 -
630 -        HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
631 -
632 -        sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
633 -          //don't want to add outputDir as eclipse is using its own output dir in bin/main
634 -          if (it.isDirectory() || ! it.exists()) {
635 -            // don't add dirs to classpath, especially if they don't exist
636 -            return false // groovy "continue" in .any closure
637 -          }
638 -          def itPath = it.toString()
639 -          if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
640 -            // make relative path
641 -            itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
642 -          }
643 -          if (alreadyAddedLibPath.get(itPath)) {
644 -            //println("Not adding duplicate entry "+itPath)
645 -          } else {
646 -            //println("Adding entry "+itPath)
647 -            cp.entries += new Library(fileReference(itPath))
648 -            alreadyAddedLibPath.put(itPath, true)
649 -          }
650 -        }
651 -
652 -        sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
653 -          //no longer want to add outputDir as eclipse is using its own output dir in bin/main
654 -          if (it.isDirectory() || ! it.exists()) {
655 -            // don't add dirs to classpath
656 -            return false // groovy "continue" in .any closure
657 -          }
658 -
659 -          def itPath = it.toString()
660 -          if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
661 -            itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
662 -          }
663 -          if (alreadyAddedLibPath.get(itPath)) {
664 -            // don't duplicate
665 -          } else {
666 -            def lib = new Library(fileReference(itPath))
667 -            lib.entryAttributes["test"] = "true"
668 -            cp.entries += lib
669 -            alreadyAddedLibPath.put(itPath, true)
670 -          }
671 -        }
672 -
673 -      } // whenMerged
674 -
675 -    } // file
676 -
677 -    containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
678 -
679 -  } // classpath
680 -
681 -  jdt {
682 -    // for the IDE, use java 11 compatibility
683 -    sourceCompatibility = compile_source_compatibility
684 -    targetCompatibility = compile_target_compatibility
685 -    javaRuntimeName = eclipseJavaRuntimeName
686 -
687 -    // add in jalview project specific properties/preferences into eclipse core preferences
688 -    file {
689 -      withProperties { props ->
690 -        def jalview_prefs = new Properties()
691 -        def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
692 -        jalview_prefs.load(ins)
693 -        ins.close()
694 -        jalview_prefs.forEach { t, v ->
695 -          if (props.getAt(t) == null) {
696 -            props.putAt(t, v)
697 -          }
698 -        }
699 -        // codestyle file -- overrides previous formatter prefs
700 -        def csFile = file("${jalviewDirAbsolutePath}/${eclipse_codestyle_file}")
701 -        if (csFile.exists()) {
702 -          XmlParser parser = new XmlParser()
703 -          def profiles = parser.parse(csFile)
704 -          def profile = profiles.'profile'.find { p -> (p.'@kind' == "CodeFormatterProfile" && p.'@name' == "Jalview") }
705 -          if (profile != null) {
706 -            profile.'setting'.each { s ->
707 -              def id = s.'@id'
708 -              def value = s.'@value'
709 -              if (id != null && value != null) {
710 -                props.putAt(id, value)
711 -              }
712 -            }
713 -          }
714 -        }
715 -      }
716 -    }
717 -
718 -  } // jdt
719 -
720 -  if (IN_ECLIPSE) {
721 -    // Don't want these to be activated if in headless build
722 -    synchronizationTasks "eclipseSynchronizationTask"
723 -    //autoBuildTasks "eclipseAutoBuildTask"
724 -
725 -  }
726 -}
727 -
728 -
729 -/* hack to change eclipse prefs in .settings files other than org.eclipse.jdt.core.prefs */
730 -// Class to allow updating arbitrary properties files
731 -class PropertiesFile extends PropertiesPersistableConfigurationObject {
732 -  public PropertiesFile(PropertiesTransformer t) { super(t); }
733 -  @Override protected void load(Properties properties) { }
734 -  @Override protected void store(Properties properties) { }
735 -  @Override protected String getDefaultResourceName() { return ""; }
736 -  // This is necessary, because PropertiesPersistableConfigurationObject fails
737 -  // if no default properties file exists.
738 -  @Override public void loadDefaults() { load(new StringBufferInputStream("")); }
739 -}
740 -
741 -// Task to update arbitrary properties files (set outputFile)
742 -class PropertiesFileTask extends PropertiesGeneratorTask<PropertiesFile> {
743 -  private final PropertiesFileContentMerger file;
744 -  public PropertiesFileTask() { file = new PropertiesFileContentMerger(getTransformer()); }
745 -  protected PropertiesFile create() { return new PropertiesFile(getTransformer()); }
746 -  protected void configure(PropertiesFile props) {
747 -    file.getBeforeMerged().execute(props); file.getWhenMerged().execute(props);
748 -  }
749 -  public void file(Closure closure) { ConfigureUtil.configure(closure, file); }
750 -}
751 -
752 -task eclipseUIPreferences(type: PropertiesFileTask) {
753 -  description = "Generate Eclipse additional settings"
754 -  def filename = "org.eclipse.jdt.ui.prefs"
755 -  outputFile = "$projectDir/.settings/${filename}" as File
756 -  file {
757 -    withProperties {
758 -      it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
759 + /*  test {
760 +    java {
761 +      srcDirs testSourceDir
762 +      outputDir = file(testClassesDir)
763      }
764 -  }
765 -}
766  
767 -task eclipseGroovyCorePreferences(type: PropertiesFileTask) {
768 -  description = "Generate Eclipse additional settings"
769 -  def filename = "org.eclipse.jdt.groovy.core.prefs"
770 -  outputFile = "$projectDir/.settings/${filename}" as File
771 -  file {
772 -    withProperties {
773 -      it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
774 +    resources {
775 +      srcDirs = sourceSets.main.resources.srcDirs
776      }
777 -  }
778 -}
779 -
780 -task eclipseAllPreferences {
781 -  dependsOn eclipseJdt
782 -  dependsOn eclipseUIPreferences
783 -  dependsOn eclipseGroovyCorePreferences
784 -}
785 -
786 -eclipseUIPreferences.mustRunAfter eclipseJdt
787 -eclipseGroovyCorePreferences.mustRunAfter eclipseJdt
788 -
789 -/* end of eclipse preferences hack */
790 -
791 -
792 -// clover bits
793 -
794 -
795 -task cleanClover {
796 -  doFirst {
797 -    delete cloverBuildDir
798 -    delete cloverReportDir
799 -  }
800 -}
801 -
802 -
803 -task cloverInstrJava(type: JavaExec) {
804 -  group = "Verification"
805 -  description = "Create clover instrumented source java files"
806 -
807 -  dependsOn cleanClover
808 -
809 -  inputs.files(sourceSets.main.allJava)
810 -  outputs.dir(cloverInstrDir)
811 -
812 -  //classpath = fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
813 -  classpath = sourceSets.clover.compileClasspath
814 -  main = "com.atlassian.clover.CloverInstr"
815 -
816 -  def argsList = [
817 -    "--encoding",
818 -    "UTF-8",
819 -    "--initstring",
820 -    cloverDb,
821 -    "--destdir",
822 -    cloverInstrDir.getPath(),
823 -  ]
824 -  def srcFiles = sourceSets.main.allJava.files
825 -  argsList.addAll(
826 -    srcFiles.collect(
827 -      { file -> file.absolutePath }
828 -    )
829 -  )
830 -  args argsList.toArray()
831 -
832 -  doFirst {
833 -    delete cloverInstrDir
834 -    println("Clover: About to instrument "+srcFiles.size() +" files")
835 -  }
836 -}
837 -
838 -
839 -task cloverInstrTests(type: JavaExec) {
840 -  group = "Verification"
841 -  description = "Create clover instrumented source test files"
842 -
843 -  dependsOn cleanClover
844 -
845 -  inputs.files(testDir)
846 -  outputs.dir(cloverTestInstrDir)
847 -
848 -  classpath = sourceSets.clover.compileClasspath
849 -  main = "com.atlassian.clover.CloverInstr"
850 -
851 -  def argsList = [
852 -    "--encoding",
853 -    "UTF-8",
854 -    "--initstring",
855 -    cloverDb,
856 -    "--srcdir",
857 -    testDir,
858 -    "--destdir",
859 -    cloverTestInstrDir.getPath(),
860 -  ]
861 -  args argsList.toArray()
862 -
863 -  doFirst {
864 -    delete cloverTestInstrDir
865 -    println("Clover: About to instrument test files")
866 -  }
867 -}
868 -
869 -
870 -task cloverInstr {
871 -  group = "Verification"
872 -  description = "Create clover instrumented all source files"
873 -
874 -  dependsOn cloverInstrJava
875 -  dependsOn cloverInstrTests
876 -}
877 -
878 -
879 -cloverClasses.dependsOn cloverInstr
880 -
881 -
882 -task cloverConsoleReport(type: JavaExec) {
883 -  group = "Verification"
884 -  description = "Creates clover console report"
885 -
886 -  onlyIf {
887 -    file(cloverDb).exists()
888 -  }
889 -
890 -  inputs.dir cloverClassesDir
891 -
892 -  classpath = sourceSets.clover.runtimeClasspath
893 -  main = "com.atlassian.clover.reporters.console.ConsoleReporter"
894 -
895 -  if (cloverreport_mem.length() > 0) {
896 -    maxHeapSize = cloverreport_mem
897 -  }
898 -  if (cloverreport_jvmargs.length() > 0) {
899 -    jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
900 -  }
901 -
902 -  def argsList = [
903 -    "--alwaysreport",
904 -    "--initstring",
905 -    cloverDb,
906 -    "--unittests"
907 -  ]
908 -
909 -  args argsList.toArray()
910 -}
911 -
912 -
913 -task cloverHtmlReport(type: JavaExec) {
914 -  group = "Verification"
915 -  description = "Creates clover HTML report"
916 -
917 -  onlyIf {
918 -    file(cloverDb).exists()
919 -  }
920 -
921 -  def cloverHtmlDir = cloverReportDir
922 -  inputs.dir cloverClassesDir
923 -  outputs.dir cloverHtmlDir
924 -
925 -  classpath = sourceSets.clover.runtimeClasspath
926 -  main = "com.atlassian.clover.reporters.html.HtmlReporter"
927 -
928 -  if (cloverreport_mem.length() > 0) {
929 -    maxHeapSize = cloverreport_mem
930 -  }
931 -  if (cloverreport_jvmargs.length() > 0) {
932 -    jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
933 -  }
934  
935 -  def argsList = [
936 -    "--alwaysreport",
937 -    "--initstring",
938 -    cloverDb,
939 -    "--outputdir",
940 -    cloverHtmlDir
941 -  ]
942 -
943 -  if (cloverreport_html_options.length() > 0) {
944 -    argsList += cloverreport_html_options.split(" ")
945 -  }
946 -
947 -  args argsList.toArray()
948 -}
949 -
950 -
951 -task cloverXmlReport(type: JavaExec) {
952 -  group = "Verification"
953 -  description = "Creates clover XML report"
954 -
955 -  onlyIf {
956 -    file(cloverDb).exists()
957 -  }
958 -
959 -  def cloverXmlFile = "${cloverReportDir}/clover.xml"
960 -  inputs.dir cloverClassesDir
961 -  outputs.file cloverXmlFile
962 -
963 -  classpath = sourceSets.clover.runtimeClasspath
964 -  main = "com.atlassian.clover.reporters.xml.XMLReporter"
965 -
966 -  if (cloverreport_mem.length() > 0) {
967 -    maxHeapSize = cloverreport_mem
968 -  }
969 -  if (cloverreport_jvmargs.length() > 0) {
970 -    jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
971 -  }
972 -
973 -  def argsList = [
974 -    "--alwaysreport",
975 -    "--initstring",
976 -    cloverDb,
977 -    "--outfile",
978 -    cloverXmlFile
979 -  ]
980 -
981 -  if (cloverreport_xml_options.length() > 0) {
982 -    argsList += cloverreport_xml_options.split(" ")
983 -  }
984 -
985 -  args argsList.toArray()
986 -}
987 -
988 -
989 -task cloverReport {
990 -  group = "Verification"
991 -  description = "Creates clover reports"
992 -
993 -  dependsOn cloverXmlReport
994 -  dependsOn cloverHtmlReport
995 -}
996 -
997 -
998 -compileCloverJava {
999 +    compileClasspath = files( sourceSets.test.java.outputDir )
1000 +    compileClasspath += sourceSets.main.compileClasspath
1001 +    compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**   REMOVE_THIS_GAP  /*.jar"])
1002  
1003 -  doFirst {
1004 -    sourceCompatibility = compile_source_compatibility
1005 -    targetCompatibility = compile_target_compatibility
1006 -    options.compilerArgs += additional_compiler_args
1007 -    print ("Setting target compatibility to "+targetCompatibility+"\n")
1008 +    runtimeClasspath = compileClasspath
1009    }
1010 -  //classpath += configurations.cloverRuntime
1011 +*/
1012  }
1013 -// end clover bits
1014  
1015  
1016  compileJava {
1017 -  // JBP->BS should the print statement in doFirst refer to compile_target_compatibility ?
1018    sourceCompatibility = compile_source_compatibility
1019    targetCompatibility = compile_target_compatibility
1020 -  options.compilerArgs += additional_compiler_args
1021 -  options.encoding = "UTF-8"
1022 +  options.compilerArgs = additional_compiler_args
1023    doFirst {
1024      print ("Setting target compatibility to "+compile_target_compatibility+"\n")
1025    }
1026 -
1027  }
1028  
1029  
1030  compileTestJava {
1031 -  sourceCompatibility = compile_source_compatibility
1032 -  targetCompatibility = compile_target_compatibility
1033 -  options.compilerArgs += additional_compiler_args
1034    doFirst {
1035 +    sourceCompatibility = compile_source_compatibility
1036 +    targetCompatibility = compile_target_compatibility
1037 +    options.compilerArgs = additional_compiler_args
1038      print ("Setting target compatibility to "+targetCompatibility+"\n")
1039    }
1040  }
1041 @@ -1091,7 +223,6 @@ clean {
1042  
1043  
1044  cleanTest {
1045 -  dependsOn cleanClover
1046    doFirst {
1047      delete sourceSets.test.java.outputDir
1048    }
1049 @@ -1100,89 +231,11 @@ cleanTest {
1050  
1051  // format is a string like date.format("dd MMMM yyyy")
1052  def getDate(format) {
1053 +  def date = new Date()
1054    return date.format(format)
1055  }
1056  
1057  
1058 -def convertMdToHtml (FileTree mdFiles, File cssFile) {
1059 -  MutableDataSet options = new MutableDataSet()
1060 -
1061 -  def extensions = new ArrayList<>()
1062 -  extensions.add(AnchorLinkExtension.create()) 
1063 -  extensions.add(AutolinkExtension.create())
1064 -  extensions.add(StrikethroughExtension.create())
1065 -  extensions.add(TaskListExtension.create())
1066 -  extensions.add(TablesExtension.create())
1067 -  extensions.add(TocExtension.create())
1068 -  
1069 -  options.set(Parser.EXTENSIONS, extensions)
1070 -
1071 -  // set GFM table parsing options
1072 -  options.set(TablesExtension.WITH_CAPTION, false)
1073 -  options.set(TablesExtension.COLUMN_SPANS, false)
1074 -  options.set(TablesExtension.MIN_HEADER_ROWS, 1)
1075 -  options.set(TablesExtension.MAX_HEADER_ROWS, 1)
1076 -  options.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
1077 -  options.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
1078 -  options.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
1079 -  // GFM anchor links
1080 -  options.set(AnchorLinkExtension.ANCHORLINKS_SET_ID, false)
1081 -  options.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor")
1082 -  options.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true)
1083 -  options.set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "<span class=\"octicon octicon-link\"></span>")
1084 -
1085 -  Parser parser = Parser.builder(options).build()
1086 -  HtmlRenderer renderer = HtmlRenderer.builder(options).build()
1087 -
1088 -  mdFiles.each { mdFile ->
1089 -    // add table of contents
1090 -    def mdText = "[TOC]\n"+mdFile.text
1091 -
1092 -    // grab the first top-level title
1093 -    def title = null
1094 -    def titleRegex = /(?m)^#(\s+|([^#]))(.*)/
1095 -    def matcher = mdText =~ titleRegex
1096 -    if (matcher.size() > 0) {
1097 -      // matcher[0][2] is the first character of the title if there wasn't any whitespace after the #
1098 -      title = (matcher[0][2] != null ? matcher[0][2] : "")+matcher[0][3]
1099 -    }
1100 -    // or use the filename if none found
1101 -    if (title == null) {
1102 -      title = mdFile.getName()
1103 -    }
1104 -
1105 -    Node document = parser.parse(mdText)
1106 -    String htmlBody = renderer.render(document)
1107 -    def htmlText = '''<html>
1108 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1109 -<html xmlns="http://www.w3.org/1999/xhtml">
1110 -  <head>
1111 -    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1112 -    <meta http-equiv="Content-Style-Type" content="text/css" />
1113 -    <meta name="generator" content="flexmark" />
1114 -'''
1115 -    htmlText += ((title != null) ? "  <title>${title}</title>" : '' )
1116 -    htmlText += '''
1117 -    <style type="text/css">code{white-space: pre;}</style>
1118 -'''
1119 -    htmlText += ((cssFile != null) ? cssFile.text : '')
1120 -    htmlText += '''</head>
1121 -  <body>
1122 -'''
1123 -    htmlText += htmlBody
1124 -    htmlText += '''
1125 -  </body>
1126 -</html>
1127 -'''
1128 -
1129 -    def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html")
1130 -    def htmlFile = file(htmlFilePath)
1131 -    println("Creating ${htmlFilePath}")
1132 -    htmlFile.text = htmlText
1133 -  }
1134 -}
1135 -
1136 -
1137  task copyDocs(type: Copy) {
1138    def inputDir = "${jalviewDir}/${doc_dir}"
1139    def outputDir = "${docBuildDir}/${doc_dir}"
1140 @@ -1213,235 +266,6 @@ task copyDocs(type: Copy) {
1141  }
1142  
1143  
1144 -task convertMdFiles {
1145 -  dependsOn copyDocs
1146 -  def mdFiles = fileTree(dir: docBuildDir, include: "**/*.md")
1147 -  def cssFile = file("${jalviewDir}/${flexmark_css}")
1148 -
1149 -  doLast {
1150 -    convertMdToHtml(mdFiles, cssFile)
1151 -  }
1152 -
1153 -  inputs.files(mdFiles)
1154 -  inputs.file(cssFile)
1155 -
1156 -  def htmlFiles = []
1157 -  mdFiles.each { mdFile ->
1158 -    def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html")
1159 -    htmlFiles.add(file(htmlFilePath))
1160 -  }
1161 -  outputs.files(htmlFiles)
1162 -}
1163 -
1164 -
1165 -def hugoTemplateSubstitutions(String input, Map extras=null) {
1166 -  def replacements = [
1167 -    DATE: getDate("yyyy-MM-dd"),
1168 -    CHANNEL: propertiesChannelName,
1169 -    APPLICATION_NAME: applicationName,
1170 -    GIT_HASH: gitHash,
1171 -    GIT_BRANCH: gitBranch,
1172 -    VERSION: JALVIEW_VERSION,
1173 -    JAVA_VERSION: JAVA_VERSION,
1174 -    VERSION_UNDERSCORES: JALVIEW_VERSION_UNDERSCORES,
1175 -    DRAFT: "false",
1176 -    JVL_HEADER: ""
1177 -  ]
1178 -  def output = input
1179 -  if (extras != null) {
1180 -    extras.each{ k, v ->
1181 -      output = output.replaceAll("__${k}__", ((v == null)?"":v))
1182 -    }
1183 -  }
1184 -  replacements.each{ k, v ->
1185 -    output = output.replaceAll("__${k}__", ((v == null)?"":v))
1186 -  }
1187 -  return output
1188 -}
1189 -
1190 -def mdFileComponents(File mdFile, def dateOnly=false) {
1191 -  def map = [:]
1192 -  def content = ""
1193 -  if (mdFile.exists()) {
1194 -    def inFrontMatter = false
1195 -    def firstLine = true
1196 -    mdFile.eachLine { line ->
1197 -      if (line.matches("---")) {
1198 -        def prev = inFrontMatter
1199 -        inFrontMatter = firstLine
1200 -        if (inFrontMatter != prev)
1201 -          return false
1202 -      }
1203 -      if (inFrontMatter) {
1204 -        def m = null
1205 -        if (m = line =~ /^date:\s*(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/) {
1206 -          map["date"] = new Date().parse("yyyy-MM-dd HH:mm:ss", m[0][1])
1207 -        } else if (m = line =~ /^date:\s*(\d{4}-\d{2}-\d{2})/) {
1208 -          map["date"] = new Date().parse("yyyy-MM-dd", m[0][1])
1209 -        } else if (m = line =~ /^channel:\s*(\S+)/) {
1210 -          map["channel"] = m[0][1]
1211 -        } else if (m = line =~ /^version:\s*(\S+)/) {
1212 -          map["version"] = m[0][1]
1213 -        } else if (m = line =~ /^\s*([^:]+)\s*:\s*(\S.*)/) {
1214 -          map[ m[0][1] ] = m[0][2]
1215 -        }
1216 -        if (dateOnly && map["date"] != null) {
1217 -          return false
1218 -        }
1219 -      } else {
1220 -        if (dateOnly)
1221 -          return false
1222 -        content += line+"\n"
1223 -      }
1224 -      firstLine = false
1225 -    }
1226 -  }
1227 -  return dateOnly ? map["date"] : [map, content]
1228 -}
1229 -
1230 -task hugoTemplates {
1231 -  group "website"
1232 -  description "Create partially populated md pages for hugo website build"
1233 -
1234 -  def hugoTemplatesDir = file("${jalviewDir}/${hugo_templates_dir}")
1235 -  def hugoBuildDir = "${jalviewDir}/${hugo_build_dir}"
1236 -  def templateFiles = fileTree(dir: hugoTemplatesDir)
1237 -  def releaseMdFile = file("${jalviewDir}/${releases_dir}/release-${JALVIEW_VERSION_UNDERSCORES}.md")
1238 -  def whatsnewMdFile = file("${jalviewDir}/${whatsnew_dir}/whatsnew-${JALVIEW_VERSION_UNDERSCORES}.md")
1239 -  def oldJvlFile = file("${jalviewDir}/${hugo_old_jvl}")
1240 -  def jalviewjsFile = file("${jalviewDir}/${hugo_jalviewjs}")
1241 -
1242 -  doFirst {
1243 -    // specific release template for version archive
1244 -    def changes = ""
1245 -    def whatsnew = null
1246 -    def givenDate = null
1247 -    def givenChannel = null
1248 -    def givenVersion = null
1249 -    if (CHANNEL == "RELEASE") {
1250 -      def (map, content) = mdFileComponents(releaseMdFile)
1251 -      givenDate = map.date
1252 -      givenChannel = map.channel
1253 -      givenVersion = map.version
1254 -      changes = content
1255 -      if (givenVersion != null && givenVersion != JALVIEW_VERSION) {
1256 -        throw new GradleException("'version' header (${givenVersion}) found in ${releaseMdFile} does not match JALVIEW_VERSION (${JALVIEW_VERSION})")
1257 -      }
1258 -
1259 -      if (whatsnewMdFile.exists())
1260 -        whatsnew = whatsnewMdFile.text
1261 -    }
1262 -
1263 -    def oldJvl = oldJvlFile.exists() ? oldJvlFile.collect{it} : []
1264 -    def jalviewjsLink = jalviewjsFile.exists() ? jalviewjsFile.collect{it} : []
1265 -
1266 -    def changesHugo = null
1267 -    if (changes != null) {
1268 -      changesHugo = '<div class="release_notes">\n\n'
1269 -      def inSection = false
1270 -      changes.eachLine { line ->
1271 -        def m = null
1272 -        if (m = line =~ /^##([^#].*)$/) {
1273 -          if (inSection) {
1274 -            changesHugo += "</div>\n\n"
1275 -          }
1276 -          def section = m[0][1].trim()
1277 -          section = section.toLowerCase()
1278 -          section = section.replaceAll(/ +/, "_")
1279 -          section = section.replaceAll(/[^a-z0-9_\-]/, "")
1280 -          changesHugo += "<div class=\"${section}\">\n\n"
1281 -          inSection = true
1282 -        } else if (m = line =~ /^(\s*-\s*)<!--([^>]+)-->(.*?)(<br\/?>)?\s*$/) {
1283 -          def comment = m[0][2].trim()
1284 -          if (comment != "") {
1285 -            comment = comment.replaceAll('"', "&quot;")
1286 -            def issuekeys = []
1287 -            comment.eachMatch(/JAL-\d+/) { jal -> issuekeys += jal }
1288 -            def newline = m[0][1]
1289 -            if (comment.trim() != "")
1290 -              newline += "{{<comment>}}${comment}{{</comment>}}  "
1291 -            newline += m[0][3].trim()
1292 -            if (issuekeys.size() > 0)
1293 -              newline += "  {{< jal issue=\"${issuekeys.join(",")}\" alt=\"${comment}\" >}}"
1294 -            if (m[0][4] != null)
1295 -              newline += m[0][4]
1296 -            line = newline
1297 -          }
1298 -        }
1299 -        changesHugo += line+"\n"
1300 -      }
1301 -      if (inSection) {
1302 -        changesHugo += "\n</div>\n\n"
1303 -      }
1304 -      changesHugo += '</div>'
1305 -    }
1306 -
1307 -    templateFiles.each{ templateFile ->
1308 -      def newFileName = string(hugoTemplateSubstitutions(templateFile.getName()))
1309 -      def relPath = hugoTemplatesDir.toPath().relativize(templateFile.toPath()).getParent()
1310 -      def newRelPathName = hugoTemplateSubstitutions( relPath.toString() )
1311 -
1312 -      def outPathName = string("${hugoBuildDir}/$newRelPathName")
1313 -
1314 -      copy {
1315 -        from templateFile
1316 -        rename(templateFile.getName(), newFileName)
1317 -        into outPathName
1318 -      }
1319 -
1320 -      def newFile = file("${outPathName}/${newFileName}".toString())
1321 -      def content = newFile.text
1322 -      newFile.text = hugoTemplateSubstitutions(content,
1323 -        [
1324 -          WHATSNEW: whatsnew,
1325 -          CHANGES: changesHugo,
1326 -          DATE: givenDate == null ? "" : givenDate.format("yyyy-MM-dd"),
1327 -          DRAFT: givenDate == null ? "true" : "false",
1328 -          JALVIEWJSLINK: jalviewjsLink.contains(JALVIEW_VERSION) ? "true" : "false",
1329 -          JVL_HEADER: oldJvl.contains(JALVIEW_VERSION) ? "jvl: true" : ""
1330 -        ]
1331 -      )
1332 -    }
1333 -
1334 -  }
1335 -
1336 -  inputs.file(oldJvlFile)
1337 -  inputs.dir(hugoTemplatesDir)
1338 -  inputs.property("JALVIEW_VERSION", { JALVIEW_VERSION })
1339 -  inputs.property("CHANNEL", { CHANNEL })
1340 -}
1341 -
1342 -def getMdDate(File mdFile) {
1343 -  return mdFileComponents(mdFile, true)
1344 -}
1345 -
1346 -def getMdSections(String content) {
1347 -  def sections = [:]
1348 -  def sectionContent = ""
1349 -  def sectionName = null
1350 -  content.eachLine { line ->
1351 -    def m = null
1352 -    if (m = line =~ /^##([^#].*)$/) {
1353 -      if (sectionName != null) {
1354 -        sections[sectionName] = sectionContent
1355 -        sectionName = null
1356 -        sectionContent = ""
1357 -      }
1358 -      sectionName = m[0][1].trim()
1359 -      sectionName = sectionName.toLowerCase()
1360 -      sectionName = sectionName.replaceAll(/ +/, "_")
1361 -      sectionName = sectionName.replaceAll(/[^a-z0-9_\-]/, "")
1362 -    } else if (sectionName != null) {
1363 -      sectionContent += line+"\n"
1364 -    }
1365 -  }
1366 -  if (sectionContent != null) {
1367 -    sections[sectionName] = sectionContent
1368 -  }
1369 -  return sections
1370 -}
1371 -
1372 -
1373  task copyHelp(type: Copy) {
1374    def inputDir = helpSourceDir
1375    def outputDir = "${helpBuildDir}/${help_dir}"
1376 @@ -1476,7 +300,6 @@ task copyHelp(type: Copy) {
1377    outputs.dir(outputDir)
1378  }
1379  
1380 -
1381  task releasesTemplates {
1382    group "help"
1383    description "Recreate whatsNew.html and releases.html from markdown files and templates in help"
1384 @@ -1491,6 +314,7 @@ task releasesTemplates {
1385    def whatsnewMdDir = "${jalviewDir}/${whatsnew_dir}"
1386  
1387    doFirst {
1388 +    def JALVIEW_VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1389      def releaseMdFile = file("${releasesMdDir}/release-${JALVIEW_VERSION_UNDERSCORES}.md")
1390      def whatsnewMdFile = file("${whatsnewMdDir}/whatsnew-${JALVIEW_VERSION_UNDERSCORES}.md")
1391  
1392 @@ -1505,7 +329,7 @@ task releasesTemplates {
1393  
1394      def releaseFiles = fileTree(dir: releasesMdDir, include: "release-*.md")
1395      def releaseFilesDates = releaseFiles.collectEntries {
1396 -      [(it): getMdDate(it)]
1397 +      [(it): getDate("")]
1398      }
1399      releaseFiles = releaseFiles.sort { a,b -> releaseFilesDates[a].compareTo(releaseFilesDates[b]) }
1400  
1401 @@ -1513,96 +337,13 @@ task releasesTemplates {
1402      def m = releasesTemplate =~ /(?s)__VERSION_LOOP_START__(.*)__VERSION_LOOP_END__/
1403      def versionTemplate = m[0][1]
1404  
1405 -    MutableDataSet options = new MutableDataSet()
1406 -
1407 -    def extensions = new ArrayList<>()
1408 -    options.set(Parser.EXTENSIONS, extensions)
1409 -    options.set(Parser.HTML_BLOCK_COMMENT_ONLY_FULL_LINE, true)
1410 -
1411 -    Parser parser = Parser.builder(options).build()
1412 -    HtmlRenderer renderer = HtmlRenderer.builder(options).build()
1413 -
1414 -    def actualVersions = releaseFiles.collect { rf ->
1415 -      def (rfMap, rfContent) = mdFileComponents(rf)
1416 -      return rfMap.version
1417 -    }
1418      def versionsHtml = ""
1419      def linkedVersions = []
1420 -    releaseFiles.reverse().each { rFile ->
1421 -      def (rMap, rContent) = mdFileComponents(rFile)
1422 -
1423 -      def versionLink = ""
1424 -      def partialVersion = ""
1425 -      def firstPart = true
1426 -      rMap.version.split("\\.").each { part ->
1427 -        def displayPart = ( firstPart ? "" : "." ) + part
1428 -        partialVersion += displayPart
1429 -        if (
1430 -            linkedVersions.contains(partialVersion)
1431 -            || ( actualVersions.contains(partialVersion) && partialVersion != rMap.version )
1432 -            ) {
1433 -          versionLink += displayPart
1434 -        } else {
1435 -          versionLink += "<a id=\"Jalview.${partialVersion}\">${displayPart}</a>"
1436 -          linkedVersions += partialVersion
1437 -        }
1438 -        firstPart = false
1439 -      }
1440 -      def displayDate = releaseFilesDates[rFile].format("dd/MM/yyyy")
1441 -
1442 -      def lm = null
1443 -      def rContentProcessed = ""
1444 -      rContent.eachLine { line ->
1445 -        if (lm = line =~ /^(\s*-)(\s*<!--[^>]*?-->)(.*)$/) {
1446 -          line = "${lm[0][1]}${lm[0][3]}${lm[0][2]}"
1447 -      } else if (lm = line =~ /^###([^#]+.*)$/) {
1448 -          line = "_${lm[0][1].trim()}_"
1449 -        }
1450 -        rContentProcessed += line + "\n"
1451 -      }
1452 -
1453 -      def rContentSections = getMdSections(rContentProcessed)
1454 -      def rVersion = versionTemplate
1455 -      if (rVersion != "") {
1456 -        def rNewFeatures = rContentSections["new_features"]
1457 -        def rIssuesResolved = rContentSections["issues_resolved"]
1458 -        Node newFeaturesNode = parser.parse(rNewFeatures)
1459 -        String newFeaturesHtml = renderer.render(newFeaturesNode)
1460 -        Node issuesResolvedNode = parser.parse(rIssuesResolved)
1461 -        String issuesResolvedHtml = renderer.render(issuesResolvedNode)
1462 -        rVersion = hugoTemplateSubstitutions(rVersion,
1463 -          [
1464 -            VERSION: rMap.version,
1465 -            VERSION_LINK: versionLink,
1466 -            DISPLAY_DATE: displayDate,
1467 -            NEW_FEATURES: newFeaturesHtml,
1468 -            ISSUES_RESOLVED: issuesResolvedHtml
1469 -          ]
1470 -        )
1471 -        versionsHtml += rVersion
1472 -      }
1473 -    }
1474  
1475      releasesTemplate = releasesTemplate.replaceAll("(?s)__VERSION_LOOP_START__.*__VERSION_LOOP_END__", versionsHtml)
1476 -    releasesTemplate = hugoTemplateSubstitutions(releasesTemplate)
1477      releasesHtmlFile.text = releasesTemplate
1478  
1479 -    if (whatsnewMdFile.exists()) {
1480 -      def wnDisplayDate = releaseFilesDates[releaseMdFile] != null ? releaseFilesDates[releaseMdFile].format("dd MMMM yyyy") : ""
1481 -      def whatsnewMd = hugoTemplateSubstitutions(whatsnewMdFile.text)
1482 -      Node whatsnewNode = parser.parse(whatsnewMd)
1483 -      String whatsnewHtml = renderer.render(whatsnewNode)
1484 -      whatsnewHtml = whatsnewTemplateFile.text.replaceAll("__WHATS_NEW__", whatsnewHtml)
1485 -      whatsnewHtmlFile.text = hugoTemplateSubstitutions(whatsnewHtml,
1486 -        [
1487 -            VERSION: JALVIEW_VERSION,
1488 -          DISPLAY_DATE: wnDisplayDate
1489 -        ]
1490 -      )
1491 -    } else if (gradle.taskGraph.hasTask(":linkCheck")) {
1492 -      whatsnewHtmlFile.text = "Development build " + getDate("yyyy-MM-dd HH:mm:ss")
1493 -    }
1494 -
1495 +    whatsnewHtmlFile.text = "Debian build " + getDate("yyyy-MM-dd HH:mm:ss")
1496    }
1497  
1498    inputs.file(releasesTemplateFile)
1499 @@ -1613,7 +354,6 @@ task releasesTemplates {
1500    outputs.file(whatsnewHtmlFile)
1501  }
1502  
1503 -
1504  task copyResources(type: Copy) {
1505    group = "build"
1506    description = "Copy (and make text substitutions in) the resources dir to the build area"
1507 @@ -1653,44 +393,22 @@ task copyChannelResources(type: Copy) {
1508  
1509    def inputDir = "${channelDir}/${resource_dir}"
1510    def outputDir = resourcesBuildDir
1511 -  from(inputDir) {
1512 -    include(channel_props)
1513 -    filter(ReplaceTokens,
1514 -      beginToken: '__',
1515 -      endToken: '__',
1516 -      tokens: [
1517 -        'SUFFIX': channelSuffix
1518 -      ]
1519 -    )
1520 -  }
1521 -  from(inputDir) {
1522 -    exclude(channel_props)
1523 -  }
1524 +  from inputDir
1525    into outputDir
1526  
1527    inputs.dir(inputDir)
1528    outputs.dir(outputDir)
1529  }
1530  
1531 -task createBuildProperties(type: WriteProperties) {
1532 -  dependsOn copyResources
1533 -  group = "build"
1534 -  description = "Create the ${buildProperties} file"
1535 -  
1536 -  inputs.dir(sourceDir)
1537 -  inputs.dir(resourcesBuildDir)
1538 -  outputFile (buildProperties)
1539 -  // taking time specific comment out to allow better incremental builds
1540 -  comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
1541 -  //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
1542 -  property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
1543 -  property "VERSION", JALVIEW_VERSION
1544 -  property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
1545 -  property "JAVA_COMPILE_VERSION", JAVA_INTEGER_VERSION
1546 -  if (getdownSetAppBaseProperty) {
1547 -    property "GETDOWNAPPBASE", getdownAppBase
1548 -    property "GETDOWNAPPDISTDIR", getdownAppDistDir
1549 -  }
1550 +task createBuildProperties(type: Copy) {
1551 +  // using the build_properties already included in the source tarball
1552 +  def inputFile = "build_properties"
1553 +  def outputFile = buildProperties
1554 +  from inputFile
1555 +  into file(outputFile).getParent()
1556 +  rename(file(inputFile).getName(), file(outputFile).getName())
1557 +
1558 +  inputs.file(inputFile)
1559    outputs.file(outputFile)
1560  }
1561  
1562 @@ -1725,123 +443,31 @@ task prepare {
1563    dependsOn copyDocs
1564    dependsOn copyHelp
1565    dependsOn releasesTemplates
1566 -  dependsOn convertMdFiles
1567    dependsOn buildIndices
1568  }
1569  
1570  
1571  compileJava.dependsOn prepare
1572  run.dependsOn compileJava
1573 -compileTestJava.dependsOn compileJava
1574 -
1575 +//run.dependsOn prepare
1576  
1577  
1578 +//testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
1579  test {
1580 -  group = "Verification"
1581 -  description = "Runs all testTaskN tasks)"
1582 -
1583 -  if (useClover) {
1584 -    dependsOn cloverClasses
1585 -  } else { //?
1586 -    dependsOn testClasses
1587 -  }
1588 -
1589 -  // not running tests in this task
1590 -  exclude "**/*"
1591 -}
1592 -/* testTask0 is the main test task */
1593 -task testTask0(type: Test) {
1594 -  group = "Verification"
1595 -  description = "The main test task. Runs all non-testTaskN-labelled tests (unless excluded)"
1596 -  useTestNG() {
1597 -    includeGroups testng_groups.split(",")
1598 -    excludeGroups testng_excluded_groups.split(",")
1599 -    tasks.withType(Test).matching {it.name.startsWith("testTask") && it.name != name}.all {t -> excludeGroups t.name}
1600 -    preserveOrder true
1601 -    useDefaultListeners=true
1602 -  }
1603 -}
1604 -
1605 -/* separated tests */
1606 -task testTask1(type: Test) {
1607 -  group = "Verification"
1608 -  description = "Tests that need to be isolated from the main test run"
1609 -  useTestNG() {
1610 -    includeGroups name
1611 -    excludeGroups testng_excluded_groups.split(",")
1612 -    preserveOrder true
1613 -    useDefaultListeners=true
1614 -  }
1615 -}
1616 +  dependsOn prepare
1617 +  dependsOn compileJava //?
1618  
1619 -/* insert more testTaskNs here -- change N to next digit or other string */
1620 -/*
1621 -task testTaskN(type: Test) {
1622 -  group = "Verification"
1623 -  description = "Tests that need to be isolated from the main test run"
1624    useTestNG() {
1625 -    includeGroups name
1626 -    excludeGroups testng_excluded_groups.split(",")
1627 +    includeGroups testng_groups
1628 +    excludeGroups testng_excluded_groups
1629      preserveOrder true
1630      useDefaultListeners=true
1631    }
1632 -}
1633 -*/
1634 -
1635 -/*
1636 - * adapted from https://medium.com/@wasyl/pretty-tests-summary-in-gradle-744804dd676c
1637 - * to summarise test results from all Test tasks
1638 - */
1639 -/* START of test tasks results summary */
1640 -import groovy.time.TimeCategory
1641 -import org.gradle.api.tasks.testing.logging.TestExceptionFormat
1642 -import org.gradle.api.tasks.testing.logging.TestLogEvent
1643 -rootProject.ext.testsResults = [] // Container for tests summaries
1644 -
1645 -tasks.withType(Test).matching {t -> t.getName().startsWith("testTask")}.all { testTask ->
1646 -
1647 -  // from original test task
1648 -  if (useClover) {
1649 -    dependsOn cloverClasses
1650 -  } else { //?
1651 -    dependsOn testClasses //?
1652 -  }
1653 -
1654 -  // run main tests first
1655 -  if (!testTask.name.equals("testTask0"))
1656 -    testTask.mustRunAfter "testTask0"
1657 -
1658 -  testTask.testLogging { logging ->
1659 -    events TestLogEvent.FAILED
1660 -//      TestLogEvent.SKIPPED,
1661 -//      TestLogEvent.STANDARD_OUT,
1662 -//      TestLogEvent.STANDARD_ERROR
1663 -
1664 -    exceptionFormat TestExceptionFormat.FULL
1665 -    showExceptions true
1666 -    showCauses true
1667 -    showStackTraces true
1668 -
1669 -    info.events = [ TestLogEvent.FAILED ]
1670 -  }
1671 -
1672 -
1673 -
1674 -  ignoreFailures = true // Always try to run all tests for all modules
1675 -
1676 -  afterSuite { desc, result ->
1677 -    if (desc.parent)
1678 -      return // Only summarize results for whole modules
1679 -
1680 -    def resultsInfo = [testTask.project.name, testTask.name, result, TimeCategory.minus(new Date(result.endTime), new Date(result.startTime)), testTask.reports.html.entryPoint]
1681 -
1682 -    rootProject.ext.testsResults.add(resultsInfo)
1683 -  }
1684  
1685 -  // from original test task
1686    maxHeapSize = "1024m"
1687  
1688    workingDir = jalviewDir
1689 +  //systemProperties 'clover.jar' System.properties.clover.jar
1690    def testLaf = project.findProperty("test_laf")
1691    if (testLaf != null) {
1692      println("Setting Test LaF to '${testLaf}'")
1693 @@ -1857,143 +483,8 @@ tasks.withType(Test).matching {t -> t.getName().startsWith("testTask")}.all { te
1694    jvmArgs += additional_compiler_args
1695  
1696    doFirst {
1697 -    // this is not perfect yet -- we should only add the commandLineIncludePatterns to the
1698 -    // testTasks that include the tests, and exclude all from the others.
1699 -    // get --test argument
1700 -    filter.commandLineIncludePatterns = test.filter.commandLineIncludePatterns
1701 -    // do something with testTask.getCandidateClassFiles() to see if the test should silently finish because of the
1702 -    // commandLineIncludePatterns not matching anything.  Instead we are doing setFailOnNoMatchingTests(false) below
1703 -
1704 -
1705 -    if (useClover) {
1706 -      println("Running tests " + (useClover?"WITH":"WITHOUT") + " clover")
1707 -    }
1708 -  }
1709 -
1710 -
1711 -  /* don't fail on no matching tests (so --tests will run across all testTasks) */
1712 -  testTask.filter.setFailOnNoMatchingTests(false)
1713 -
1714 -  /* ensure the "test" task dependsOn all the testTasks */
1715 -  test.dependsOn testTask
1716 -}
1717 -
1718 -gradle.buildFinished {
1719 -    def allResults = rootProject.ext.testsResults
1720 -
1721 -    if (!allResults.isEmpty()) {
1722 -        printResults allResults
1723 -        allResults.each {r ->
1724 -          if (r[2].resultType == TestResult.ResultType.FAILURE)
1725 -            throw new GradleException("Failed tests!")
1726 -        }
1727 -    }
1728 -}
1729 -
1730 -private static String colString(styler, col, colour, text) {
1731 -  return col?"${styler[colour](text)}":text
1732 -}
1733 -
1734 -private static String getSummaryLine(s, pn, tn, rt, rc, rs, rf, rsk, t, col) {
1735 -  def colour = 'black'
1736 -  def text = rt
1737 -  def nocol = false
1738 -  if (rc == 0) {
1739 -    text = "-----"
1740 -    nocol = true
1741 -  } else {
1742 -    switch(rt) {
1743 -      case TestResult.ResultType.SUCCESS:
1744 -        colour = 'green'
1745 -        break;
1746 -      case TestResult.ResultType.FAILURE:
1747 -        colour = 'red'
1748 -        break;
1749 -      default:
1750 -        nocol = true
1751 -        break;
1752 -    }
1753    }
1754 -  StringBuilder sb = new StringBuilder()
1755 -  sb.append("${pn}")
1756 -  if (tn != null)
1757 -    sb.append(":${tn}")
1758 -  sb.append(" results: ")
1759 -  sb.append(colString(s, col && !nocol, colour, text))
1760 -  sb.append(" (")
1761 -  sb.append("${rc} tests, ")
1762 -  sb.append(colString(s, col && rs > 0, 'green', rs))
1763 -  sb.append(" successes, ")
1764 -  sb.append(colString(s, col && rf > 0, 'red', rf))
1765 -  sb.append(" failures, ")
1766 -  sb.append("${rsk} skipped) in ${t}")
1767 -  return sb.toString()
1768 -}
1769 -
1770 -private static void printResults(allResults) {
1771 -
1772 -    // styler from https://stackoverflow.com/a/56139852
1773 -    def styler = 'black red green yellow blue magenta cyan white'.split().toList().withIndex(30).collectEntries { key, val -> [(key) : { "\033[${val}m${it}\033[0m" }] }
1774 -
1775 -    def maxLength = 0
1776 -    def failedTests = false
1777 -    def summaryLines = []
1778 -    def totalcount = 0
1779 -    def totalsuccess = 0
1780 -    def totalfail = 0
1781 -    def totalskip = 0
1782 -    def totaltime = TimeCategory.getSeconds(0)
1783 -    // sort on project name then task name
1784 -    allResults.sort {a, b -> a[0] == b[0]? a[1]<=>b[1]:a[0] <=> b[0]}.each {
1785 -      def projectName = it[0]
1786 -      def taskName = it[1]
1787 -      def result = it[2]
1788 -      def time = it[3]
1789 -      def report = it[4]
1790 -      def summaryCol = getSummaryLine(styler, projectName, taskName, result.resultType, result.testCount, result.successfulTestCount, result.failedTestCount, result.skippedTestCount, time, true)
1791 -      def summaryPlain = getSummaryLine(styler, projectName, taskName, result.resultType, result.testCount, result.successfulTestCount, result.failedTestCount, result.skippedTestCount, time, false)
1792 -      def reportLine = "Report file: ${report}"
1793 -      def ls = summaryPlain.length()
1794 -      def lr = reportLine.length()
1795 -      def m = [ls, lr].max()
1796 -      if (m > maxLength)
1797 -        maxLength = m
1798 -      def info = [ls, summaryCol, reportLine]
1799 -      summaryLines.add(info)
1800 -      failedTests |= result.resultType == TestResult.ResultType.FAILURE
1801 -      totalcount += result.testCount
1802 -      totalsuccess += result.successfulTestCount
1803 -      totalfail += result.failedTestCount
1804 -      totalskip += result.skippedTestCount
1805 -      totaltime += time
1806 -    }
1807 -    def totalSummaryCol = getSummaryLine(styler, "OVERALL", "", failedTests?TestResult.ResultType.FAILURE:TestResult.ResultType.SUCCESS, totalcount, totalsuccess, totalfail, totalskip, totaltime, true)
1808 -    def totalSummaryPlain = getSummaryLine(styler, "OVERALL", "", failedTests?TestResult.ResultType.FAILURE:TestResult.ResultType.SUCCESS, totalcount, totalsuccess, totalfail, totalskip, totaltime, false)
1809 -    def tls = totalSummaryPlain.length()
1810 -    if (tls > maxLength)
1811 -      maxLength = tls
1812 -    def info = [tls, totalSummaryCol, null]
1813 -    summaryLines.add(info)
1814 -
1815 -    def allSummaries = []
1816 -    for(sInfo : summaryLines) {
1817 -      def ls = sInfo[0]
1818 -      def summary = sInfo[1]
1819 -      def report = sInfo[2]
1820 -
1821 -      StringBuilder sb = new StringBuilder()
1822 -      sb.append("│" + summary + " " * (maxLength - ls) + "│")
1823 -      if (report != null) {
1824 -        sb.append("\n│" + report + " " * (maxLength - report.length()) + "│")
1825 -      }
1826 -      allSummaries += sb.toString()
1827 -    }
1828 -
1829 -    println "┌${"${"─" * maxLength}"}┐"
1830 -    println allSummaries.join("\n├${"${"─" * maxLength}"}┤\n")
1831 -    println "└${"${"─" * maxLength}"}┘"
1832  }
1833 -/* END of test tasks results summary */
1834  
1835  
1836  task compileLinkCheck(type: JavaCompile) {
1837 @@ -2052,7 +543,7 @@ jar {
1838    manifest {
1839      attributes "Main-Class": main_class,
1840      "Permissions": "all-permissions",
1841 -    "Application-Name": applicationName,
1842 +    "Application-Name": install4jApplicationName,
1843      "Codebase": application_codebase,
1844      "Implementation-Version": JALVIEW_VERSION
1845    }
1846 @@ -2060,8 +551,6 @@ jar {
1847    def outputDir = "${jalviewDir}/${package_dir}"
1848    destinationDirectory = file(outputDir)
1849    archiveFileName = rootProject.name+".jar"
1850 -  duplicatesStrategy "EXCLUDE"
1851 -
1852  
1853    exclude "cache*/**"
1854    exclude "*.jar"
1855 @@ -2073,2137 +562,7 @@ jar {
1856    sourceSets.main.resources.srcDirs.each{ dir ->
1857      inputs.dir(dir)
1858    }
1859 -  outputs.file("${outputDir}/${archiveFileName}")
1860 -}
1861 -
1862 -
1863 -task copyJars(type: Copy) {
1864 -  from fileTree(dir: classesDir, include: "**/*.jar").files
1865 -  into "${jalviewDir}/${package_dir}"
1866 -}
1867 -
1868 -
1869 -// doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
1870 -task syncJars(type: Sync) {
1871 -  dependsOn jar
1872 -  from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
1873 -  into "${jalviewDir}/${package_dir}"
1874 -  preserve {
1875 -    include jar.archiveFileName.getOrNull()
1876 -  }
1877 -}
1878 -
1879 -
1880 -task makeDist {
1881 -  group = "build"
1882 -  description = "Put all required libraries in dist"
1883 -  // order of "cleanPackageDir", "copyJars", "jar" important!
1884 -  jar.mustRunAfter cleanPackageDir
1885 -  syncJars.mustRunAfter cleanPackageDir
1886 -  dependsOn cleanPackageDir
1887 -  dependsOn syncJars
1888 -  dependsOn jar
1889 -  outputs.dir("${jalviewDir}/${package_dir}")
1890 -}
1891 -
1892 -
1893 -task cleanDist {
1894 -  dependsOn cleanPackageDir
1895 -  dependsOn cleanTest
1896 -  dependsOn clean
1897 -}
1898 -
1899 -
1900 -shadowJar {
1901 -  group = "distribution"
1902 -  description = "Create a single jar file with all dependency libraries merged. Can be run with java -jar"
1903 -  if (buildDist) {
1904 -    dependsOn makeDist
1905 -  }
1906 -  from ("${jalviewDir}/${libDistDir}") {
1907 -    include("*.jar")
1908 -  }
1909 -  manifest {
1910 -    attributes "Implementation-Version": JALVIEW_VERSION,
1911 -    "Application-Name": applicationName
1912 -  }
1913 -
1914 -  duplicatesStrategy "INCLUDE"
1915 -
1916 -  mainClassName = shadow_jar_main_class
1917 -  mergeServiceFiles()
1918 -  classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
1919 -  minimize()
1920 -}
1921 -
1922 -task getdownImagesCopy() {
1923 -  inputs.dir getdownImagesDir
1924 -  outputs.dir getdownImagesBuildDir
1925 -
1926 -  doFirst {
1927 -    copy {
1928 -      from(getdownImagesDir) {
1929 -        include("*getdown*.png")
1930 -      }
1931 -      into getdownImagesBuildDir
1932 -    }
1933 -  }
1934 -}
1935 -
1936 -task getdownImagesProcess() {
1937 -  dependsOn getdownImagesCopy
1938 -
1939 -  doFirst {
1940 -    if (backgroundImageText) {
1941 -      if (convertBinary == null) {
1942 -        throw new StopExecutionException("No ImageMagick convert binary installed at '${convertBinaryExpectedLocation}'")
1943 -      }
1944 -      if (!project.hasProperty("getdown_background_image_text_suffix_cmd")) {
1945 -        throw new StopExecutionException("No property 'getdown_background_image_text_suffix_cmd' defined. See channel_gradle.properties for channel ${CHANNEL}")
1946 -      }
1947 -      fileTree(dir: getdownImagesBuildDir, include: "*background*.png").getFiles().each { file ->
1948 -        exec {
1949 -          executable convertBinary
1950 -          args = [
1951 -            file.getPath(),
1952 -            '-font', getdown_background_image_text_font,
1953 -            '-fill', getdown_background_image_text_colour,
1954 -            '-draw', sprintf(getdown_background_image_text_suffix_cmd, channelSuffix),
1955 -            '-draw', sprintf(getdown_background_image_text_commit_cmd, "git-commit: ${gitHash}"),
1956 -            '-draw', sprintf(getdown_background_image_text_date_cmd, getDate("yyyy-MM-dd HH:mm:ss")),
1957 -            file.getPath()
1958 -          ]
1959 -        }
1960 -      }
1961 -    }
1962 -  }
1963 -}
1964 -
1965 -task getdownImages() {
1966 -  dependsOn getdownImagesProcess
1967 -}
1968 -
1969 -task getdownWebsite() {
1970 -  group = "distribution"
1971 -  description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
1972 -
1973 -  dependsOn getdownImages
1974 -  if (buildDist) {
1975 -    dependsOn makeDist
1976 -  }
1977 -
1978 -  def getdownWebsiteResourceFilenames = []
1979 -  def getdownResourceDir = getdownResourceDir
1980 -  def getdownResourceFilenames = []
1981 -
1982 -  doFirst {
1983 -    // clean the getdown website and files dir before creating getdown folders
1984 -    delete getdownAppBaseDir
1985 -    delete getdownFilesDir
1986 -
1987 -    copy {
1988 -      from buildProperties
1989 -      rename(file(buildProperties).getName(), getdown_build_properties)
1990 -      into getdownAppDir
1991 -    }
1992 -    getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
1993 -
1994 -    copy {
1995 -      from channelPropsFile
1996 -      filter(ReplaceTokens,
1997 -        beginToken: '__',
1998 -        endToken: '__',
1999 -        tokens: [
2000 -          'SUFFIX': channelSuffix
2001 -        ]
2002 -      )
2003 -      into getdownAppBaseDir
2004 -    }
2005 -    getdownWebsiteResourceFilenames += file(channelPropsFile).getName()
2006 -
2007 -    // set some getdownTxt_ properties then go through all properties looking for getdownTxt_...
2008 -    def props = project.properties.sort { it.key }
2009 -    if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) {
2010 -      props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion)
2011 -    }
2012 -    if (getdownAltJavaMaxVersion != null && getdownAltJavaMaxVersion.length() > 0) {
2013 -      props.put("getdown_txt_java_max_version", getdownAltJavaMaxVersion)
2014 -    }
2015 -    if (getdownAltMultiJavaLocation != null && getdownAltMultiJavaLocation.length() > 0) {
2016 -      props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
2017 -    }
2018 -    if (getdownImagesBuildDir != null && file(getdownImagesBuildDir).exists()) {
2019 -      props.put("getdown_txt_ui.background_image", "${getdownImagesBuildDir}/${getdown_background_image}")
2020 -      props.put("getdown_txt_ui.instant_background_image", "${getdownImagesBuildDir}/${getdown_instant_background_image}")
2021 -      props.put("getdown_txt_ui.error_background", "${getdownImagesBuildDir}/${getdown_error_background}")
2022 -      props.put("getdown_txt_ui.progress_image", "${getdownImagesBuildDir}/${getdown_progress_image}")
2023 -      props.put("getdown_txt_ui.icon", "${getdownImagesDir}/${getdown_icon}")
2024 -      props.put("getdown_txt_ui.mac_dock_icon", "${getdownImagesDir}/${getdown_mac_dock_icon}")
2025 -    }
2026 -
2027 -    props.put("getdown_txt_title", jalview_name)
2028 -    props.put("getdown_txt_ui.name", applicationName)
2029 -
2030 -    // start with appbase
2031 -    getdownTextLines += "appbase = ${getdownAppBase}"
2032 -    props.each{ prop, val ->
2033 -      if (prop.startsWith("getdown_txt_") && val != null) {
2034 -        if (prop.startsWith("getdown_txt_multi_")) {
2035 -          def key = prop.substring(18)
2036 -          val.split(",").each{ v ->
2037 -            def line = "${key} = ${v}"
2038 -            getdownTextLines += line
2039 -          }
2040 -        } else {
2041 -          // file values rationalised
2042 -          if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
2043 -            def r = null
2044 -            if (val.indexOf('/') == 0) {
2045 -              // absolute path
2046 -              r = file(val)
2047 -            } else if (val.indexOf('/') > 0) {
2048 -              // relative path (relative to jalviewDir)
2049 -              r = file( "${jalviewDir}/${val}" )
2050 -            }
2051 -            if (r.exists()) {
2052 -              val = "${getdown_resource_dir}/" + r.getName()
2053 -              getdownWebsiteResourceFilenames += val
2054 -              getdownResourceFilenames += r.getPath()
2055 -            }
2056 -          }
2057 -          if (! prop.startsWith("getdown_txt_resource")) {
2058 -            def line = prop.substring(12) + " = ${val}"
2059 -            getdownTextLines += line
2060 -          }
2061 -        }
2062 -      }
2063 -    }
2064 -
2065 -    getdownWebsiteResourceFilenames.each{ filename ->
2066 -      getdownTextLines += "resource = ${filename}"
2067 -    }
2068 -    getdownResourceFilenames.each{ filename ->
2069 -      copy {
2070 -        from filename
2071 -        into getdownResourceDir
2072 -      }
2073 -    }
2074 -    
2075 -    def getdownWrapperScripts = [ getdown_bash_wrapper_script, getdown_powershell_wrapper_script, getdown_batch_wrapper_script ]
2076 -    getdownWrapperScripts.each{ script ->
2077 -      def s = file( "${jalviewDir}/utils/getdown/${getdown_wrapper_script_dir}/${script}" )
2078 -      if (s.exists()) {
2079 -        copy {
2080 -          from s
2081 -          into "${getdownAppBaseDir}/${getdown_wrapper_script_dir}"
2082 -        }
2083 -        getdownTextLines += "resource = ${getdown_wrapper_script_dir}/${script}"
2084 -      }
2085 -    }
2086 -
2087 -    def codeFiles = []
2088 -    fileTree(file(package_dir)).each{ f ->
2089 -      if (f.isDirectory()) {
2090 -        def files = fileTree(dir: f, include: ["*"]).getFiles()
2091 -        codeFiles += files
2092 -      } else if (f.exists()) {
2093 -        codeFiles += f
2094 -      }
2095 -    }
2096 -    def jalviewJar = jar.archiveFileName.getOrNull()
2097 -    // put jalview.jar first for CLASSPATH and .properties files reasons
2098 -    codeFiles.sort{a, b -> ( a.getName() == jalviewJar ? -1 : ( b.getName() == jalviewJar ? 1 : a <=> b ) ) }.each{f ->
2099 -      def name = f.getName()
2100 -      def line = "code = ${getdownAppDistDir}/${name}"
2101 -      getdownTextLines += line
2102 -      copy {
2103 -        from f.getPath()
2104 -        into getdownAppDir
2105 -      }
2106 -    }
2107 -
2108 -    // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
2109 -    /*
2110 -    if (JAVA_VERSION.equals("11")) {
2111 -    def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
2112 -    j11libFiles.sort().each{f ->
2113 -    def name = f.getName()
2114 -    def line = "code = ${getdown_j11lib_dir}/${name}"
2115 -    getdownTextLines += line
2116 -    copy {
2117 -    from f.getPath()
2118 -    into getdownJ11libDir
2119 -    }
2120 -    }
2121 -    }
2122 -     */
2123 -
2124 -    // 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.
2125 -    //getdownTextLines += "class = " + file(getdownLauncher).getName()
2126 -    getdownTextLines += "resource = ${getdown_launcher_new}"
2127 -    getdownTextLines += "class = ${main_class}"
2128 -    // Not setting these properties in general so that getdownappbase and getdowndistdir will default to release version in jalview.bin.Cache
2129 -    if (getdownSetAppBaseProperty) {
2130 -      getdownTextLines += "jvmarg = -Dgetdowndistdir=${getdownAppDistDir}"
2131 -      getdownTextLines += "jvmarg = -Dgetdownappbase=${getdownAppBase}"
2132 -    }
2133 -
2134 -    def getdownTxt = file("${getdownAppBaseDir}/getdown.txt")
2135 -    getdownTxt.write(getdownTextLines.join("\n"))
2136 -
2137 -    getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl"
2138 -    def launchJvl = file("${getdownAppBaseDir}/${getdownLaunchJvl}")
2139 -    launchJvl.write("appbase=${getdownAppBase}")
2140 -
2141 -    // files going into the getdown website dir: getdown-launcher.jar
2142 -    copy {
2143 -      from getdownLauncher
2144 -      rename(file(getdownLauncher).getName(), getdown_launcher_new)
2145 -      into getdownAppBaseDir
2146 -    }
2147 -
2148 -    // files going into the getdown website dir: getdown-launcher(-local).jar
2149 -    copy {
2150 -      from getdownLauncher
2151 -      if (file(getdownLauncher).getName() != getdown_launcher) {
2152 -        rename(file(getdownLauncher).getName(), getdown_launcher)
2153 -      }
2154 -      into getdownAppBaseDir
2155 -    }
2156 -
2157 -    // files going into the getdown website dir: ./install dir and files
2158 -    if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
2159 -      copy {
2160 -        from getdownTxt
2161 -        from getdownLauncher
2162 -        from "${getdownAppDir}/${getdown_build_properties}"
2163 -        if (file(getdownLauncher).getName() != getdown_launcher) {
2164 -          rename(file(getdownLauncher).getName(), getdown_launcher)
2165 -        }
2166 -        into getdownInstallDir
2167 -      }
2168 -
2169 -      // and make a copy in the getdown files dir (these are not downloaded by getdown)
2170 -      copy {
2171 -        from getdownInstallDir
2172 -        into getdownFilesInstallDir
2173 -      }
2174 -    }
2175 -
2176 -    // files going into the getdown files dir: getdown.txt, getdown-launcher.jar, channel-launch.jvl, build_properties
2177 -    copy {
2178 -      from getdownTxt
2179 -      from launchJvl
2180 -      from getdownLauncher
2181 -      from "${getdownAppBaseDir}/${getdown_build_properties}"
2182 -      from "${getdownAppBaseDir}/${channel_props}"
2183 -      if (file(getdownLauncher).getName() != getdown_launcher) {
2184 -        rename(file(getdownLauncher).getName(), getdown_launcher)
2185 -      }
2186 -      into getdownFilesDir
2187 -    }
2188 -
2189 -    // and ./resource (not all downloaded by getdown)
2190 -    copy {
2191 -      from getdownResourceDir
2192 -      into "${getdownFilesDir}/${getdown_resource_dir}"
2193 -    }
2194 -  }
2195 -
2196 -  if (buildDist) {
2197 -    inputs.dir("${jalviewDir}/${package_dir}")
2198 -  }
2199 -  outputs.dir(getdownAppBaseDir)
2200 -  outputs.dir(getdownFilesDir)
2201 -}
2202 -
2203 -
2204 -// a helper task to allow getdown digest of any dir: `gradle getdownDigestDir -PDIGESTDIR=/path/to/my/random/getdown/dir
2205 -task getdownDigestDir(type: JavaExec) {
2206 -  group "Help"
2207 -  description "A task to run a getdown Digest on a dir with getdown.txt. Provide a DIGESTDIR property via -PDIGESTDIR=..."
2208 -
2209 -  def digestDirPropertyName = "DIGESTDIR"
2210 -  doFirst {
2211 -    classpath = files(getdownLauncher)
2212 -    def digestDir = findProperty(digestDirPropertyName)
2213 -    if (digestDir == null) {
2214 -      throw new GradleException("Must provide a DIGESTDIR value to produce an alternative getdown digest")
2215 -    }
2216 -    args digestDir
2217 -  }
2218 -  main = "com.threerings.getdown.tools.Digester"
2219 -}
2220 -
2221 -
2222 -task getdownDigest(type: JavaExec) {
2223 -  group = "distribution"
2224 -  description = "Digest the getdown website folder"
2225 -  dependsOn getdownWebsite
2226 -  doFirst {
2227 -    classpath = files(getdownLauncher)
2228 -  }
2229 -  main = "com.threerings.getdown.tools.Digester"
2230 -  args getdownAppBaseDir
2231 -  inputs.dir(getdownAppBaseDir)
2232 -  outputs.file("${getdownAppBaseDir}/digest2.txt")
2233 -}
2234 -
2235 -
2236 -task getdown() {
2237 -  group = "distribution"
2238 -  description = "Create the minimal and full getdown app folder for installers and website and create digest file"
2239 -  dependsOn getdownDigest
2240 -  doLast {
2241 -    if (reportRsyncCommand) {
2242 -      def fromDir = getdownAppBaseDir + (getdownAppBaseDir.endsWith('/')?'':'/')
2243 -      def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
2244 -      println "LIKELY RSYNC COMMAND:"
2245 -      println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
2246 -      if (RUNRSYNC == "true") {
2247 -        exec {
2248 -          commandLine "mkdir", "-p", toDir
2249 -        }
2250 -        exec {
2251 -          commandLine "rsync", "-avh", "--delete", fromDir, toDir
2252 -        }
2253 -      }
2254 -    }
2255 -  }
2256 -}
2257  
2258 -
2259 -task getdownArchiveBuild() {
2260 -  group = "distribution"
2261 -  description = "Put files in the archive dir to go on the website"
2262 -
2263 -  dependsOn getdownWebsite
2264 -
2265 -  def v = "v${JALVIEW_VERSION_UNDERSCORES}"
2266 -  def vDir = "${getdownArchiveDir}/${v}"
2267 -  getdownFullArchiveDir = "${vDir}/getdown"
2268 -  getdownVersionLaunchJvl = "${vDir}/jalview-${v}.jvl"
2269 -
2270 -  def vAltDir = "alt_${v}"
2271 -  def archiveImagesDir = "${jalviewDir}/${channel_properties_dir}/old/images"
2272 -
2273 -  doFirst {
2274 -    // cleanup old "old" dir
2275 -    delete getdownArchiveDir
2276 -
2277 -    def getdownArchiveTxt = file("${getdownFullArchiveDir}/getdown.txt")
2278 -    getdownArchiveTxt.getParentFile().mkdirs()
2279 -    def getdownArchiveTextLines = []
2280 -    def getdownFullArchiveAppBase = "${getdownArchiveAppBase}${getdownArchiveAppBase.endsWith("/")?"":"/"}${v}/getdown/"
2281 -
2282 -    // the libdir
2283 -    copy {
2284 -      from "${getdownAppBaseDir}/${getdownAppDistDir}"
2285 -      into "${getdownFullArchiveDir}/${vAltDir}"
2286 -    }
2287 -
2288 -    getdownTextLines.each { line ->
2289 -      line = line.replaceAll("^(?<s>appbase\\s*=\\s*).*", '${s}'+getdownFullArchiveAppBase)
2290 -      line = line.replaceAll("^(?<s>(resource|code)\\s*=\\s*)${getdownAppDistDir}/", '${s}'+vAltDir+"/")
2291 -      line = line.replaceAll("^(?<s>ui.background_image\\s*=\\s*).*\\.png", '${s}'+"${getdown_resource_dir}/jalview_archive_getdown_background.png")
2292 -      line = line.replaceAll("^(?<s>ui.instant_background_image\\s*=\\s*).*\\.png", '${s}'+"${getdown_resource_dir}/jalview_archive_getdown_background_initialising.png")
2293 -      line = line.replaceAll("^(?<s>ui.error_background\\s*=\\s*).*\\.png", '${s}'+"${getdown_resource_dir}/jalview_archive_getdown_background_error.png")
2294 -      line = line.replaceAll("^(?<s>ui.progress_image\\s*=\\s*).*\\.png", '${s}'+"${getdown_resource_dir}/jalview_archive_getdown_progress_bar.png")
2295 -      // remove the existing resource = resource/ or bin/ lines
2296 -      if (! line.matches("resource\\s*=\\s*(resource|bin)/.*")) {
2297 -        getdownArchiveTextLines += line
2298 -      }
2299 -    }
2300 -
2301 -    // the resource dir -- add these files as resource lines in getdown.txt
2302 -    copy {
2303 -      from "${archiveImagesDir}"
2304 -      into "${getdownFullArchiveDir}/${getdown_resource_dir}"
2305 -      eachFile { file ->
2306 -        getdownArchiveTextLines += "resource = ${getdown_resource_dir}/${file.getName()}"
2307 -      }
2308 -    }
2309 -
2310 -    getdownArchiveTxt.write(getdownArchiveTextLines.join("\n"))
2311 -
2312 -    def vLaunchJvl = file(getdownVersionLaunchJvl)
2313 -    vLaunchJvl.getParentFile().mkdirs()
2314 -    vLaunchJvl.write("appbase=${getdownFullArchiveAppBase}\n")
2315 -    def vLaunchJvlPath = vLaunchJvl.toPath().toAbsolutePath()
2316 -    def jvlLinkPath = file("${vDir}/jalview.jvl").toPath().toAbsolutePath()
2317 -    // for some reason filepath.relativize(fileInSameDirPath) gives a path to "../" which is wrong
2318 -    //java.nio.file.Files.createSymbolicLink(jvlLinkPath, jvlLinkPath.relativize(vLaunchJvlPath));
2319 -    java.nio.file.Files.createSymbolicLink(jvlLinkPath, java.nio.file.Paths.get(".",vLaunchJvl.getName()));
2320 -
2321 -    // files going into the getdown files dir: getdown.txt, getdown-launcher.jar, channel-launch.jvl, build_properties
2322 -    copy {
2323 -      from getdownLauncher
2324 -      from "${getdownAppBaseDir}/${getdownLaunchJvl}"
2325 -      from "${getdownAppBaseDir}/${getdown_launcher_new}"
2326 -      from "${getdownAppBaseDir}/${channel_props}"
2327 -      if (file(getdownLauncher).getName() != getdown_launcher) {
2328 -        rename(file(getdownLauncher).getName(), getdown_launcher)
2329 -      }
2330 -      into getdownFullArchiveDir
2331 -    }
2332 -
2333 -  }
2334 -}
2335 -
2336 -task getdownArchiveDigest(type: JavaExec) {
2337 -  group = "distribution"
2338 -  description = "Digest the getdown archive folder"
2339 -
2340 -  dependsOn getdownArchiveBuild
2341 -
2342 -  doFirst {
2343 -    classpath = files(getdownLauncher)
2344 -    args getdownFullArchiveDir
2345 -  }
2346 -  main = "com.threerings.getdown.tools.Digester"
2347 -  inputs.dir(getdownFullArchiveDir)
2348 -  outputs.file("${getdownFullArchiveDir}/digest2.txt")
2349 -}
2350 -
2351 -task getdownArchive() {
2352 -  group = "distribution"
2353 -  description = "Build the website archive dir with getdown digest"
2354 -
2355 -  dependsOn getdownArchiveBuild
2356 -  dependsOn getdownArchiveDigest
2357 -}
2358 -
2359 -tasks.withType(JavaCompile) {
2360 -       options.encoding = 'UTF-8'
2361 -}
2362 -
2363 -
2364 -clean {
2365 -  doFirst {
2366 -    delete getdownAppBaseDir
2367 -    delete getdownFilesDir
2368 -    delete getdownArchiveDir
2369 -  }
2370 -}
2371 -
2372 -
2373 -install4j {
2374 -  if (file(install4jHomeDir).exists()) {
2375 -    // good to go!
2376 -  } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
2377 -    install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
2378 -  } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
2379 -    install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
2380 -  }
2381 -  installDir(file(install4jHomeDir))
2382 -
2383 -  mediaTypes = Arrays.asList(install4j_media_types.split(","))
2384 -}
2385 -
2386 -
2387 -task copyInstall4jTemplate {
2388 -  def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
2389 -  def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
2390 -  inputs.file(install4jTemplateFile)
2391 -  inputs.file(install4jFileAssociationsFile)
2392 -  inputs.property("CHANNEL", { CHANNEL })
2393 -  outputs.file(install4jConfFile)
2394 -
2395 -  doLast {
2396 -    def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
2397 -
2398 -    // turn off code signing if no OSX_KEYPASS
2399 -    if (OSX_KEYPASS == "") {
2400 -      install4jConfigXml.'**'.codeSigning.each { codeSigning ->
2401 -        codeSigning.'@macEnabled' = "false"
2402 -      }
2403 -      install4jConfigXml.'**'.windows.each { windows ->
2404 -        windows.'@runPostProcessor' = "false"
2405 -      }
2406 -    }
2407 -
2408 -    // disable install screen for OSX dmg (for 2.11.2.0)
2409 -    install4jConfigXml.'**'.macosArchive.each { macosArchive -> 
2410 -      macosArchive.attributes().remove('executeSetupApp')
2411 -      macosArchive.attributes().remove('setupAppId')
2412 -    }
2413 -
2414 -    // turn off checksum creation for LOCAL channel
2415 -    def e = install4jConfigXml.application[0]
2416 -    e.'@createChecksums' = string(install4jCheckSums)
2417 -
2418 -    // put file association actions where placeholder action is
2419 -    def install4jFileAssociationsText = install4jFileAssociationsFile.text
2420 -    def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
2421 -    install4jConfigXml.'**'.action.any { a -> // .any{} stops after the first one that returns true
2422 -      if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
2423 -        def parent = a.parent()
2424 -        parent.remove(a)
2425 -        fileAssociationActions.each { faa ->
2426 -            parent.append(faa)
2427 -        }
2428 -        // don't need to continue in .any loop once replacements have been made
2429 -        return true
2430 -      }
2431 -    }
2432 -
2433 -    // use Windows Program Group with Examples folder for RELEASE, and Program Group without Examples for everything else
2434 -    // NB we're deleting the /other/ one!
2435 -    // Also remove the examples subdir from non-release versions
2436 -    def customizedIdToDelete = "PROGRAM_GROUP_RELEASE"
2437 -    // 2.11.1.0 NOT releasing with the Examples folder in the Program Group
2438 -    if (false && CHANNEL=="RELEASE") { // remove 'false && ' to include Examples folder in RELEASE channel
2439 -      customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE"
2440 -    } else {
2441 -      // remove the examples subdir from Full File Set
2442 -      def files = install4jConfigXml.files[0]
2443 -      def fileset = files.filesets.fileset.find { fs -> fs.'@customizedId' == "FULL_FILE_SET" }
2444 -      def root = files.roots.root.find { r -> r.'@fileset' == fileset.'@id' }
2445 -      def mountPoint = files.mountPoints.mountPoint.find { mp -> mp.'@root' == root.'@id' }
2446 -      def dirEntry = files.entries.dirEntry.find { de -> de.'@mountPoint' == mountPoint.'@id' && de.'@subDirectory' == "examples" }
2447 -      dirEntry.parent().remove(dirEntry)
2448 -    }
2449 -    install4jConfigXml.'**'.action.any { a ->
2450 -      if (a.'@customizedId' == customizedIdToDelete) {
2451 -        def parent = a.parent()
2452 -        parent.remove(a)
2453 -        return true
2454 -      }
2455 -    }
2456 -
2457 -    // write install4j file
2458 -    install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
2459 -  }
2460 -}
2461 -
2462 -
2463 -clean {
2464 -  doFirst {
2465 -    delete install4jConfFile
2466 -  }
2467 -}
2468 -
2469 -task cleanInstallersDataFiles {
2470 -  def installersOutputTxt = file("${jalviewDir}/${install4jBuildDir}/output.txt")
2471 -  def installersSha256 = file("${jalviewDir}/${install4jBuildDir}/sha256sums")
2472 -  def hugoDataJsonFile = file("${jalviewDir}/${install4jBuildDir}/installers-${JALVIEW_VERSION_UNDERSCORES}.json")
2473 -  doFirst {
2474 -    delete installersOutputTxt
2475 -    delete installersSha256
2476 -    delete hugoDataJsonFile
2477 -  }
2478 -}
2479 -
2480 -task install4jDMGBackgroundImageCopy {
2481 -  inputs.file "${install4jDMGBackgroundImageDir}/${install4jDMGBackgroundImageFile}"
2482 -  outputs.dir "${install4jDMGBackgroundImageBuildDir}"
2483 -  doFirst {
2484 -    copy {
2485 -      from(install4jDMGBackgroundImageDir) {
2486 -        include(install4jDMGBackgroundImageFile)
2487 -      }
2488 -      into install4jDMGBackgroundImageBuildDir
2489 -    }
2490 -  }
2491 -}
2492 -
2493 -task install4jDMGBackgroundImageProcess {
2494 -  dependsOn install4jDMGBackgroundImageCopy
2495 -
2496 -  doFirst {
2497 -    if (backgroundImageText) {
2498 -      if (convertBinary == null) {
2499 -        throw new StopExecutionException("No ImageMagick convert binary installed at '${convertBinaryExpectedLocation}'")
2500 -      }
2501 -      if (!project.hasProperty("install4j_background_image_text_suffix_cmd")) {
2502 -        throw new StopExecutionException("No property 'install4j_background_image_text_suffix_cmd' defined. See channel_gradle.properties for channel ${CHANNEL}")
2503 -      }
2504 -      fileTree(dir: install4jDMGBackgroundImageBuildDir, include: "*.png").getFiles().each { file ->
2505 -        exec {
2506 -          executable convertBinary
2507 -          args = [
2508 -            file.getPath(),
2509 -            '-font', install4j_background_image_text_font,
2510 -            '-fill', install4j_background_image_text_colour,
2511 -            '-draw', sprintf(install4j_background_image_text_suffix_cmd, channelSuffix),
2512 -            '-draw', sprintf(install4j_background_image_text_commit_cmd, "git-commit: ${gitHash}"),
2513 -            '-draw', sprintf(install4j_background_image_text_date_cmd, getDate("yyyy-MM-dd HH:mm:ss")),
2514 -            file.getPath()
2515 -          ]
2516 -        }
2517 -      }
2518 -    }
2519 -  }
2520 -}
2521 -
2522 -task install4jDMGBackgroundImage {
2523 -  dependsOn install4jDMGBackgroundImageProcess
2524 -}
2525 -
2526 -task installerFiles(type: com.install4j.gradle.Install4jTask) {
2527 -  group = "distribution"
2528 -  description = "Create the install4j installers"
2529 -  dependsOn getdown
2530 -  dependsOn copyInstall4jTemplate
2531 -  dependsOn cleanInstallersDataFiles
2532 -  dependsOn install4jDMGBackgroundImage
2533 -
2534 -  projectFile = install4jConfFile
2535 -
2536 -  // create an md5 for the input files to use as version for install4j conf file
2537 -  def digest = MessageDigest.getInstance("MD5")
2538 -  digest.update(
2539 -    (file("${install4jDir}/${install4j_template}").text + 
2540 -    file("${install4jDir}/${install4j_info_plist_file_associations}").text +
2541 -    file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
2542 -  def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
2543 -  if (filesMd5.length() >= 8) {
2544 -    filesMd5 = filesMd5.substring(0,8)
2545 -  }
2546 -  def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
2547 -
2548 -  variables = [
2549 -    'JALVIEW_NAME': jalview_name,
2550 -    'JALVIEW_APPLICATION_NAME': applicationName,
2551 -    'JALVIEW_DIR': "../..",
2552 -    'OSX_KEYSTORE': OSX_KEYSTORE,
2553 -    'OSX_APPLEID': OSX_APPLEID,
2554 -    'OSX_ALTOOLPASS': OSX_ALTOOLPASS,
2555 -    'JSIGN_SH': JSIGN_SH,
2556 -    'JRE_DIR': getdown_app_dir_java,
2557 -    'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
2558 -    'JALVIEW_VERSION': JALVIEW_VERSION,
2559 -    'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
2560 -    'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
2561 -    'JAVA_VERSION': JAVA_VERSION,
2562 -    'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
2563 -    'VERSION': JALVIEW_VERSION,
2564 -    'COPYRIGHT_MESSAGE': install4j_copyright_message,
2565 -    'BUNDLE_ID': install4jBundleId,
2566 -    'INTERNAL_ID': install4jInternalId,
2567 -    'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
2568 -    'MACOS_DMG_DS_STORE': install4jDMGDSStore,
2569 -    'MACOS_DMG_BG_IMAGE': "${install4jDMGBackgroundImageBuildDir}/${install4jDMGBackgroundImageFile}",
2570 -    'WRAPPER_LINK': getdownWrapperLink,
2571 -    'BASH_WRAPPER_SCRIPT': getdown_bash_wrapper_script,
2572 -    'POWERSHELL_WRAPPER_SCRIPT': getdown_powershell_wrapper_script,
2573 -    'BATCH_WRAPPER_SCRIPT': getdown_batch_wrapper_script,
2574 -    'WRAPPER_SCRIPT_BIN_DIR': getdown_wrapper_script_dir,
2575 -    'INSTALLER_NAME': install4jInstallerName,
2576 -    'INSTALL4J_UTILS_DIR': install4j_utils_dir,
2577 -    'GETDOWN_CHANNEL_DIR': getdownChannelDir,
2578 -    'GETDOWN_FILES_DIR': getdown_files_dir,
2579 -    'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
2580 -    'GETDOWN_DIST_DIR': getdownAppDistDir,
2581 -    'GETDOWN_ALT_DIR': getdown_app_dir_alt,
2582 -    'GETDOWN_INSTALL_DIR': getdown_install_dir,
2583 -    'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
2584 -    'BUILD_DIR': install4jBuildDir,
2585 -    'APPLICATION_CATEGORIES': install4j_application_categories,
2586 -    'APPLICATION_FOLDER': install4jApplicationFolder,
2587 -    'UNIX_APPLICATION_FOLDER': install4jUnixApplicationFolder,
2588 -    'EXECUTABLE_NAME': install4jExecutableName,
2589 -    'EXTRA_SCHEME': install4jExtraScheme,
2590 -    'MAC_ICONS_FILE': install4jMacIconsFile,
2591 -    'WINDOWS_ICONS_FILE': install4jWindowsIconsFile,
2592 -    'PNG_ICON_FILE': install4jPngIconFile,
2593 -    'BACKGROUND': install4jBackground,
2594 -  ]
2595 -
2596 -  def varNameMap = [
2597 -    'mac': 'MACOS',
2598 -    'windows': 'WINDOWS',
2599 -    'linux': 'LINUX'
2600 -  ]
2601 -  
2602 -  // these are the bundled OS/architecture VMs needed by install4j
2603 -  def osArch = [
2604 -    [ "mac", "x64" ],
2605 -    [ "mac", "aarch64" ],
2606 -    [ "windows", "x64" ],
2607 -    [ "linux", "x64" ],
2608 -    [ "linux", "aarch64" ]
2609 -  ]
2610 -  osArch.forEach { os, arch ->
2611 -    variables[ sprintf("%s_%s_JAVA_VM_DIR", varNameMap[os], arch.toUpperCase(Locale.ROOT)) ] = sprintf("%s/jre-%s-%s-%s/jre", jreInstallsDir, JAVA_INTEGER_VERSION, os, arch)
2612 -    // N.B. For some reason install4j requires the below filename to have underscores and not hyphens
2613 -    // otherwise running `gradle installers` generates a non-useful error:
2614 -    // `install4j: compilation failed. Reason: java.lang.NumberFormatException: For input string: "windows"`
2615 -    variables[ sprintf("%s_%s_JAVA_VM_TGZ", varNameMap[os], arch.toUpperCase(Locale.ROOT)) ] = sprintf("%s/tgz/jre_%s_%s_%s.tar.gz", jreInstallsDir, JAVA_INTEGER_VERSION, os, arch)
2616 -  }
2617 -
2618 -  //println("INSTALL4J VARIABLES:")
2619 -  //variables.each{k,v->println("${k}=${v}")}
2620 -
2621 -  destination = "${jalviewDir}/${install4jBuildDir}"
2622 -  buildSelected = true
2623 -
2624 -  if (install4j_faster.equals("true") || CHANNEL.startsWith("LOCAL")) {
2625 -    faster = true
2626 -    disableSigning = true
2627 -    disableNotarization = true
2628 -  }
2629 -
2630 -  if (OSX_KEYPASS) {
2631 -    macKeystorePassword = OSX_KEYPASS
2632 -  } 
2633 -  
2634 -  if (OSX_ALTOOLPASS) {
2635 -    appleIdPassword = OSX_ALTOOLPASS
2636 -    disableNotarization = false
2637 -  } else {
2638 -    disableNotarization = true
2639 -  }
2640 -
2641 -  doFirst {
2642 -    println("Using projectFile "+projectFile)
2643 -    if (!disableNotarization) { println("Will notarize OSX App DMG") }
2644 -  }
2645 -  //verbose=true
2646 -
2647 -  inputs.dir(getdownAppBaseDir)
2648 -  inputs.file(install4jConfFile)
2649 -  inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
2650 -  outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
2651 -}
2652 -
2653 -def getDataHash(File myFile) {
2654 -  HashCode hash = Files.asByteSource(myFile).hash(Hashing.sha256())
2655 -  return myFile.exists()
2656 -  ? [
2657 -      "file" : myFile.getName(),
2658 -      "filesize" : myFile.length(),
2659 -      "sha256" : hash.toString()
2660 -    ]
2661 -  : null
2662 -}
2663 -
2664 -def writeDataJsonFile(File installersOutputTxt, File installersSha256, File dataJsonFile) {
2665 -  def hash = [
2666 -    "channel" : getdownChannelName,
2667 -    "date" : getDate("yyyy-MM-dd HH:mm:ss"),
2668 -    "git-commit" : "${gitHash} [${gitBranch}]",
2669 -    "version" : JALVIEW_VERSION
2670 -  ]
2671 -  // install4j installer files
2672 -  if (installersOutputTxt.exists()) {
2673 -    def idHash = [:]
2674 -    installersOutputTxt.readLines().each { def line ->
2675 -      if (line.startsWith("#")) {
2676 -        return;
2677 -      }
2678 -      line.replaceAll("\n","")
2679 -      def vals = line.split("\t")
2680 -      def filename = vals[3]
2681 -      def filesize = file(filename).length()
2682 -      filename = filename.replaceAll(/^.*\//, "")
2683 -      hash[vals[0]] = [ "id" : vals[0], "os" : vals[1], "name" : vals[2], "file" : filename, "filesize" : filesize ]
2684 -      idHash."${filename}" = vals[0]
2685 -    }
2686 -    if (install4jCheckSums && installersSha256.exists()) {
2687 -      installersSha256.readLines().each { def line ->
2688 -        if (line.startsWith("#")) {
2689 -          return;
2690 -        }
2691 -        line.replaceAll("\n","")
2692 -        def vals = line.split(/\s+\*?/)
2693 -        def filename = vals[1]
2694 -        def innerHash = (hash.(idHash."${filename}"))."sha256" = vals[0]
2695 -      }
2696 -    }
2697 -  }
2698 -
2699 -  [
2700 -    "JAR": shadowJar.archiveFile, // executable JAR
2701 -    "JVL": getdownVersionLaunchJvl, // version JVL
2702 -    "SOURCE": sourceDist.archiveFile // source TGZ
2703 -  ].each { key, value ->
2704 -    def file = file(value)
2705 -    if (file.exists()) {
2706 -      def fileHash = getDataHash(file)
2707 -      if (fileHash != null) {
2708 -        hash."${key}" = fileHash;
2709 -      }
2710 -    }
2711 -  }
2712 -  return dataJsonFile.write(new JsonBuilder(hash).toPrettyString())
2713 -}
2714 -
2715 -task staticMakeInstallersJsonFile {
2716 -  doFirst {
2717 -    def output = findProperty("i4j_output")
2718 -    def sha256 = findProperty("i4j_sha256")
2719 -    def json = findProperty("i4j_json")
2720 -    if (output == null || sha256 == null || json == null) {
2721 -      throw new GradleException("Must provide paths to all of output.txt, sha256sums, and output.json with '-Pi4j_output=... -Pi4j_sha256=... -Pi4j_json=...")
2722 -    }
2723 -    writeDataJsonFile(file(output), file(sha256), file(json))
2724 -  }
2725 -}
2726 -
2727 -task installers {
2728 -  dependsOn installerFiles
2729 -}
2730 -
2731 -
2732 -spotless {
2733 -  java {
2734 -    eclipse().configFile(eclipse_codestyle_file)
2735 -  }
2736 -}
2737 -
2738 -task createSourceReleaseProperties(type: WriteProperties) {
2739 -  group = "distribution"
2740 -  description = "Create the source RELEASE properties file"
2741 -  
2742 -  def sourceTarBuildDir = "${buildDir}/sourceTar"
2743 -  def sourceReleasePropertiesFile = "${sourceTarBuildDir}/RELEASE"
2744 -  outputFile (sourceReleasePropertiesFile)
2745 -
2746 -  doFirst {
2747 -    releaseProps.each{ key, val -> property key, val }
2748 -    property "git.branch", gitBranch
2749 -    property "git.hash", gitHash
2750 -  }
2751 -
2752 -  outputs.file(outputFile)
2753 -}
2754 -
2755 -task sourceDist(type: Tar) {
2756 -  group "distribution"
2757 -  description "Create a source .tar.gz file for distribution"
2758 -
2759 -  dependsOn createBuildProperties
2760 -  dependsOn convertMdFiles
2761 -  dependsOn eclipseAllPreferences
2762 -  dependsOn createSourceReleaseProperties
2763 -
2764 -
2765 -  def outputFileName = "${project.name}_${JALVIEW_VERSION_UNDERSCORES}.tar.gz"
2766 -  archiveFileName = outputFileName
2767 -  
2768 -  compression Compression.GZIP
2769 -  
2770 -  into project.name
2771 -
2772 -  def EXCLUDE_FILES=[
2773 -    "build/*",
2774 -    "bin/*",
2775 -    "test-output/",
2776 -    "test-reports",
2777 -    "tests",
2778 -    "clover*/*",
2779 -    ".*",
2780 -    "benchmarking/*",
2781 -    "**/.*",
2782 -    "*.class",
2783 -    "**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales",
2784 -    "*locales/**",
2785 -    "utils/InstallAnywhere",
2786 -    "**/*.log",
2787 -    "RELEASE",
2788 -  ] 
2789 -  def PROCESS_FILES=[
2790 -    "AUTHORS",
2791 -    "CITATION",
2792 -    "FEATURETODO",
2793 -    "JAVA-11-README",
2794 -    "FEATURETODO",
2795 -    "LICENSE",
2796 -    "**/README",
2797 -    "THIRDPARTYLIBS",
2798 -    "TESTNG",
2799 -    "build.gradle",
2800 -    "gradle.properties",
2801 -    "**/*.java",
2802 -    "**/*.html",
2803 -    "**/*.xml",
2804 -    "**/*.gradle",
2805 -    "**/*.groovy",
2806 -    "**/*.properties",
2807 -    "**/*.perl",
2808 -    "**/*.sh",
2809 -  ]
2810 -  def INCLUDE_FILES=[
2811 -    ".classpath",
2812 -    ".settings/org.eclipse.buildship.core.prefs",
2813 -    ".settings/org.eclipse.jdt.core.prefs"
2814 -  ]
2815 -
2816 -  from(jalviewDir) {
2817 -    exclude (EXCLUDE_FILES)
2818 -    include (PROCESS_FILES)
2819 -    filter(ReplaceTokens,
2820 -      beginToken: '$$',
2821 -      endToken: '$$',
2822 -      tokens: [
2823 -        'Version-Rel': JALVIEW_VERSION,
2824 -        'Year-Rel': getDate("yyyy")
2825 -      ]
2826 -    )
2827 -  }
2828 -  from(jalviewDir) {
2829 -    exclude (EXCLUDE_FILES)
2830 -    exclude (PROCESS_FILES)
2831 -    exclude ("appletlib")
2832 -    exclude ("**/*locales")
2833 -    exclude ("*locales/**")
2834 -    exclude ("utils/InstallAnywhere")
2835 -
2836 -    exclude (getdown_files_dir)
2837 -    // getdown_website_dir and getdown_archive_dir moved to build/website/docroot/getdown
2838 -    //exclude (getdown_website_dir)
2839 -    //exclude (getdown_archive_dir)
2840 -
2841 -    // exluding these as not using jars as modules yet
2842 -    exclude ("${j11modDir}/**/*.jar")
2843 -  }
2844 -  from(jalviewDir) {
2845 -    include(INCLUDE_FILES)
2846 -  }
2847 -//  from (jalviewDir) {
2848 -//    // explicit includes for stuff that seemed to not get included
2849 -//    include(fileTree("test/**/*."))
2850 -//    exclude(EXCLUDE_FILES)
2851 -//    exclude(PROCESS_FILES)
2852 -//  }
2853 -
2854 -  from(file(buildProperties).getParent()) {
2855 -    include(file(buildProperties).getName())
2856 -    rename(file(buildProperties).getName(), "build_properties")
2857 -    filter({ line ->
2858 -      line.replaceAll("^INSTALLATION=.*\$","INSTALLATION=Source Release"+" git-commit\\\\:"+gitHash+" ["+gitBranch+"]")
2859 -    })
2860 -  }
2861 -
2862 -  def sourceTarBuildDir = "${buildDir}/sourceTar"
2863 -  from(sourceTarBuildDir) {
2864 -    // this includes the appended RELEASE properties file
2865 -  }
2866 -}
2867 -
2868 -task dataInstallersJson {
2869 -  group "website"
2870 -  description "Create the installers-VERSION.json data file for installer files created"
2871 -
2872 -  mustRunAfter installers
2873 -  mustRunAfter shadowJar
2874 -  mustRunAfter sourceDist
2875 -  mustRunAfter getdownArchive
2876 -
2877 -  def installersOutputTxt = file("${jalviewDir}/${install4jBuildDir}/output.txt")
2878 -  def installersSha256 = file("${jalviewDir}/${install4jBuildDir}/sha256sums")
2879 -
2880 -  if (installersOutputTxt.exists()) {
2881 -    inputs.file(installersOutputTxt)
2882 -  }
2883 -  if (install4jCheckSums && installersSha256.exists()) {
2884 -    inputs.file(installersSha256)
2885 -  }
2886 -  [
2887 -    shadowJar.archiveFile, // executable JAR
2888 -    getdownVersionLaunchJvl, // version JVL
2889 -    sourceDist.archiveFile // source TGZ
2890 -  ].each { fileName ->
2891 -    if (file(fileName).exists()) {
2892 -      inputs.file(fileName)
2893 -    }
2894 -  }
2895 -
2896 -  outputs.file(hugoDataJsonFile)
2897 -
2898 -  doFirst {
2899 -    writeDataJsonFile(installersOutputTxt, installersSha256, hugoDataJsonFile)
2900 -  }
2901 -}
2902 -
2903 -task helppages {
2904 -  group "help"
2905 -  description "Copies all help pages to build dir. Runs ant task 'pubhtmlhelp'."
2906 -
2907 -  dependsOn copyHelp
2908 -  dependsOn pubhtmlhelp
2909 -  
2910 -  inputs.dir("${helpBuildDir}/${help_dir}")
2911 -  outputs.dir("${buildDir}/distributions/${help_dir}")
2912 -}
2913 -
2914 -
2915 -task j2sSetHeadlessBuild {
2916 -  doFirst {
2917 -    IN_ECLIPSE = false
2918 -  }
2919 -}
2920 -
2921 -
2922 -task jalviewjsEnableAltFileProperty(type: WriteProperties) {
2923 -  group "jalviewjs"
2924 -  description "Enable the alternative J2S Config file for headless build"
2925 -
2926 -  outputFile = jalviewjsJ2sSettingsFileName
2927 -  def j2sPropsFile = file(jalviewjsJ2sSettingsFileName)
2928 -  def j2sProps = new Properties()
2929 -  if (j2sPropsFile.exists()) {
2930 -    try {
2931 -      def j2sPropsFileFIS = new FileInputStream(j2sPropsFile)
2932 -      j2sProps.load(j2sPropsFileFIS)
2933 -      j2sPropsFileFIS.close()
2934 -
2935 -      j2sProps.each { prop, val ->
2936 -        property(prop, val)
2937 -      }
2938 -    } catch (Exception e) {
2939 -      println("Exception reading ${jalviewjsJ2sSettingsFileName}")
2940 -      e.printStackTrace()
2941 -    }
2942 -  }
2943 -  if (! j2sProps.stringPropertyNames().contains(jalviewjs_j2s_alt_file_property_config)) {
2944 -    property(jalviewjs_j2s_alt_file_property_config, jalviewjs_j2s_alt_file_property)
2945 -  }
2946 -}
2947 -
2948 -
2949 -task jalviewjsSetEclipseWorkspace {
2950 -  def propKey = "jalviewjs_eclipse_workspace"
2951 -  def propVal = null
2952 -  if (project.hasProperty(propKey)) {
2953 -    propVal = project.getProperty(propKey)
2954 -    if (propVal.startsWith("~/")) {
2955 -      propVal = System.getProperty("user.home") + propVal.substring(1)
2956 -    }
2957 -  }
2958 -  def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
2959 -  def propsFile = file(propsFileName)
2960 -  def eclipseWsDir = propVal
2961 -  def props = new Properties()
2962 -
2963 -  def writeProps = true
2964 -  if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
2965 -    def ins = new FileInputStream(propsFileName)
2966 -    props.load(ins)
2967 -    ins.close()
2968 -    if (props.getProperty(propKey, null) != null) {
2969 -      eclipseWsDir = props.getProperty(propKey)
2970 -      writeProps = false
2971 -    }
2972 -  }
2973 -
2974 -  if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
2975 -    def tempDir = File.createTempDir()
2976 -    eclipseWsDir = tempDir.getAbsolutePath()
2977 -    writeProps = true
2978 -  }
2979 -  eclipseWorkspace = file(eclipseWsDir)
2980 -
2981 -  doFirst {
2982 -    // do not run a headless transpile when we claim to be in Eclipse
2983 -    if (IN_ECLIPSE) {
2984 -      println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2985 -      throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
2986 -    } else {
2987 -      println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2988 -    }
2989 -
2990 -    if (writeProps) {
2991 -      props.setProperty(propKey, eclipseWsDir)
2992 -      propsFile.parentFile.mkdirs()
2993 -      def bytes = new ByteArrayOutputStream()
2994 -      props.store(bytes, null)
2995 -      def propertiesString = bytes.toString()
2996 -      propsFile.text = propertiesString
2997 -      print("NEW ")
2998 -    } else {
2999 -      print("EXISTING ")
3000 -    }
3001 -
3002 -    println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
3003 -  }
3004 -
3005 -  //inputs.property(propKey, eclipseWsDir) // eclipseWsDir only gets set once this task runs, so will be out-of-date
3006 -  outputs.file(propsFileName)
3007 -  outputs.upToDateWhen { eclipseWorkspace.exists() && propsFile.exists() }
3008 -}
3009 -
3010 -
3011 -task jalviewjsEclipsePaths {
3012 -  def eclipseProduct
3013 -
3014 -  def eclipseRoot = jalviewjs_eclipse_root
3015 -  if (eclipseRoot.startsWith("~/")) {
3016 -    eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
3017 -  }
3018 -  if (OperatingSystem.current().isMacOsX()) {
3019 -    eclipseRoot += "/Eclipse.app"
3020 -    eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
3021 -    eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
3022 -  } else if (OperatingSystem.current().isWindows()) { // check these paths!!
3023 -    if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
3024 -      eclipseRoot += "/eclipse"
3025 -    }
3026 -    eclipseBinary = "${eclipseRoot}/eclipse.exe"
3027 -    eclipseProduct = "${eclipseRoot}/.eclipseproduct"
3028 -  } else { // linux or unix
3029 -    if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
3030 -      eclipseRoot += "/eclipse"
3031 -println("eclipseDir exists")
3032 -    }
3033 -    eclipseBinary = "${eclipseRoot}/eclipse"
3034 -    eclipseProduct = "${eclipseRoot}/.eclipseproduct"
3035 -  }
3036 -
3037 -  eclipseVersion = "4.13" // default
3038 -  def assumedVersion = true
3039 -  if (file(eclipseProduct).exists()) {
3040 -    def fis = new FileInputStream(eclipseProduct)
3041 -    def props = new Properties()
3042 -    props.load(fis)
3043 -    eclipseVersion = props.getProperty("version")
3044 -    fis.close()
3045 -    assumedVersion = false
3046 -  }
3047 -  
3048 -  def propKey = "eclipse_debug"
3049 -  eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
3050 -
3051 -  doFirst {
3052 -    // do not run a headless transpile when we claim to be in Eclipse
3053 -    if (IN_ECLIPSE) {
3054 -      println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
3055 -      throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
3056 -    } else {
3057 -      println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
3058 -    }
3059 -
3060 -    if (!assumedVersion) {
3061 -      println("ECLIPSE VERSION=${eclipseVersion}")
3062 -    }
3063 -  }
3064 -}
3065 -
3066 -
3067 -task printProperties {
3068 -  group "Debug"
3069 -  description "Output to console all System.properties"
3070 -  doFirst {
3071 -    System.properties.each { key, val -> System.out.println("Property: ${key}=${val}") }
3072 -  }
3073 -}
3074 -
3075 -
3076 -task eclipseSetup {
3077 -  dependsOn eclipseProject
3078 -  dependsOn eclipseClasspath
3079 -  dependsOn eclipseJdt
3080 -}
3081 -
3082 -
3083 -// this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
3084 -task jalviewjsEclipseCopyDropins(type: Copy) {
3085 -  dependsOn jalviewjsEclipsePaths
3086 -
3087 -  def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
3088 -  inputFiles += file("${jalviewDir}/${jalviewjsJ2sPlugin}")
3089 -  def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
3090 -
3091 -  from inputFiles
3092 -  into outputDir
3093 -}
3094 -
3095 -
3096 -// this eclipse -clean doesn't actually work
3097 -task jalviewjsCleanEclipse(type: Exec) {
3098 -  dependsOn eclipseSetup
3099 -  dependsOn jalviewjsEclipsePaths
3100 -  dependsOn jalviewjsEclipseCopyDropins
3101 -
3102 -  executable(eclipseBinary)
3103 -  args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
3104 -  if (eclipseDebug) {
3105 -    args += "-debug"
3106 -  }
3107 -  args += "-l"
3108 -
3109 -  def inputString = """exit
3110 -y
3111 -"""
3112 -  def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
3113 -  standardInput = inputByteStream
3114 -}
3115 -
3116 -/* not really working yet
3117 -jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
3118 -*/
3119 -
3120 -
3121 -task jalviewjsTransferUnzipSwingJs {
3122 -  def file_zip = "${jalviewDir}/${jalviewjs_swingjs_zip}"
3123 -
3124 -  doLast {
3125 -    copy {
3126 -      from zipTree(file_zip)
3127 -      into "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
3128 -    }
3129 -  }
3130 -
3131 -  inputs.file file_zip
3132 -  outputs.dir "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
3133 -}
3134 -
3135 -
3136 -task jalviewjsTransferUnzipLib {
3137 -  def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
3138 -
3139 -  doLast {
3140 -    zipFiles.each { file_zip -> 
3141 -      copy {
3142 -        from zipTree(file_zip)
3143 -        into "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
3144 -      }
3145 -    }
3146 -  }
3147 -
3148 -  inputs.files zipFiles
3149 -  outputs.dir "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
3150 -}
3151 -
3152 -
3153 -task jalviewjsTransferUnzipAllLibs {
3154 -  dependsOn jalviewjsTransferUnzipSwingJs
3155 -  dependsOn jalviewjsTransferUnzipLib
3156 -}
3157 -
3158 -
3159 -task jalviewjsCreateJ2sSettings(type: WriteProperties) {
3160 -  group "JalviewJS"
3161 -  description "Create the alternative j2s file from the j2s.* properties"
3162 -
3163 -  jalviewjsJ2sProps = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
3164 -  def siteDirProperty = "j2s.site.directory"
3165 -  def setSiteDir = false
3166 -  jalviewjsJ2sProps.each { prop, val ->
3167 -    if (val != null) {
3168 -      if (prop == siteDirProperty) {
3169 -        if (!(val.startsWith('/') || val.startsWith("file://") )) {
3170 -          val = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${val}"
3171 -        }
3172 -        setSiteDir = true
3173 -      }
3174 -      property(prop,val)
3175 -    }
3176 -    if (!setSiteDir) { // default site location, don't override specifically set property
3177 -      property(siteDirProperty,"${jalviewDirRelativePath}/${jalviewjsTransferSiteJsDir}")
3178 -    }
3179 -  }
3180 -  outputFile = jalviewjsJ2sAltSettingsFileName
3181 -
3182 -  if (! IN_ECLIPSE) {
3183 -    inputs.properties(jalviewjsJ2sProps)
3184 -    outputs.file(jalviewjsJ2sAltSettingsFileName)
3185 -  }
3186 -}
3187 -
3188 -
3189 -task jalviewjsEclipseSetup {
3190 -  dependsOn jalviewjsEclipseCopyDropins
3191 -  dependsOn jalviewjsSetEclipseWorkspace
3192 -  dependsOn jalviewjsCreateJ2sSettings
3193 -}
3194 -
3195 -
3196 -task jalviewjsSyncAllLibs (type: Sync) {
3197 -  dependsOn jalviewjsTransferUnzipAllLibs
3198 -  def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteLibDir}")
3199 -  inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
3200 -  def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
3201 -
3202 -  from inputFiles
3203 -  into outputDir
3204 -  def outputFiles = []
3205 -  rename { filename ->
3206 -    outputFiles += "${outputDir}/${filename}"
3207 -    null
3208 -  }
3209 -  preserve {
3210 -    include "**"
3211 -  }
3212 -
3213 -  // should this be exclude really ?
3214 -  duplicatesStrategy "INCLUDE"
3215 -
3216 -  outputs.files outputFiles
3217 -  inputs.files inputFiles
3218 -}
3219 -
3220 -
3221 -task jalviewjsSyncResources (type: Sync) {
3222 -  dependsOn buildResources
3223 -
3224 -  def inputFiles = fileTree(dir: resourcesBuildDir)
3225 -  def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
3226 -
3227 -  from inputFiles
3228 -  into outputDir
3229 -  def outputFiles = []
3230 -  rename { filename ->
3231 -    outputFiles += "${outputDir}/${filename}"
3232 -    null
3233 -  }
3234 -  preserve {
3235 -    include "**"
3236 -  }
3237 -  outputs.files outputFiles
3238 -  inputs.files inputFiles
3239 -}
3240 -
3241 -
3242 -task jalviewjsSyncSiteResources (type: Sync) {
3243 -  def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
3244 -  def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
3245 -
3246 -  from inputFiles
3247 -  into outputDir
3248 -  def outputFiles = []
3249 -  rename { filename ->
3250 -    outputFiles += "${outputDir}/${filename}"
3251 -    null
3252 -  }
3253 -  preserve {
3254 -    include "**"
3255 -  }
3256 -  outputs.files outputFiles
3257 -  inputs.files inputFiles
3258 -}
3259 -
3260 -
3261 -task jalviewjsSyncBuildProperties (type: Sync) {
3262 -  dependsOn createBuildProperties
3263 -  def inputFiles = [file(buildProperties)]
3264 -  def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
3265 -
3266 -  from inputFiles
3267 -  into outputDir
3268 -  def outputFiles = []
3269 -  rename { filename ->
3270 -    outputFiles += "${outputDir}/${filename}"
3271 -    null
3272 -  }
3273 -  preserve {
3274 -    include "**"
3275 -  }
3276 -  outputs.files outputFiles
3277 -  inputs.files inputFiles
3278 -}
3279 -
3280 -
3281 -task jalviewjsProjectImport(type: Exec) {
3282 -  dependsOn eclipseSetup
3283 -  dependsOn jalviewjsEclipsePaths
3284 -  dependsOn jalviewjsEclipseSetup
3285 -
3286 -  doFirst {
3287 -    // do not run a headless import when we claim to be in Eclipse
3288 -    if (IN_ECLIPSE) {
3289 -      println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
3290 -      throw new StopExecutionException("Not running headless import whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
3291 -    } else {
3292 -      println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
3293 -    }
3294 -  }
3295 -
3296 -  //def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
3297 -  def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview"
3298 -  executable(eclipseBinary)
3299 -  args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
3300 -  if (eclipseDebug) {
3301 -    args += "-debug"
3302 -  }
3303 -  args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
3304 -  if (!IN_ECLIPSE) {
3305 -    args += [ "-D${j2sHeadlessBuildProperty}=true" ]
3306 -    args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ]
3307 -  }
3308 -
3309 -  inputs.file("${jalviewDir}/.project")
3310 -  outputs.upToDateWhen { 
3311 -    file(projdir).exists()
3312 -  }
3313 -}
3314 -
3315 -
3316 -task jalviewjsTranspile(type: Exec) {
3317 -  dependsOn jalviewjsEclipseSetup 
3318 -  dependsOn jalviewjsProjectImport
3319 -  dependsOn jalviewjsEclipsePaths
3320 -  if (!IN_ECLIPSE) {
3321 -    dependsOn jalviewjsEnableAltFileProperty
3322 -  }
3323 -
3324 -  doFirst {
3325 -    // do not run a headless transpile when we claim to be in Eclipse
3326 -    if (IN_ECLIPSE) {
3327 -      println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
3328 -      throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
3329 -    } else {
3330 -      println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
3331 -    }
3332 -  }
3333 -
3334 -  executable(eclipseBinary)
3335 -  args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
3336 -  if (eclipseDebug) {
3337 -    args += "-debug"
3338 -  }
3339 -  args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
3340 -  if (!IN_ECLIPSE) {
3341 -    args += [ "-D${j2sHeadlessBuildProperty}=true" ]
3342 -    args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ]
3343 -  }
3344 -
3345 -  def stdout
3346 -  def stderr
3347 -  doFirst {
3348 -    stdout = new ByteArrayOutputStream()
3349 -    stderr = new ByteArrayOutputStream()
3350 -
3351 -    def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}"
3352 -    def logOutFile = file(logOutFileName)
3353 -    logOutFile.createNewFile()
3354 -    logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
3355 -BINARY: ${eclipseBinary}
3356 -VERSION: ${eclipseVersion}
3357 -WORKSPACE: ${eclipseWorkspace}
3358 -DEBUG: ${eclipseDebug}
3359 -----
3360 -"""
3361 -    def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
3362 -    // combine stdout and stderr
3363 -    def logErrFOS = logOutFOS
3364 -
3365 -    if (jalviewjs_j2s_to_console.equals("true")) {
3366 -      standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
3367 -        new org.apache.tools.ant.util.TeeOutputStream(
3368 -          logOutFOS,
3369 -          stdout),
3370 -        System.out)
3371 -      errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
3372 -        new org.apache.tools.ant.util.TeeOutputStream(
3373 -          logErrFOS,
3374 -          stderr),
3375 -        System.err)
3376 -    } else {
3377 -      standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
3378 -        logOutFOS,
3379 -        stdout)
3380 -      errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
3381 -        logErrFOS,
3382 -        stderr)
3383 -    }
3384 -  }
3385 -
3386 -  doLast {
3387 -    if (stdout.toString().contains("Error processing ")) {
3388 -      // j2s did not complete transpile
3389 -      //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
3390 -      if (jalviewjs_ignore_transpile_errors.equals("true")) {
3391 -        println("IGNORING TRANSPILE ERRORS")
3392 -        println("See eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
3393 -      } else {
3394 -        throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
3395 -      }
3396 -    }
3397 -  }
3398 -
3399 -  inputs.dir("${jalviewDir}/${sourceDir}")
3400 -  outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
3401 -  outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
3402 -}
3403 -
3404 -
3405 -def jalviewjsCallCore(String name, FileCollection list, String prefixFile, String suffixFile, String jsfile, String zjsfile, File logOutFile, Boolean logOutConsole) {
3406 -
3407 -  def stdout = new ByteArrayOutputStream()
3408 -  def stderr = new ByteArrayOutputStream()
3409 -
3410 -  def coreFile = file(jsfile)
3411 -  def msg = ""
3412 -  msg = "Creating core for ${name}...\nGenerating ${jsfile}"
3413 -  println(msg)
3414 -  logOutFile.createNewFile()
3415 -  logOutFile.append(msg+"\n")
3416 -
3417 -  def coreTop = file(prefixFile)
3418 -  def coreBottom = file(suffixFile)
3419 -  coreFile.getParentFile().mkdirs()
3420 -  coreFile.createNewFile()
3421 -  coreFile.write( coreTop.getText("UTF-8") )
3422 -  list.each {
3423 -    f ->
3424 -    if (f.exists()) {
3425 -      def t = f.getText("UTF-8")
3426 -      t.replaceAll("Clazz\\.([^_])","Clazz_${1}")
3427 -      coreFile.append( t )
3428 -    } else {
3429 -      msg = "...file '"+f.getPath()+"' does not exist, skipping"
3430 -      println(msg)
3431 -      logOutFile.append(msg+"\n")
3432 -    }
3433 -  }
3434 -  coreFile.append( coreBottom.getText("UTF-8") )
3435 -
3436 -  msg = "Generating ${zjsfile}"
3437 -  println(msg)
3438 -  logOutFile.append(msg+"\n")
3439 -  def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
3440 -  def logErrFOS = logOutFOS
3441 -
3442 -  javaexec {
3443 -    classpath = files(["${jalviewDir}/${jalviewjs_closure_compiler}"])
3444 -    main = "com.google.javascript.jscomp.CommandLineRunner"
3445 -    jvmArgs = [ "-Dfile.encoding=UTF-8" ]
3446 -    args = [ "--compilation_level", "SIMPLE_OPTIMIZATIONS", "--warning_level", "QUIET", "--charset", "UTF-8", "--js", jsfile, "--js_output_file", zjsfile ]
3447 -    maxHeapSize = "2g"
3448 -
3449 -    msg = "\nRunning '"+commandLine.join(' ')+"'\n"
3450 -    println(msg)
3451 -    logOutFile.append(msg+"\n")
3452 -
3453 -    if (logOutConsole) {
3454 -      standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
3455 -        new org.apache.tools.ant.util.TeeOutputStream(
3456 -          logOutFOS,
3457 -          stdout),
3458 -        standardOutput)
3459 -        errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
3460 -          new org.apache.tools.ant.util.TeeOutputStream(
3461 -            logErrFOS,
3462 -            stderr),
3463 -          System.err)
3464 -    } else {
3465 -      standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
3466 -        logOutFOS,
3467 -        stdout)
3468 -        errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
3469 -          logErrFOS,
3470 -          stderr)
3471 -    }
3472 -  }
3473 -  msg = "--"
3474 -  println(msg)
3475 -  logOutFile.append(msg+"\n")
3476 -}
3477 -
3478 -
3479 -task jalviewjsBuildAllCores {
3480 -  group "JalviewJS"
3481 -  description "Build the core js lib closures listed in the classlists dir"
3482 -  dependsOn jalviewjsTranspile
3483 -  dependsOn jalviewjsTransferUnzipSwingJs
3484 -
3485 -  def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}"
3486 -  def swingJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_j2s_subdir}"
3487 -  def libJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${jalviewjs_j2s_subdir}"
3488 -  def jsDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_js_subdir}"
3489 -  def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core"
3490 -  def prefixFile = "${jsDir}/core/coretop2.js"
3491 -  def suffixFile = "${jsDir}/core/corebottom2.js"
3492 -
3493 -  inputs.file prefixFile
3494 -  inputs.file suffixFile
3495 -
3496 -  def classlistFiles = []
3497 -  // add the classlists found int the jalviewjs_classlists_dir
3498 -  fileTree(dir: "${jalviewDir}/${jalviewjs_classlists_dir}", include: "*.txt").each {
3499 -    file ->
3500 -    def name = file.getName() - ".txt"
3501 -    classlistFiles += [
3502 -      'file': file,
3503 -      'name': name
3504 -    ]
3505 -  }
3506 -
3507 -  // _jmol and _jalview cores. Add any other peculiar classlist.txt files here
3508 -  //classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jmol}"), 'name': "_jvjmol" ]
3509 -  classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jalview}"), 'name': jalviewjsJalviewCoreName ]
3510 -
3511 -  jalviewjsCoreClasslists = []
3512 -
3513 -  classlistFiles.each {
3514 -    hash ->
3515 -
3516 -    def file = hash['file']
3517 -    if (! file.exists()) {
3518 -      //println("...classlist file '"+file.getPath()+"' does not exist, skipping")
3519 -      return false // this is a "continue" in groovy .each closure
3520 -    }
3521 -    def name = hash['name']
3522 -    if (name == null) {
3523 -      name = file.getName() - ".txt"
3524 -    }
3525 -
3526 -    def filelist = []
3527 -    file.eachLine {
3528 -      line ->
3529 -        filelist += line
3530 -    }
3531 -    def list = fileTree(dir: j2sDir, includes: filelist)
3532 -
3533 -    def jsfile = "${outputDir}/core${name}.js"
3534 -    def zjsfile = "${outputDir}/core${name}.z.js"
3535 -
3536 -    jalviewjsCoreClasslists += [
3537 -      'jsfile': jsfile,
3538 -      'zjsfile': zjsfile,
3539 -      'list': list,
3540 -      'name': name
3541 -    ]
3542 -
3543 -    inputs.file(file)
3544 -    inputs.files(list)
3545 -    outputs.file(jsfile)
3546 -    outputs.file(zjsfile)
3547 -  }
3548 -  
3549 -  // _stevesoft core. add any cores without a classlist here (and the inputs and outputs)
3550 -  def stevesoftClasslistName = "_stevesoft"
3551 -  def stevesoftClasslist = [
3552 -    'jsfile': "${outputDir}/core${stevesoftClasslistName}.js",
3553 -    'zjsfile': "${outputDir}/core${stevesoftClasslistName}.z.js",
3554 -    'list': fileTree(dir: j2sDir, include: "com/stevesoft/pat/**/*.js"),
3555 -    'name': stevesoftClasslistName
3556 -  ]
3557 -  jalviewjsCoreClasslists += stevesoftClasslist
3558 -  inputs.files(stevesoftClasslist['list'])
3559 -  outputs.file(stevesoftClasslist['jsfile'])
3560 -  outputs.file(stevesoftClasslist['zjsfile'])
3561 -
3562 -  // _all core
3563 -  def allClasslistName = "_all"
3564 -  def allJsFiles = fileTree(dir: j2sDir, include: "**/*.js")
3565 -  allJsFiles += fileTree(
3566 -    dir: libJ2sDir,
3567 -    include: "**/*.js",
3568 -    excludes: [
3569 -      // these exlusions are files that the closure-compiler produces errors for. Should fix them
3570 -      "**/org/jmol/jvxl/readers/IsoIntersectFileReader.js",
3571 -      "**/org/jmol/export/JSExporter.js"
3572 -    ]
3573 -  )
3574 -  allJsFiles += fileTree(
3575 -    dir: swingJ2sDir,
3576 -    include: "**/*.js",
3577 -    excludes: [
3578 -      // these exlusions are files that the closure-compiler produces errors for. Should fix them
3579 -      "**/sun/misc/Unsafe.js",
3580 -      "**/swingjs/jquery/jquery-editable-select.js",
3581 -      "**/swingjs/jquery/j2sComboBox.js",
3582 -      "**/sun/misc/FloatingDecimal.js"
3583 -    ]
3584 -  )
3585 -  def allClasslist = [
3586 -    'jsfile': "${outputDir}/core${allClasslistName}.js",
3587 -    'zjsfile': "${outputDir}/core${allClasslistName}.z.js",
3588 -    'list': allJsFiles,
3589 -    'name': allClasslistName
3590 -  ]
3591 -  // not including this version of "all" core at the moment
3592 -  //jalviewjsCoreClasslists += allClasslist
3593 -  inputs.files(allClasslist['list'])
3594 -  outputs.file(allClasslist['jsfile'])
3595 -  outputs.file(allClasslist['zjsfile'])
3596 -
3597 -  doFirst {
3598 -    def logOutFile = file("${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_closure_stdout}")
3599 -    logOutFile.getParentFile().mkdirs()
3600 -    logOutFile.createNewFile()
3601 -    logOutFile.write(getDate("yyyy-MM-dd HH:mm:ss")+" jalviewjsBuildAllCores\n----\n")
3602 -
3603 -    jalviewjsCoreClasslists.each {
3604 -      jalviewjsCallCore(it.name, it.list, prefixFile, suffixFile, it.jsfile, it.zjsfile, logOutFile, jalviewjs_j2s_to_console.equals("true"))
3605 -    }
3606 -  }
3607 -
3608 -}
3609 -
3610 -
3611 -def jalviewjsPublishCoreTemplate(String coreName, String templateName, File inputFile, String outputFile) {
3612 -  copy {
3613 -    from inputFile
3614 -    into file(outputFile).getParentFile()
3615 -    rename { filename ->
3616 -      if (filename.equals(inputFile.getName())) {
3617 -        return file(outputFile).getName()
3618 -      }
3619 -      return null
3620 -    }
3621 -    filter(ReplaceTokens,
3622 -      beginToken: '_',
3623 -      endToken: '_',
3624 -      tokens: [
3625 -        'MAIN': '"'+main_class+'"',
3626 -        'CODE': "null",
3627 -        'NAME': jalviewjsJalviewTemplateName+" [core ${coreName}]",
3628 -        'COREKEY': jalviewjs_core_key,
3629 -        'CORENAME': coreName
3630 -      ]
3631 -    )
3632 -  }
3633 -}
3634 -
3635 -
3636 -task jalviewjsPublishCoreTemplates {
3637 -  dependsOn jalviewjsBuildAllCores
3638 -  def inputFileName = "${jalviewDir}/${j2s_coretemplate_html}"
3639 -  def inputFile = file(inputFileName)
3640 -  def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
3641 -
3642 -  def outputFiles = []
3643 -  jalviewjsCoreClasslists.each { cl ->
3644 -    def outputFile = "${outputDir}/${jalviewjsJalviewTemplateName}_${cl.name}.html"
3645 -    cl['outputfile'] = outputFile
3646 -    outputFiles += outputFile
3647 -  }
3648 -
3649 -  doFirst {
3650 -    jalviewjsCoreClasslists.each { cl ->
3651 -      jalviewjsPublishCoreTemplate(cl.name, jalviewjsJalviewTemplateName, inputFile, cl.outputfile)
3652 -    }
3653 -  }
3654 -  inputs.file(inputFile)
3655 -  outputs.files(outputFiles)
3656 -}
3657 -
3658 -
3659 -task jalviewjsSyncCore (type: Sync) {
3660 -  dependsOn jalviewjsBuildAllCores
3661 -  dependsOn jalviewjsPublishCoreTemplates
3662 -  def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
3663 -  def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
3664 -
3665 -  from inputFiles
3666 -  into outputDir
3667 -  def outputFiles = []
3668 -  rename { filename ->
3669 -    outputFiles += "${outputDir}/${filename}"
3670 -    null
3671 -  }
3672 -  preserve {
3673 -    include "**"
3674 -  }
3675 -  outputs.files outputFiles
3676 -  inputs.files inputFiles
3677 -}
3678 -
3679 -
3680 -// this Copy version of TransferSiteJs will delete anything else in the target dir
3681 -task jalviewjsCopyTransferSiteJs(type: Copy) {
3682 -  dependsOn jalviewjsTranspile
3683 -  from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
3684 -  into "${jalviewDir}/${jalviewjsSiteDir}"
3685 -}
3686 -
3687 -
3688 -// this Sync version of TransferSite is used by buildship to keep the website automatically up to date when a file changes
3689 -task jalviewjsSyncTransferSiteJs(type: Sync) {
3690 -  from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
3691 -  include "**/*.*"
3692 -  into "${jalviewDir}/${jalviewjsSiteDir}"
3693 -  preserve {
3694 -    include "**"
3695 -  }
3696 -}
3697 -
3698 -
3699 -jalviewjsSyncAllLibs.mustRunAfter jalviewjsCopyTransferSiteJs
3700 -jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSiteJs
3701 -jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSiteJs
3702 -jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSiteJs
3703 -
3704 -jalviewjsSyncAllLibs.mustRunAfter jalviewjsSyncTransferSiteJs
3705 -jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSiteJs
3706 -jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSiteJs
3707 -jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSiteJs
3708 -
3709 -
3710 -task jalviewjsPrepareSite {
3711 -  group "JalviewJS"
3712 -  description "Prepares the website folder including unzipping files and copying resources"
3713 -  dependsOn jalviewjsSyncAllLibs
3714 -  dependsOn jalviewjsSyncResources
3715 -  dependsOn jalviewjsSyncSiteResources
3716 -  dependsOn jalviewjsSyncBuildProperties
3717 -  dependsOn jalviewjsSyncCore
3718 -}
3719 -
3720 -
3721 -task jalviewjsBuildSite {
3722 -  group "JalviewJS"
3723 -  description "Builds the whole website including transpiled code"
3724 -  dependsOn jalviewjsCopyTransferSiteJs
3725 -  dependsOn jalviewjsPrepareSite
3726 -}
3727 -
3728 -
3729 -task cleanJalviewjsTransferSite {
3730 -  doFirst {
3731 -    delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
3732 -    delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
3733 -    delete "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
3734 -    delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
3735 -  }
3736 -}
3737 -
3738 -
3739 -task cleanJalviewjsSite {
3740 -  dependsOn cleanJalviewjsTransferSite
3741 -  doFirst {
3742 -    delete "${jalviewDir}/${jalviewjsSiteDir}"
3743 -  }
3744 -}
3745 -
3746 -
3747 -task jalviewjsSiteTar(type: Tar) {
3748 -  group "JalviewJS"
3749 -  description "Creates a tar.gz file for the website"
3750 -  dependsOn jalviewjsBuildSite
3751 -  def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
3752 -  archiveFileName = outputFilename
3753 -
3754 -  compression Compression.GZIP
3755 -
3756 -  from "${jalviewDir}/${jalviewjsSiteDir}"
3757 -  into jalviewjs_site_dir // this is inside the tar file
3758 -
3759 -  inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
3760 -}
3761 -
3762 -
3763 -task jalviewjsServer {
3764 -  group "JalviewJS"
3765 -  def filename = "jalviewjsTest.html"
3766 -  description "Starts a webserver on localhost to test the website. See ${filename} to access local site on most recently used port."
3767 -  def htmlFile = "${jalviewDirAbsolutePath}/${filename}"
3768 -  doLast {
3769 -
3770 -    def factory
3771 -    try {
3772 -      def f = Class.forName("org.gradle.plugins.javascript.envjs.http.simple.SimpleHttpFileServerFactory")
3773 -      factory = f.newInstance()
3774 -    } catch (ClassNotFoundException e) {
3775 -      throw new GradleException("Unable to create SimpleHttpFileServerFactory")
3776 -    }
3777 -    def port = Integer.valueOf(jalviewjs_server_port)
3778 -    def start = port
3779 -    def running = false
3780 -    def url
3781 -    def jalviewjsServer
3782 -    while(port < start+1000 && !running) {
3783 -      try {
3784 -        def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
3785 -        jalviewjsServer = factory.start(doc_root, port)
3786 -        running = true
3787 -        url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
3788 -        println("SERVER STARTED with document root ${doc_root}.")
3789 -        println("Go to "+url+" . Run  gradle --stop  to stop (kills all gradle daemons).")
3790 -        println("For debug: "+url+"?j2sdebug")
3791 -        println("For verbose: "+url+"?j2sverbose")
3792 -      } catch (Exception e) {
3793 -        port++;
3794 -      }
3795 -    }
3796 -    def htmlText = """
3797 -      <p><a href="${url}">JalviewJS Test. &lt;${url}&gt;</a></p>
3798 -      <p><a href="${url}?j2sdebug">JalviewJS Test with debug. &lt;${url}?j2sdebug&gt;</a></p>
3799 -      <p><a href="${url}?j2sverbose">JalviewJS Test with verbose. &lt;${url}?j2sdebug&gt;</a></p>
3800 -      """
3801 -    jalviewjsCoreClasslists.each { cl ->
3802 -      def urlcore = jalviewjsServer.getResourceUrl(file(cl.outputfile).getName())
3803 -      htmlText += """
3804 -      <p><a href="${urlcore}">${jalviewjsJalviewTemplateName} [core ${cl.name}]. &lt;${urlcore}&gt;</a></p>
3805 -      """
3806 -      println("For core ${cl.name}: "+urlcore)
3807 -    }
3808 -
3809 -    file(htmlFile).text = htmlText
3810 -  }
3811 -
3812 -  outputs.file(htmlFile)
3813 -  outputs.upToDateWhen({false})
3814 -}
3815 -
3816 -
3817 -task cleanJalviewjsAll {
3818 -  group "JalviewJS"
3819 -  description "Delete all configuration and build artifacts to do with JalviewJS build"
3820 -  dependsOn cleanJalviewjsSite
3821 -  dependsOn jalviewjsEclipsePaths
3822 -  
3823 -  doFirst {
3824 -    delete "${jalviewDir}/${jalviewjsBuildDir}"
3825 -    delete "${jalviewDir}/${eclipse_bin_dir}"
3826 -    if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
3827 -      delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
3828 -    }
3829 -    delete jalviewjsJ2sAltSettingsFileName
3830 -  }
3831 -
3832 -  outputs.upToDateWhen( { false } )
3833 -}
3834 -
3835 -
3836 -task jalviewjsIDE_checkJ2sPlugin {
3837 -  group "00 JalviewJS in Eclipse"
3838 -  description "Compare the swingjs/net.sf.j2s.core(-j11)?.jar file with the Eclipse IDE's plugin version (found in the 'dropins' dir)"
3839 -
3840 -  doFirst {
3841 -    def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}")
3842 -    def j2sPluginFile = file(j2sPlugin)
3843 -    def eclipseHome = System.properties["eclipse.home.location"]
3844 -    if (eclipseHome == null || ! IN_ECLIPSE) {
3845 -      throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.")
3846 -    }
3847 -    def eclipseJ2sPluginDirs = [ "${eclipseHome}/dropins" ]
3848 -    def altPluginsDir = System.properties["org.eclipse.equinox.p2.reconciler.dropins.directory"]
3849 -    if (altPluginsDir != null && file(altPluginsDir).exists()) {
3850 -      eclipseJ2sPluginDirs += altPluginsDir
3851 -    }
3852 -    def foundPlugin = false
3853 -    def j2sPluginFileName = j2sPluginFile.getName()
3854 -    def eclipseJ2sPlugin
3855 -    def eclipseJ2sPluginFile
3856 -    eclipseJ2sPluginDirs.any { dir ->
3857 -      eclipseJ2sPlugin = "${dir}/${j2sPluginFileName}"
3858 -      eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
3859 -      if (eclipseJ2sPluginFile.exists()) {
3860 -        foundPlugin = true
3861 -        return true
3862 -      }
3863 -    }
3864 -    if (!foundPlugin) {
3865 -      def msg = "Eclipse J2S Plugin is not installed (could not find '${j2sPluginFileName}' in\n"+eclipseJ2sPluginDirs.join("\n")+"\n)\nTry running task jalviewjsIDE_copyJ2sPlugin"
3866 -      System.err.println(msg)
3867 -      throw new StopExecutionException(msg)
3868 -    }
3869 -
3870 -    def digest = MessageDigest.getInstance("MD5")
3871 -
3872 -    digest.update(j2sPluginFile.text.bytes)
3873 -    def j2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
3874 -
3875 -    digest.update(eclipseJ2sPluginFile.text.bytes)
3876 -    def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
3877 -     
3878 -    if (j2sPluginMd5 != eclipseJ2sPluginMd5) {
3879 -      def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'"
3880 -      System.err.println(msg)
3881 -      throw new StopExecutionException(msg)
3882 -    } else {
3883 -      def msg = "Eclipse J2S Plugin '${eclipseJ2sPlugin}' is the same as '${j2sPlugin}' (this is good)"
3884 -      println(msg)
3885 -    }
3886 -  }
3887 -}
3888 -
3889 -task jalviewjsIDE_copyJ2sPlugin {
3890 -  group "00 JalviewJS in Eclipse"
3891 -  description "Copy the swingjs/net.sf.j2s.core(-j11)?.jar file into the Eclipse IDE's 'dropins' dir"
3892 -
3893 -  doFirst {
3894 -    def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}")
3895 -    def j2sPluginFile = file(j2sPlugin)
3896 -    def eclipseHome = System.properties["eclipse.home.location"]
3897 -    if (eclipseHome == null || ! IN_ECLIPSE) {
3898 -      throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. NOT copying J2S Plugin.")
3899 -    }
3900 -    def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}"
3901 -    def eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
3902 -    def msg = "WARNING! Copying this commit's j2s plugin '${j2sPlugin}' to Eclipse J2S Plugin '${eclipseJ2sPlugin}'\n* May require an Eclipse restart"
3903 -    System.err.println(msg)
3904 -    copy {
3905 -      from j2sPlugin
3906 -      eclipseJ2sPluginFile.getParentFile().mkdirs()
3907 -      into eclipseJ2sPluginFile.getParent()
3908 -    }
3909 -  }
3910 -}
3911 -
3912 -
3913 -task jalviewjsIDE_j2sFile {
3914 -  group "00 JalviewJS in Eclipse"
3915 -  description "Creates the .j2s file"
3916 -  dependsOn jalviewjsCreateJ2sSettings
3917 -}
3918 -
3919 -
3920 -task jalviewjsIDE_SyncCore {
3921 -  group "00 JalviewJS in Eclipse"
3922 -  description "Build the core js lib closures listed in the classlists dir and publish core html from template"
3923 -  dependsOn jalviewjsSyncCore
3924 -}
3925 -
3926 -
3927 -task jalviewjsIDE_SyncSiteAll {
3928 -  dependsOn jalviewjsSyncAllLibs
3929 -  dependsOn jalviewjsSyncResources
3930 -  dependsOn jalviewjsSyncSiteResources
3931 -  dependsOn jalviewjsSyncBuildProperties
3932 -}
3933 -
3934 -
3935 -cleanJalviewjsTransferSite.mustRunAfter jalviewjsIDE_SyncSiteAll
3936 -
3937 -
3938 -task jalviewjsIDE_PrepareSite {
3939 -  group "00 JalviewJS in Eclipse"
3940 -  description "Sync libs and resources to site dir, but not closure cores"
3941 -
3942 -  dependsOn jalviewjsIDE_SyncSiteAll
3943 -  //dependsOn cleanJalviewjsTransferSite // not sure why this clean is here -- will slow down a re-run of this task
3944 -}
3945 -
3946 -
3947 -task jalviewjsIDE_AssembleSite {
3948 -  group "00 JalviewJS in Eclipse"
3949 -  description "Assembles unzipped supporting zipfiles, resources, site resources and closure cores into the Eclipse transpiled site"
3950 -  dependsOn jalviewjsPrepareSite
3951 -}
3952 -
3953 -
3954 -task jalviewjsIDE_SiteClean {
3955 -  group "00 JalviewJS in Eclipse"
3956 -  description "Deletes the Eclipse transpiled site"
3957 -  dependsOn cleanJalviewjsSite
3958 -}
3959 -
3960 -
3961 -task jalviewjsIDE_Server {
3962 -  group "00 JalviewJS in Eclipse"
3963 -  description "Starts a webserver on localhost to test the website"
3964 -  dependsOn jalviewjsServer
3965 -}
3966 -
3967 -
3968 -// buildship runs this at import or gradle refresh
3969 -task eclipseSynchronizationTask {
3970 -  //dependsOn eclipseSetup
3971 -  dependsOn createBuildProperties
3972 -  if (J2S_ENABLED) {
3973 -    dependsOn jalviewjsIDE_j2sFile
3974 -    dependsOn jalviewjsIDE_checkJ2sPlugin
3975 -    dependsOn jalviewjsIDE_PrepareSite
3976 -  }
3977 -}
3978 -
3979 -
3980 -// buildship runs this at build time or project refresh
3981 -task eclipseAutoBuildTask {
3982 -  //dependsOn jalviewjsIDE_checkJ2sPlugin
3983 -  //dependsOn jalviewjsIDE_PrepareSite
3984 -}
3985 -
3986 -
3987 -task jalviewjs {
3988 -  group "JalviewJS"
3989 -  description "Build the site"
3990 -  dependsOn jalviewjsBuildSite
3991 +  outputs.file("${outputDir}/${archiveFileName}")
3992  }
3993