1 --- a/build.gradle 2021-09-21 09:52:04.653972716 +0100
2 +++ b/build.gradle 2021-09-21 09:52:18.117985307 +0100
4 * For properties set within build.gradle, use camelCaseNoSpace.
6 import org.apache.tools.ant.filters.ReplaceTokens
7 -import org.gradle.internal.os.OperatingSystem
8 -import org.gradle.plugins.ide.internal.generator.PropertiesPersistableConfigurationObject
9 -import org.gradle.api.internal.PropertiesTransformer
10 -import org.gradle.util.ConfigureUtil
11 -import org.gradle.plugins.ide.eclipse.model.Output
12 -import org.gradle.plugins.ide.eclipse.model.Library
13 -import java.security.MessageDigest
14 -import groovy.transform.ExternalizeMethods
15 -import groovy.util.XmlParser
16 -import groovy.xml.XmlUtil
17 -import com.vladsch.flexmark.util.ast.Node
18 -import com.vladsch.flexmark.html.HtmlRenderer
19 -import com.vladsch.flexmark.parser.Parser
20 -import com.vladsch.flexmark.util.data.MutableDataSet
21 -import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension
22 -import com.vladsch.flexmark.ext.tables.TablesExtension
23 -import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension
24 -import com.vladsch.flexmark.ext.autolink.AutolinkExtension
25 -import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension
26 -import com.vladsch.flexmark.ext.toc.TocExtension
34 - classpath "com.vladsch.flexmark:flexmark-all:0.62.0"
43 - id "com.diffplug.gradle.spotless" version "3.28.0"
44 - id 'com.github.johnrengelman.shadow' version '4.0.3'
45 - id 'com.install4j.gradle' version '8.0.10'
46 - id 'com.dorongold.task-tree' version '1.5' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
47 - id 'com.palantir.git-version' version '0.12.3'
57 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
58 def string(Object o) {
59 return o == null ? "" : o.toString()
66 jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
67 jalviewDirRelativePath = jalviewDir
69 - getdownChannelName = CHANNEL.toLowerCase()
70 - // default to "default". Currently only has different cosmetics for "develop", "release", "default"
71 - propertiesChannelName = ["develop", "release", "test-release", "jalviewjs", "jalviewjs-release" ].contains(getdownChannelName) ? getdownChannelName : "default"
72 - // Import channel_properties
73 + propertiesChannelName = "release"
74 channelDir = string("${jalviewDir}/${channel_properties_dir}/${propertiesChannelName}")
75 channelGradleProperties = string("${channelDir}/channel_gradle.properties")
76 overrideProperties(channelGradleProperties, false)
77 - // local build environment properties
78 - // can be "projectDir/local.properties"
79 - overrideProperties("${projectDir}/local.properties", true)
80 - // or "../projectDir_local.properties"
81 - overrideProperties(projectDir.getParent() + "/" + projectDir.getName() + "_local.properties", true)
85 // Import releaseProps from the RELEASE file
86 // or a file specified via JALVIEW_RELEASE_FILE if defined
88 if (findProperty("JALVIEW_VERSION")==null || "".equals(JALVIEW_VERSION)) {
89 JALVIEW_VERSION = releaseProps.get("jalview.version")
92 - // this property set when running Eclipse headlessly
93 - j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
94 - // this property set by Eclipse
95 - eclipseApplicationProperty = string("eclipse.application")
96 - // CHECK IF RUNNING FROM WITHIN ECLIPSE
97 - def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
98 - IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
99 - // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
100 - if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
101 - println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
105 - println("WITHIN ECLIPSE IDE")
107 - println("HEADLESS BUILD")
110 - J2S_ENABLED = (project.hasProperty('j2s.compiler.status') && project['j2s.compiler.status'] != null && project['j2s.compiler.status'] == "enable")
112 - println("J2S ENABLED")
115 - System.properties.sort { it.key }.each {
116 - key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
119 - if (false && IN_ECLIPSE) {
120 - jalviewDir = jalviewDirAbsolutePath
125 - buildDate = new Date().format("yyyyMMdd")
128 bareSourceDir = string(source_dir)
129 @@ -173,218 +86,18 @@
131 classesDir = string("${jalviewDir}/${classes_dir}")
134 - useClover = clover.equals("true")
135 - cloverBuildDir = "${buildDir}/clover"
136 - cloverInstrDir = file("${cloverBuildDir}/clover-instr")
137 - cloverClassesDir = file("${cloverBuildDir}/clover-classes")
138 - cloverReportDir = file("${buildDir}/reports/clover")
139 - cloverTestInstrDir = file("${cloverBuildDir}/clover-test-instr")
140 - cloverTestClassesDir = file("${cloverBuildDir}/clover-test-classes")
141 - //cloverTestClassesDir = cloverClassesDir
142 - cloverDb = string("${cloverBuildDir}/clover.db")
144 - testSourceDir = useClover ? cloverTestInstrDir : testDir
145 - testClassesDir = useClover ? cloverTestClassesDir : "${jalviewDir}/${test_output_dir}"
147 - getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
149 - buildProperties = null
151 - // the following values might be overridden by the CHANNEL switch
152 - getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
153 - getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
154 - getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
155 - getdownAppDistDir = getdown_app_dir_alt
156 - getdownImagesDir = string("${jalviewDir}/${getdown_images_dir}")
157 - getdownSetAppBaseProperty = false // whether to pass the appbase and appdistdir to the application
158 - reportRsyncCommand = false
159 - jvlChannelName = CHANNEL.toLowerCase()
160 - install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build
161 - install4jDMGDSStore = "${install4j_images_dir}/${install4j_dmg_ds_store}"
162 - install4jDMGBackgroundImage = "${install4j_images_dir}/${install4j_dmg_background}"
163 - install4jInstallerName = "${jalview_name} Non-Release Installer"
164 - install4jExecutableName = install4j_executable_name
165 - install4jExtraScheme = "jalviewx"
166 - install4jMacIconsFile = string("${install4j_images_dir}/${install4j_mac_icons_file}")
167 - install4jWindowsIconsFile = string("${install4j_images_dir}/${install4j_windows_icons_file}")
168 - install4jPngIconFile = string("${install4j_images_dir}/${install4j_png_icon_file}")
169 - install4jBackground = string("${install4j_images_dir}/${install4j_background}")
173 - // TODO: get bamboo build artifact URL for getdown artifacts
174 - getdown_channel_base = bamboo_channelbase
175 - getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
176 - getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
177 - jvlChannelName += "_${getdownChannelName}"
178 - // automatically add the test group Not-bamboo for exclusion
179 - if ("".equals(testng_excluded_groups)) {
180 - testng_excluded_groups = "Not-bamboo"
182 - install4jExtraScheme = "jalviewb"
186 - case [ "RELEASE", "JALVIEWJS-RELEASE" ]:
187 - getdownAppDistDir = getdown_app_dir_release
188 - reportRsyncCommand = true
189 - install4jSuffix = ""
190 - install4jInstallerName = "${jalview_name} Installer"
194 - getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
195 - getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
196 - getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
197 - if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
198 - throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
200 - package_dir = string("${ARCHIVEDIR}/${package_dir}")
201 - buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
204 - reportRsyncCommand = true
205 - install4jExtraScheme = "jalviewa"
208 - case "ARCHIVELOCAL":
209 - getdownChannelName = string("archive/${JALVIEW_VERSION}")
210 - getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
211 - getdownAppBase = file(getdownWebsiteDir).toURI().toString()
212 - if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
213 - throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
215 - package_dir = string("${ARCHIVEDIR}/${package_dir}")
216 - buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
219 - reportRsyncCommand = true
220 - getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
221 - install4jSuffix = "Archive"
222 - install4jExtraScheme = "jalviewa"
226 - reportRsyncCommand = true
227 - getdownSetAppBaseProperty = true
228 - // DEVELOP-RELEASE is usually associated with a Jalview release series so set the version
229 - JALVIEW_VERSION=JALVIEW_VERSION+"-d${buildDate}"
231 - install4jSuffix = "Develop"
232 - install4jExtraScheme = "jalviewd"
233 - install4jInstallerName = "${jalview_name} Develop Installer"
236 - case "TEST-RELEASE":
237 - reportRsyncCommand = true
238 - // Don't ignore transpile errors for release build
239 - if (jalviewjs_ignore_transpile_errors.equals("true")) {
240 - jalviewjs_ignore_transpile_errors = "false"
241 - println("Setting jalviewjs_ignore_transpile_errors to 'false'")
243 - JALVIEW_VERSION = JALVIEW_VERSION+"-test"
244 - install4jSuffix = "Test"
245 - install4jExtraScheme = "jalviewt"
246 - install4jInstallerName = "${jalview_name} Test Installer"
249 - case ~/^SCRATCH(|-[-\w]*)$/:
250 - getdownChannelName = CHANNEL
251 - JALVIEW_VERSION = JALVIEW_VERSION+"-"+CHANNEL
253 - getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
254 - getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
255 - reportRsyncCommand = true
256 - install4jSuffix = "Scratch"
260 - if (!file("${LOCALDIR}").exists()) {
261 - throw new GradleException("Must provide a LOCALDIR value to produce a local distribution")
263 - getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
264 - getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
266 - JALVIEW_VERSION = "TEST"
267 - install4jSuffix = "Test-Local"
268 - install4jExtraScheme = "jalviewt"
269 - install4jInstallerName = "${jalview_name} Test Installer"
272 - case [ "LOCAL", "JALVIEWJS" ]:
273 - JALVIEW_VERSION = "TEST"
274 - getdownAppBase = file(getdownWebsiteDir).toURI().toString()
275 - getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
276 - install4jExtraScheme = "jalviewl"
279 - default: // something wrong specified
280 - throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
284 - // override getdownAppBase if requested
285 - if (findProperty("getdown_appbase_override") != null) {
286 - // revert to LOCAL if empty string
287 - if (string(getdown_appbase_override) == "") {
288 - getdownAppBase = file(getdownWebsiteDir).toURI().toString()
289 - getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
290 - } else if (string(getdown_appbase_override).startsWith("file://")) {
291 - getdownAppBase = string(getdown_appbase_override)
292 - getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
294 - getdownAppBase = string(getdown_appbase_override)
296 - println("Overriding getdown appbase with '${getdownAppBase}'")
298 - // sanitise file name for jalview launcher file for this channel
299 - jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_")
300 - // install4j application and folder names
301 - if (install4jSuffix == "") {
302 - install4jApplicationName = "${jalview_name}"
303 - install4jBundleId = "${install4j_bundle_id}"
304 - install4jWinApplicationId = install4j_release_win_application_id
306 - install4jApplicationName = "${jalview_name} ${install4jSuffix}"
307 - install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase()
308 - // add int hash of install4jSuffix to the last part of the application_id
309 - def id = install4j_release_win_application_id
310 - def idsplitreverse = id.split("-").reverse()
311 - idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode()
312 - install4jWinApplicationId = idsplitreverse.reverse().join("-")
314 - // sanitise folder and id names
315 - // install4jApplicationFolder = e.g. "Jalview Build"
316 - install4jApplicationFolder = install4jApplicationName
317 - .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \
318 - .replaceAll("_+", "_") // collapse __
319 - install4jInternalId = install4jApplicationName
320 - .replaceAll(" ","_")
321 - .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
322 - .replaceAll("_+", "") // collapse __
323 - //.replaceAll("_*-_*", "-") // collapse _-_
324 - install4jUnixApplicationFolder = install4jApplicationName
325 - .replaceAll(" ","_")
326 - .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
327 - .replaceAll("_+", "_") // collapse __
328 - .replaceAll("_*-_*", "-") // collapse _-_
331 - getdownWrapperLink = install4jUnixApplicationFolder // e.g. "jalview_local"
332 - getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
333 - //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
334 - getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
335 - getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
336 - getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
337 - getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
338 - /* compile without modules -- using classpath libraries
339 - modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
340 - modules_runtimeClasspath = modules_compileClasspath
342 - def details = versionDetails()
343 - gitHash = details.gitHash
344 - gitBranch = details.branchName
345 + resourceClassesDir = classesDir
347 + testSourceDir = testDir
348 + testClassesDir = "${jalviewDir}/${test_output_dir}"
350 + buildProperties = string("${classesDir}/${build_properties_file}")
351 + getdownSetAppBaseProperty = false // whether to pass the appbase and appdistdir to the application
353 + install4jApplicationName = "${jalview_name}"
355 println("Using a ${CHANNEL} profile.")
357 additional_compiler_args = []
358 @@ -396,71 +109,16 @@
359 libDistDir = j8libDir
360 compile_source_compatibility = 1.8
361 compile_target_compatibility = 1.8
362 - // these are getdown.txt properties defined dependent on the JAVA_VERSION
363 - getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version"))
364 - getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version"))
365 - // this property is assigned below and expanded to multiple lines in the getdown task
366 - getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location"))
367 - // this property is for the Java library used in eclipse
368 - eclipseJavaRuntimeName = string("JavaSE-1.8")
369 } else if (JAVA_VERSION.equals("11")) {
370 JAVA_INTEGER_VERSION = string("11")
372 libDistDir = j11libDir
373 compile_source_compatibility = 11
374 compile_target_compatibility = 11
375 - getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
376 - getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
377 - getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
378 - eclipseJavaRuntimeName = string("JavaSE-11")
379 - /* compile without modules -- using classpath libraries
380 - additional_compiler_args += [
381 - '--module-path', modules_compileClasspath.asPath,
382 - '--add-modules', j11modules
385 - } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
386 - JAVA_INTEGER_VERSION = JAVA_VERSION
388 - libDistDir = j11libDir
389 - compile_source_compatibility = JAVA_VERSION
390 - compile_target_compatibility = JAVA_VERSION
391 - getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
392 - getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
393 - getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
394 - eclipseJavaRuntimeName = string("JavaSE-11")
395 - /* compile without modules -- using classpath libraries
396 - additional_compiler_args += [
397 - '--module-path', modules_compileClasspath.asPath,
398 - '--add-modules', j11modules
402 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
407 - JAVA_MIN_VERSION = JAVA_VERSION
408 - JAVA_MAX_VERSION = JAVA_VERSION
409 - def jreInstallsDir = string(jre_installs_dir)
410 - if (jreInstallsDir.startsWith("~/")) {
411 - jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1)
413 - macosJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-mac-x64/jre")
414 - macosJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-mac-x64.tar.gz")
415 - windowsJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-windows-x64/jre")
416 - windowsJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-windows-x64.tar.gz")
417 - linuxJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-linux-x64/jre")
418 - linuxJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-linux-x64.tar.gz")
419 - install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
420 - install4jConfFileName = string("jalview-install4j-conf.install4j")
421 - install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
422 - install4jHomeDir = install4j_home_dir
423 - if (install4jHomeDir.startsWith("~/")) {
424 - install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
427 resourceBuildDir = string("${buildDir}/resources")
428 resourcesBuildDir = string("${resourceBuildDir}/resources_build")
429 helpBuildDir = string("${resourceBuildDir}/help_build")
431 helpSourceDir = string("${helpParentDir}/${help_dir}")
432 helpFile = string("${helpBuildDir}/${help_dir}/help.jhm")
435 - relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
436 - jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
437 - jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
439 - jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
441 - jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
443 - jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
444 - jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
445 - jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
446 - jalviewjsJalviewCoreHtmlFile = string("")
447 - jalviewjsJalviewCoreName = string(jalviewjs_core_name)
448 - jalviewjsCoreClasslists = []
449 - jalviewjsJalviewTemplateName = string(jalviewjs_name)
450 - jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
451 - jalviewjsJ2sAltSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_alt_settings}")
452 - jalviewjsJ2sProps = null
453 - jalviewjsJ2sPlugin = jalviewjs_j2s_plugin
455 - eclipseWorkspace = null
456 - eclipseBinary = string("")
457 - eclipseVersion = string("")
458 - eclipseDebug = false
462 @@ -517,27 +150,12 @@
463 compileClasspath = files(sourceSets.main.java.outputDir)
464 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
466 - runtimeClasspath = compileClasspath
467 - runtimeClasspath += files(sourceSets.main.resources.srcDirs)
472 - srcDirs cloverInstrDir
473 - outputDir = cloverClassesDir
477 - srcDirs = sourceSets.main.resources.srcDirs
480 - compileClasspath = files( sourceSets.clover.java.outputDir )
481 - //compileClasspath += files( testClassesDir )
482 + compileClasspath = files(sourceSets.main.java.outputDir)
483 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
484 - compileClasspath += fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
485 - compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
487 runtimeClasspath = compileClasspath
488 + runtimeClasspath += files(sourceSets.main.resources.srcDirs)
492 @@ -557,453 +175,41 @@
493 runtimeClasspath = compileClasspath
494 runtimeClasspath += files(sourceSets.test.resources.srcDirs)
500 -// eclipse project and settings files creation, also used by buildship
503 - name = eclipse_project_name
505 - natures 'org.eclipse.jdt.core.javanature',
506 - 'org.eclipse.jdt.groovy.core.groovyNature',
507 - 'org.eclipse.buildship.core.gradleprojectnature'
509 - buildCommand 'org.eclipse.jdt.core.javabuilder'
510 - buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
514 - //defaultOutputDir = sourceSets.main.java.outputDir
515 - configurations.each{ c->
516 - if (c.isCanBeResolved()) {
517 - minusConfigurations += [c]
521 - plusConfigurations = [ ]
525 - def removeTheseToo = []
526 - HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
527 - cp.entries.each { entry ->
528 - // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
529 - // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
530 - // we add the resources and help/help dirs in as libs afterwards (see below)
531 - if (entry.kind == 'src') {
532 - if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
533 - removeTheseToo += entry
535 - alreadyAddedSrcPath.putAt(entry.path, true)
540 - cp.entries.removeAll(removeTheseToo)
542 - //cp.entries += new Output("${eclipse_bin_dir}/main")
543 - if (file(helpParentDir).isDirectory()) {
544 - cp.entries += new Library(fileReference(helpParentDir))
546 - if (file(resourceDir).isDirectory()) {
547 - cp.entries += new Library(fileReference(resourceDir))
550 - HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
552 - sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
553 - //don't want to add outputDir as eclipse is using its own output dir in bin/main
554 - if (it.isDirectory() || ! it.exists()) {
555 - // don't add dirs to classpath, especially if they don't exist
556 - return false // groovy "continue" in .any closure
558 - def itPath = it.toString()
559 - if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
560 - // make relative path
561 - itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
563 - if (alreadyAddedLibPath.get(itPath)) {
564 - //println("Not adding duplicate entry "+itPath)
566 - //println("Adding entry "+itPath)
567 - cp.entries += new Library(fileReference(itPath))
568 - alreadyAddedLibPath.put(itPath, true)
572 - sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
573 - //no longer want to add outputDir as eclipse is using its own output dir in bin/main
574 - if (it.isDirectory() || ! it.exists()) {
575 - // don't add dirs to classpath
576 - return false // groovy "continue" in .any closure
579 - def itPath = it.toString()
580 - if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
581 - itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
583 - if (alreadyAddedLibPath.get(itPath)) {
586 - def lib = new Library(fileReference(itPath))
587 - lib.entryAttributes["test"] = "true"
589 - alreadyAddedLibPath.put(itPath, true)
597 - containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
602 - // for the IDE, use java 11 compatibility
603 - sourceCompatibility = compile_source_compatibility
604 - targetCompatibility = compile_target_compatibility
605 - javaRuntimeName = eclipseJavaRuntimeName
607 - // add in jalview project specific properties/preferences into eclipse core preferences
609 - withProperties { props ->
610 - def jalview_prefs = new Properties()
611 - def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
612 - jalview_prefs.load(ins)
614 - jalview_prefs.forEach { t, v ->
615 - if (props.getAt(t) == null) {
619 - // codestyle file -- overrides previous formatter prefs
620 - def csFile = file("${jalviewDirAbsolutePath}/${eclipse_codestyle_file}")
621 - if (csFile.exists()) {
622 - XmlParser parser = new XmlParser()
623 - def profiles = parser.parse(csFile)
624 - def profile = profiles.'profile'.find { p -> (p.'@kind' == "CodeFormatterProfile" && p.'@name' == "Jalview") }
625 - if (profile != null) {
626 - profile.'setting'.each { s ->
628 - def value = s.'@value'
629 - if (id != null && value != null) {
630 - props.putAt(id, value)
641 - // Don't want these to be activated if in headless build
642 - synchronizationTasks "eclipseSynchronizationTask"
643 - //autoBuildTasks "eclipseAutoBuildTask"
649 -/* hack to change eclipse prefs in .settings files other than org.eclipse.jdt.core.prefs */
650 -// Class to allow updating arbitrary properties files
651 -class PropertiesFile extends PropertiesPersistableConfigurationObject {
652 - public PropertiesFile(PropertiesTransformer t) { super(t); }
653 - @Override protected void load(Properties properties) { }
654 - @Override protected void store(Properties properties) { }
655 - @Override protected String getDefaultResourceName() { return ""; }
656 - // This is necessary, because PropertiesPersistableConfigurationObject fails
657 - // if no default properties file exists.
658 - @Override public void loadDefaults() { load(new StringBufferInputStream("")); }
661 -// Task to update arbitrary properties files (set outputFile)
662 -class PropertiesFileTask extends PropertiesGeneratorTask<PropertiesFile> {
663 - private final PropertiesFileContentMerger file;
664 - public PropertiesFileTask() { file = new PropertiesFileContentMerger(getTransformer()); }
665 - protected PropertiesFile create() { return new PropertiesFile(getTransformer()); }
666 - protected void configure(PropertiesFile props) {
667 - file.getBeforeMerged().execute(props); file.getWhenMerged().execute(props);
669 - public void file(Closure closure) { ConfigureUtil.configure(closure, file); }
672 -task eclipseUIPreferences(type: PropertiesFileTask) {
673 - description = "Generate Eclipse additional settings"
674 - def filename = "org.eclipse.jdt.ui.prefs"
675 - outputFile = "$projectDir/.settings/${filename}" as File
678 - it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
681 + srcDirs testSourceDir
682 + outputDir = file(testClassesDir)
687 -task eclipseGroovyCorePreferences(type: PropertiesFileTask) {
688 - description = "Generate Eclipse additional settings"
689 - def filename = "org.eclipse.jdt.groovy.core.prefs"
690 - outputFile = "$projectDir/.settings/${filename}" as File
693 - it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
695 + srcDirs = sourceSets.main.resources.srcDirs
700 -task eclipseAllPreferences {
701 - dependsOn eclipseJdt
702 - dependsOn eclipseUIPreferences
703 - dependsOn eclipseGroovyCorePreferences
706 -eclipseUIPreferences.mustRunAfter eclipseJdt
707 -eclipseGroovyCorePreferences.mustRunAfter eclipseJdt
709 -/* end of eclipse preferences hack */
717 - delete cloverBuildDir
718 - delete cloverReportDir
723 -task cloverInstrJava(type: JavaExec) {
724 - group = "Verification"
725 - description = "Create clover instrumented source java files"
727 - dependsOn cleanClover
729 - inputs.files(sourceSets.main.allJava)
730 - outputs.dir(cloverInstrDir)
732 - //classpath = fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
733 - classpath = sourceSets.clover.compileClasspath
734 - main = "com.atlassian.clover.CloverInstr"
742 - cloverInstrDir.getPath(),
744 - def srcFiles = sourceSets.main.allJava.files
747 - { file -> file.absolutePath }
750 - args argsList.toArray()
753 - delete cloverInstrDir
754 - println("Clover: About to instrument "+srcFiles.size() +" files")
759 -task cloverInstrTests(type: JavaExec) {
760 - group = "Verification"
761 - description = "Create clover instrumented source test files"
763 - dependsOn cleanClover
765 - inputs.files(testDir)
766 - outputs.dir(cloverTestInstrDir)
768 - classpath = sourceSets.clover.compileClasspath
769 - main = "com.atlassian.clover.CloverInstr"
779 - cloverTestInstrDir.getPath(),
781 - args argsList.toArray()
784 - delete cloverTestInstrDir
785 - println("Clover: About to instrument test files")
791 - group = "Verification"
792 - description = "Create clover instrumented all source files"
794 - dependsOn cloverInstrJava
795 - dependsOn cloverInstrTests
799 -cloverClasses.dependsOn cloverInstr
802 -task cloverConsoleReport(type: JavaExec) {
803 - group = "Verification"
804 - description = "Creates clover console report"
807 - file(cloverDb).exists()
810 - inputs.dir cloverClassesDir
812 - classpath = sourceSets.clover.runtimeClasspath
813 - main = "com.atlassian.clover.reporters.console.ConsoleReporter"
815 - if (cloverreport_mem.length() > 0) {
816 - maxHeapSize = cloverreport_mem
818 - if (cloverreport_jvmargs.length() > 0) {
819 - jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
829 - args argsList.toArray()
833 -task cloverHtmlReport(type: JavaExec) {
834 - group = "Verification"
835 - description = "Creates clover HTML report"
838 - file(cloverDb).exists()
841 - def cloverHtmlDir = cloverReportDir
842 - inputs.dir cloverClassesDir
843 - outputs.dir cloverHtmlDir
845 - classpath = sourceSets.clover.runtimeClasspath
846 - main = "com.atlassian.clover.reporters.html.HtmlReporter"
848 - if (cloverreport_mem.length() > 0) {
849 - maxHeapSize = cloverreport_mem
851 - if (cloverreport_jvmargs.length() > 0) {
852 - jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
863 - if (cloverreport_html_options.length() > 0) {
864 - argsList += cloverreport_html_options.split(" ")
867 - args argsList.toArray()
871 -task cloverXmlReport(type: JavaExec) {
872 - group = "Verification"
873 - description = "Creates clover XML report"
876 - file(cloverDb).exists()
879 - def cloverXmlFile = "${cloverReportDir}/clover.xml"
880 - inputs.dir cloverClassesDir
881 - outputs.file cloverXmlFile
883 - classpath = sourceSets.clover.runtimeClasspath
884 - main = "com.atlassian.clover.reporters.xml.XMLReporter"
886 - if (cloverreport_mem.length() > 0) {
887 - maxHeapSize = cloverreport_mem
889 - if (cloverreport_jvmargs.length() > 0) {
890 - jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
901 - if (cloverreport_xml_options.length() > 0) {
902 - argsList += cloverreport_xml_options.split(" ")
905 - args argsList.toArray()
908 + compileClasspath = files( sourceSets.test.java.outputDir )
909 + compileClasspath += sourceSets.main.compileClasspath
910 + compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["** REMOVE_THIS_GAP /*.jar"])
913 - group = "Verification"
914 - description = "Creates clover reports"
916 - dependsOn cloverXmlReport
917 - dependsOn cloverHtmlReport
924 - sourceCompatibility = compile_source_compatibility
925 - targetCompatibility = compile_target_compatibility
926 - options.compilerArgs += additional_compiler_args
927 - print ("Setting target compatibility to "+targetCompatibility+"\n")
928 + runtimeClasspath = compileClasspath
930 - //classpath += configurations.cloverRuntime
937 - // JBP->BS should the print statement in doFirst refer to compile_target_compatibility ?
938 sourceCompatibility = compile_source_compatibility
939 targetCompatibility = compile_target_compatibility
940 options.compilerArgs = additional_compiler_args
941 - options.encoding = "UTF-8"
943 print ("Setting target compatibility to "+compile_target_compatibility+"\n")
950 - sourceCompatibility = compile_source_compatibility
951 - targetCompatibility = compile_target_compatibility
952 - options.compilerArgs = additional_compiler_args
954 + sourceCompatibility = compile_source_compatibility
955 + targetCompatibility = compile_target_compatibility
956 + options.compilerArgs = additional_compiler_args
957 print ("Setting target compatibility to "+targetCompatibility+"\n")
964 - dependsOn cleanClover
966 delete sourceSets.test.java.outputDir
968 @@ -1031,85 +236,6 @@
972 -def convertMdToHtml (FileTree mdFiles, File cssFile) {
973 - MutableDataSet options = new MutableDataSet()
975 - def extensions = new ArrayList<>()
976 - extensions.add(AnchorLinkExtension.create())
977 - extensions.add(AutolinkExtension.create())
978 - extensions.add(StrikethroughExtension.create())
979 - extensions.add(TaskListExtension.create())
980 - extensions.add(TablesExtension.create())
981 - extensions.add(TocExtension.create())
983 - options.set(Parser.EXTENSIONS, extensions)
985 - // set GFM table parsing options
986 - options.set(TablesExtension.WITH_CAPTION, false)
987 - options.set(TablesExtension.COLUMN_SPANS, false)
988 - options.set(TablesExtension.MIN_HEADER_ROWS, 1)
989 - options.set(TablesExtension.MAX_HEADER_ROWS, 1)
990 - options.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
991 - options.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
992 - options.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
993 - // GFM anchor links
994 - options.set(AnchorLinkExtension.ANCHORLINKS_SET_ID, false)
995 - options.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor")
996 - options.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true)
997 - options.set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "<span class=\"octicon octicon-link\"></span>")
999 - Parser parser = Parser.builder(options).build()
1000 - HtmlRenderer renderer = HtmlRenderer.builder(options).build()
1002 - mdFiles.each { mdFile ->
1003 - // add table of contents
1004 - def mdText = "[TOC]\n"+mdFile.text
1006 - // grab the first top-level title
1008 - def titleRegex = /(?m)^#(\s+|([^#]))(.*)/
1009 - def matcher = mdText =~ titleRegex
1010 - if (matcher.size() > 0) {
1011 - // matcher[0][2] is the first character of the title if there wasn't any whitespace after the #
1012 - title = (matcher[0][2] != null ? matcher[0][2] : "")+matcher[0][3]
1014 - // or use the filename if none found
1015 - if (title == null) {
1016 - title = mdFile.getName()
1019 - Node document = parser.parse(mdText)
1020 - String htmlBody = renderer.render(document)
1021 - def htmlText = '''<html>
1022 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1023 -<html xmlns="http://www.w3.org/1999/xhtml">
1025 - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1026 - <meta http-equiv="Content-Style-Type" content="text/css" />
1027 - <meta name="generator" content="flexmark" />
1029 - htmlText += ((title != null) ? " <title>${title}</title>" : '' )
1031 - <style type="text/css">code{white-space: pre;}</style>
1033 - htmlText += ((cssFile != null) ? cssFile.text : '')
1034 - htmlText += '''</head>
1037 - htmlText += htmlBody
1043 - def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html")
1044 - def htmlFile = file(htmlFilePath)
1045 - println("Creating ${htmlFilePath}")
1046 - htmlFile.text = htmlText
1051 task copyDocs(type: Copy) {
1052 def inputDir = "${jalviewDir}/${doc_dir}"
1053 def outputDir = "${docBuildDir}/${doc_dir}"
1054 @@ -1140,27 +266,6 @@
1058 -task convertMdFiles {
1059 - dependsOn copyDocs
1060 - def mdFiles = fileTree(dir: docBuildDir, include: "**/*.md")
1061 - def cssFile = file("${jalviewDir}/${flexmark_css}")
1064 - convertMdToHtml(mdFiles, cssFile)
1067 - inputs.files(mdFiles)
1068 - inputs.file(cssFile)
1070 - def htmlFiles = []
1071 - mdFiles.each { mdFile ->
1072 - def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html")
1073 - htmlFiles.add(file(htmlFilePath))
1075 - outputs.files(htmlFiles)
1079 task copyHelp(type: Copy) {
1080 def inputDir = helpSourceDir
1081 def outputDir = "${helpBuildDir}/${help_dir}"
1082 @@ -1242,24 +347,15 @@
1083 outputs.dir(outputDir)
1086 -task createBuildProperties(type: WriteProperties) {
1087 - dependsOn copyResources
1089 - description = "Create the ${buildProperties} file"
1091 - inputs.dir(sourceDir)
1092 - inputs.dir(resourcesBuildDir)
1093 - outputFile (buildProperties)
1094 - // taking time specific comment out to allow better incremental builds
1095 - comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
1096 - //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
1097 - property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
1098 - property "VERSION", JALVIEW_VERSION
1099 - property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
1100 - if (getdownSetAppBaseProperty) {
1101 - property "GETDOWNAPPBASE", getdownAppBase
1102 - property "GETDOWNAPPDISTDIR", getdownAppDistDir
1104 +task createBuildProperties(type: Copy) {
1105 + // using the build_properties already included in the source tarball
1106 + def inputFile = "build_properties"
1107 + def outputFile = buildProperties
1109 + into file(outputFile).getParent()
1110 + rename(file(inputFile).getName(), file(outputFile).getName())
1112 + inputs.file(inputFile)
1113 outputs.file(outputFile)
1116 @@ -1293,7 +389,6 @@
1117 dependsOn buildResources
1120 - dependsOn convertMdFiles
1121 dependsOn buildIndices
1124 @@ -1306,12 +401,7 @@
1125 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
1130 - dependsOn cloverClasses
1132 - dependsOn compileJava //?
1134 + dependsOn compileJava //?
1137 includeGroups testng_groups
1138 @@ -1323,6 +413,7 @@
1139 maxHeapSize = "1024m"
1141 workingDir = jalviewDir
1142 + //systemProperties 'clover.jar' System.properties.clover.jar
1143 def testLaf = project.findProperty("test_laf")
1144 if (testLaf != null) {
1145 println("Setting Test LaF to '${testLaf}'")
1146 @@ -1338,9 +429,6 @@
1147 jvmArgs += additional_compiler_args
1151 - println("Running tests " + (useClover?"WITH":"WITHOUT") + " clover")
1156 @@ -1420,1752 +508,7 @@
1157 sourceSets.main.resources.srcDirs.each{ dir ->
1160 - outputs.file("${outputDir}/${archiveFileName}")
1164 -task copyJars(type: Copy) {
1165 - from fileTree(dir: classesDir, include: "**/*.jar").files
1166 - into "${jalviewDir}/${package_dir}"
1170 -// doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
1171 -task syncJars(type: Sync) {
1173 - from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
1174 - into "${jalviewDir}/${package_dir}"
1176 - include jar.archiveFileName.getOrNull()
1183 - description = "Put all required libraries in dist"
1184 - // order of "cleanPackageDir", "copyJars", "jar" important!
1185 - jar.mustRunAfter cleanPackageDir
1186 - syncJars.mustRunAfter cleanPackageDir
1187 - dependsOn cleanPackageDir
1188 - dependsOn syncJars
1190 - outputs.dir("${jalviewDir}/${package_dir}")
1195 - dependsOn cleanPackageDir
1196 - dependsOn cleanTest
1202 - group = "distribution"
1203 - description = "Create a single jar file with all dependency libraries merged. Can be run with java -jar"
1205 - dependsOn makeDist
1207 - from ("${jalviewDir}/${libDistDir}") {
1211 - attributes "Implementation-Version": JALVIEW_VERSION,
1212 - "Application-Name": install4jApplicationName
1214 - mainClassName = shadow_jar_main_class
1215 - mergeServiceFiles()
1216 - classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
1221 -task getdownWebsite() {
1222 - group = "distribution"
1223 - description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
1225 - dependsOn makeDist
1228 - def getdownWebsiteResourceFilenames = []
1229 - def getdownTextString = ""
1230 - def getdownResourceDir = getdownResourceDir
1231 - def getdownResourceFilenames = []
1234 - // clean the getdown website and files dir before creating getdown folders
1235 - delete getdownWebsiteDir
1236 - delete getdownFilesDir
1239 - from buildProperties
1240 - rename(file(buildProperties).getName(), getdown_build_properties)
1241 - into getdownAppDir
1243 - getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
1245 - // set some getdown_txt_ properties then go through all properties looking for getdown_txt_...
1246 - def props = project.properties.sort { it.key }
1247 - if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) {
1248 - props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion)
1250 - if (getdownAltJavaMaxVersion != null && getdownAltJavaMaxVersion.length() > 0) {
1251 - props.put("getdown_txt_java_max_version", getdownAltJavaMaxVersion)
1253 - if (getdownAltMultiJavaLocation != null && getdownAltMultiJavaLocation.length() > 0) {
1254 - props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
1256 - if (getdownImagesDir != null && file(getdownImagesDir).exists()) {
1257 - props.put("getdown_txt_ui.background_image", "${getdownImagesDir}/${getdown_background_image}")
1258 - props.put("getdown_txt_ui.instant_background_image", "${getdownImagesDir}/${getdown_instant_background_image}")
1259 - props.put("getdown_txt_ui.error_background", "${getdownImagesDir}/${getdown_error_background}")
1260 - props.put("getdown_txt_ui.progress_image", "${getdownImagesDir}/${getdown_progress_image}")
1261 - props.put("getdown_txt_ui.icon", "${getdownImagesDir}/${getdown_icon}")
1262 - props.put("getdown_txt_ui.mac_dock_icon", "${getdownImagesDir}/${getdown_mac_dock_icon}")
1265 - props.put("getdown_txt_title", jalview_name)
1266 - props.put("getdown_txt_ui.name", install4jApplicationName)
1268 - // start with appbase
1269 - getdownTextString += "appbase = ${getdownAppBase}\n"
1270 - props.each{ prop, val ->
1271 - if (prop.startsWith("getdown_txt_") && val != null) {
1272 - if (prop.startsWith("getdown_txt_multi_")) {
1273 - def key = prop.substring(18)
1274 - val.split(",").each{ v ->
1275 - def line = "${key} = ${v}\n"
1276 - getdownTextString += line
1279 - // file values rationalised
1280 - if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1282 - if (val.indexOf('/') == 0) {
1285 - } else if (val.indexOf('/') > 0) {
1286 - // relative path (relative to jalviewDir)
1287 - r = file( "${jalviewDir}/${val}" )
1290 - val = "${getdown_resource_dir}/" + r.getName()
1291 - getdownWebsiteResourceFilenames += val
1292 - getdownResourceFilenames += r.getPath()
1295 - if (! prop.startsWith("getdown_txt_resource")) {
1296 - def line = prop.substring(12) + " = ${val}\n"
1297 - getdownTextString += line
1303 - getdownWebsiteResourceFilenames.each{ filename ->
1304 - getdownTextString += "resource = ${filename}\n"
1306 - getdownResourceFilenames.each{ filename ->
1309 - into getdownResourceDir
1313 - def getdownWrapperScripts = [ getdown_bash_wrapper_script, getdown_powershell_wrapper_script, getdown_batch_wrapper_script ]
1314 - getdownWrapperScripts.each{ script ->
1315 - def s = file( "${jalviewDir}/utils/getdown/${getdown_wrapper_script_dir}/${script}" )
1319 - into "${getdownWebsiteDir}/${getdown_wrapper_script_dir}"
1321 - getdownTextString += "resource = ${getdown_wrapper_script_dir}/${script}\n"
1325 - def codeFiles = []
1326 - fileTree(file(package_dir)).each{ f ->
1327 - if (f.isDirectory()) {
1328 - def files = fileTree(dir: f, include: ["*"]).getFiles()
1329 - codeFiles += files
1330 - } else if (f.exists()) {
1334 - codeFiles.sort().each{f ->
1335 - def name = f.getName()
1336 - def line = "code = ${getdownAppDistDir}/${name}\n"
1337 - getdownTextString += line
1340 - into getdownAppDir
1344 - // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1346 - if (JAVA_VERSION.equals("11")) {
1347 - def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1348 - j11libFiles.sort().each{f ->
1349 - def name = f.getName()
1350 - def line = "code = ${getdown_j11lib_dir}/${name}\n"
1351 - getdownTextString += line
1354 - into getdownJ11libDir
1360 - // 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.
1361 - //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1362 - getdownTextString += "resource = ${getdown_launcher_new}\n"
1363 - getdownTextString += "class = ${main_class}\n"
1364 - // Not setting these properties in general so that getdownappbase and getdowndistdir will default to release version in jalview.bin.Cache
1365 - if (getdownSetAppBaseProperty) {
1366 - getdownTextString += "jvmarg = -Dgetdowndistdir=${getdownAppDistDir}\n"
1367 - getdownTextString += "jvmarg = -Dgetdownappbase=${getdownAppBase}\n"
1370 - def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1371 - getdown_txt.write(getdownTextString)
1373 - def getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl"
1374 - def launchJvl = file("${getdownWebsiteDir}/${getdownLaunchJvl}")
1375 - launchJvl.write("appbase=${getdownAppBase}")
1377 - // files going into the getdown website dir: getdown-launcher.jar
1379 - from getdownLauncher
1380 - rename(file(getdownLauncher).getName(), getdown_launcher_new)
1381 - into getdownWebsiteDir
1384 - // files going into the getdown website dir: getdown-launcher(-local).jar
1386 - from getdownLauncher
1387 - if (file(getdownLauncher).getName() != getdown_launcher) {
1388 - rename(file(getdownLauncher).getName(), getdown_launcher)
1390 - into getdownWebsiteDir
1393 - // files going into the getdown website dir: ./install dir and files
1394 - if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1397 - from getdownLauncher
1398 - from "${getdownAppDir}/${getdown_build_properties}"
1399 - if (file(getdownLauncher).getName() != getdown_launcher) {
1400 - rename(file(getdownLauncher).getName(), getdown_launcher)
1402 - into getdownInstallDir
1405 - // and make a copy in the getdown files dir (these are not downloaded by getdown)
1407 - from getdownInstallDir
1408 - into getdownFilesInstallDir
1412 - // files going into the getdown files dir: getdown.txt, getdown-launcher.jar, channel-launch.jvl, build_properties
1416 - from getdownLauncher
1417 - from "${getdownWebsiteDir}/${getdown_build_properties}"
1418 - if (file(getdownLauncher).getName() != getdown_launcher) {
1419 - rename(file(getdownLauncher).getName(), getdown_launcher)
1421 - into getdownFilesDir
1424 - // and ./resources (not all downloaded by getdown)
1426 - from getdownResourceDir
1427 - into "${getdownFilesDir}/${getdown_resource_dir}"
1432 - inputs.dir("${jalviewDir}/${package_dir}")
1434 - outputs.dir(getdownWebsiteDir)
1435 - outputs.dir(getdownFilesDir)
1439 -// a helper task to allow getdown digest of any dir: `gradle getdownDigestDir -PDIGESTDIR=/path/to/my/random/getdown/dir
1440 -task getdownDigestDir(type: JavaExec) {
1442 - description "A task to run a getdown Digest on a dir with getdown.txt. Provide a DIGESTDIR property via -PDIGESTDIR=..."
1444 - def digestDirPropertyName = "DIGESTDIR"
1446 - classpath = files(getdownLauncher)
1447 - def digestDir = findProperty(digestDirPropertyName)
1448 - if (digestDir == null) {
1449 - throw new GradleException("Must provide a DIGESTDIR value to produce an alternative getdown digest")
1453 - main = "com.threerings.getdown.tools.Digester"
1457 -task getdownDigest(type: JavaExec) {
1458 - group = "distribution"
1459 - description = "Digest the getdown website folder"
1460 - dependsOn getdownWebsite
1462 - classpath = files(getdownLauncher)
1464 - main = "com.threerings.getdown.tools.Digester"
1465 - args getdownWebsiteDir
1466 - inputs.dir(getdownWebsiteDir)
1467 - outputs.file("${getdownWebsiteDir}/digest2.txt")
1472 - group = "distribution"
1473 - description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1474 - dependsOn getdownDigest
1476 - if (reportRsyncCommand) {
1477 - def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1478 - def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1479 - println "LIKELY RSYNC COMMAND:"
1480 - println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1481 - if (RUNRSYNC == "true") {
1483 - commandLine "mkdir", "-p", toDir
1486 - commandLine "rsync", "-avh", "--delete", fromDir, toDir
1494 -tasks.withType(JavaCompile) {
1495 - options.encoding = 'UTF-8'
1501 - delete getdownWebsiteDir
1502 - delete getdownFilesDir
1508 - if (file(install4jHomeDir).exists()) {
1510 - } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
1511 - install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1512 - } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
1513 - install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
1515 - installDir(file(install4jHomeDir))
1517 - mediaTypes = Arrays.asList(install4j_media_types.split(","))
1521 -task copyInstall4jTemplate {
1522 - def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
1523 - def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
1524 - inputs.file(install4jTemplateFile)
1525 - inputs.file(install4jFileAssociationsFile)
1526 - inputs.property("CHANNEL", { CHANNEL })
1527 - outputs.file(install4jConfFile)
1530 - def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
1532 - // turn off code signing if no OSX_KEYPASS
1533 - if (OSX_KEYPASS == "") {
1534 - install4jConfigXml.'**'.codeSigning.each { codeSigning ->
1535 - codeSigning.'@macEnabled' = "false"
1537 - install4jConfigXml.'**'.windows.each { windows ->
1538 - windows.'@runPostProcessor' = "false"
1542 - // turn off checksum creation for LOCAL channel
1543 - def e = install4jConfigXml.application[0]
1544 - if (CHANNEL == "LOCAL") {
1545 - e.'@createChecksums' = "false"
1547 - e.'@createChecksums' = "true"
1550 - // put file association actions where placeholder action is
1551 - def install4jFileAssociationsText = install4jFileAssociationsFile.text
1552 - def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
1553 - install4jConfigXml.'**'.action.any { a -> // .any{} stops after the first one that returns true
1554 - if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
1555 - def parent = a.parent()
1557 - fileAssociationActions.each { faa ->
1558 - parent.append(faa)
1560 - // don't need to continue in .any loop once replacements have been made
1565 - // use Windows Program Group with Examples folder for RELEASE, and Program Group without Examples for everything else
1566 - // NB we're deleting the /other/ one!
1567 - // Also remove the examples subdir from non-release versions
1568 - def customizedIdToDelete = "PROGRAM_GROUP_RELEASE"
1569 - // 2.11.1.0 NOT releasing with the Examples folder in the Program Group
1570 - if (false && CHANNEL=="RELEASE") { // remove 'false && ' to include Examples folder in RELEASE channel
1571 - customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE"
1573 - // remove the examples subdir from Full File Set
1574 - def files = install4jConfigXml.files[0]
1575 - def fileset = files.filesets.fileset.find { fs -> fs.'@customizedId' == "FULL_FILE_SET" }
1576 - def root = files.roots.root.find { r -> r.'@fileset' == fileset.'@id' }
1577 - def mountPoint = files.mountPoints.mountPoint.find { mp -> mp.'@root' == root.'@id' }
1578 - def dirEntry = files.entries.dirEntry.find { de -> de.'@mountPoint' == mountPoint.'@id' && de.'@subDirectory' == "examples" }
1579 - dirEntry.parent().remove(dirEntry)
1581 - install4jConfigXml.'**'.action.any { a ->
1582 - if (a.'@customizedId' == customizedIdToDelete) {
1583 - def parent = a.parent()
1589 - // write install4j file
1590 - install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
1597 - delete install4jConfFile
1602 -task installers(type: com.install4j.gradle.Install4jTask) {
1603 - group = "distribution"
1604 - description = "Create the install4j installers"
1606 - dependsOn copyInstall4jTemplate
1608 - projectFile = install4jConfFile
1610 - // create an md5 for the input files to use as version for install4j conf file
1611 - def digest = MessageDigest.getInstance("MD5")
1613 - (file("${install4jDir}/${install4j_template}").text +
1614 - file("${install4jDir}/${install4j_info_plist_file_associations}").text +
1615 - file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
1616 - def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
1617 - if (filesMd5.length() >= 8) {
1618 - filesMd5 = filesMd5.substring(0,8)
1620 - def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
1621 - // make install4jBuildDir relative to jalviewDir
1622 - def install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}"
1625 - 'JALVIEW_NAME': jalview_name,
1626 - 'JALVIEW_APPLICATION_NAME': install4jApplicationName,
1627 - 'JALVIEW_DIR': "../..",
1628 - 'OSX_KEYSTORE': OSX_KEYSTORE,
1629 - 'OSX_APPLEID': OSX_APPLEID,
1630 - 'OSX_ALTOOLPASS': OSX_ALTOOLPASS,
1631 - 'JSIGN_SH': JSIGN_SH,
1632 - 'JRE_DIR': getdown_app_dir_java,
1633 - 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
1634 - 'JALVIEW_VERSION': JALVIEW_VERSION,
1635 - 'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
1636 - 'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
1637 - 'JAVA_VERSION': JAVA_VERSION,
1638 - 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1639 - 'VERSION': JALVIEW_VERSION,
1640 - 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1641 - 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1642 - 'LINUX_JAVA_VM_DIR': linuxJavaVMDir,
1643 - 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1644 - 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1645 - 'LINUX_JAVA_VM_TGZ': linuxJavaVMTgz,
1646 - 'COPYRIGHT_MESSAGE': install4j_copyright_message,
1647 - 'BUNDLE_ID': install4jBundleId,
1648 - 'INTERNAL_ID': install4jInternalId,
1649 - 'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
1650 - 'MACOS_DMG_DS_STORE': install4jDMGDSStore,
1651 - 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage,
1652 - 'WRAPPER_LINK': getdownWrapperLink,
1653 - 'BASH_WRAPPER_SCRIPT': getdown_bash_wrapper_script,
1654 - 'POWERSHELL_WRAPPER_SCRIPT': getdown_powershell_wrapper_script,
1655 - 'WRAPPER_SCRIPT_BIN_DIR': getdown_wrapper_script_dir,
1656 - 'INSTALLER_NAME': install4jInstallerName,
1657 - 'INSTALL4J_UTILS_DIR': install4j_utils_dir,
1658 - 'GETDOWN_WEBSITE_DIR': getdown_website_dir,
1659 - 'GETDOWN_FILES_DIR': getdown_files_dir,
1660 - 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1661 - 'GETDOWN_DIST_DIR': getdownAppDistDir,
1662 - 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1663 - 'GETDOWN_INSTALL_DIR': getdown_install_dir,
1664 - 'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
1665 - 'BUILD_DIR': install4jBuildDir,
1666 - 'APPLICATION_CATEGORIES': install4j_application_categories,
1667 - 'APPLICATION_FOLDER': install4jApplicationFolder,
1668 - 'UNIX_APPLICATION_FOLDER': install4jUnixApplicationFolder,
1669 - 'EXECUTABLE_NAME': install4jExecutableName,
1670 - 'EXTRA_SCHEME': install4jExtraScheme,
1671 - 'MAC_ICONS_FILE': install4jMacIconsFile,
1672 - 'WINDOWS_ICONS_FILE': install4jWindowsIconsFile,
1673 - 'PNG_ICON_FILE': install4jPngIconFile,
1674 - 'BACKGROUND': install4jBackground,
1678 - //println("INSTALL4J VARIABLES:")
1679 - //variables.each{k,v->println("${k}=${v}")}
1681 - destination = "${jalviewDir}/${install4jBuildDir}"
1682 - buildSelected = true
1684 - if (install4j_faster.equals("true") || CHANNEL.startsWith("LOCAL")) {
1686 - disableSigning = true
1687 - disableNotarization = true
1690 - if (OSX_KEYPASS) {
1691 - macKeystorePassword = OSX_KEYPASS
1694 - if (OSX_ALTOOLPASS) {
1695 - appleIdPassword = OSX_ALTOOLPASS
1696 - disableNotarization = false
1698 - disableNotarization = true
1702 - println("Using projectFile "+projectFile)
1703 - if (!disableNotarization) { println("Will notarize OSX App DMG") }
1707 - inputs.dir(getdownWebsiteDir)
1708 - inputs.file(install4jConfFile)
1709 - inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
1710 - inputs.dir(macosJavaVMDir)
1711 - inputs.dir(windowsJavaVMDir)
1712 - outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
1718 - eclipse().configFile(eclipse_codestyle_file)
1723 -task sourceDist(type: Tar) {
1724 - group "distribution"
1725 - description "Create a source .tar.gz file for distribution"
1727 - dependsOn createBuildProperties
1728 - dependsOn convertMdFiles
1730 - def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1731 - def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1732 - archiveFileName = outputFileName
1734 - compression Compression.GZIP
1738 - def EXCLUDE_FILES=[
1749 - "**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales",
1751 - "utils/InstallAnywhere",
1754 - def PROCESS_FILES=[
1766 - "gradle.properties",
1772 - "**/*.properties",
1776 - def INCLUDE_FILES=[
1777 - ".settings/org.eclipse.jdt.core.jalview.prefs",
1780 - from(jalviewDir) {
1781 - exclude (EXCLUDE_FILES)
1782 - include (PROCESS_FILES)
1783 - filter(ReplaceTokens,
1787 - 'Version-Rel': JALVIEW_VERSION,
1788 - 'Year-Rel': getDate("yyyy")
1792 - from(jalviewDir) {
1793 - exclude (EXCLUDE_FILES)
1794 - exclude (PROCESS_FILES)
1795 - exclude ("appletlib")
1796 - exclude ("**/*locales")
1797 - exclude ("*locales/**")
1798 - exclude ("utils/InstallAnywhere")
1800 - exclude (getdown_files_dir)
1801 - exclude (getdown_website_dir)
1803 - // exluding these as not using jars as modules yet
1804 - exclude ("${j11modDir}/**/*.jar")
1806 - from(jalviewDir) {
1807 - include(INCLUDE_FILES)
1809 -// from (jalviewDir) {
1810 -// // explicit includes for stuff that seemed to not get included
1811 -// include(fileTree("test/**/*."))
1812 -// exclude(EXCLUDE_FILES)
1813 -// exclude(PROCESS_FILES)
1816 - from(file(buildProperties).getParent()) {
1817 - include(file(buildProperties).getName())
1818 - rename(file(buildProperties).getName(), "build_properties")
1820 - line.replaceAll("^INSTALLATION=.*\$","INSTALLATION=Source Release"+" git-commit\\\\:"+gitHash+" ["+gitBranch+"]")
1828 - dependsOn copyHelp
1829 - dependsOn pubhtmlhelp
1831 - inputs.dir("${helpBuildDir}/${help_dir}")
1832 - outputs.dir("${buildDir}/distributions/${help_dir}")
1836 -task j2sSetHeadlessBuild {
1838 - IN_ECLIPSE = false
1843 -task jalviewjsEnableAltFileProperty(type: WriteProperties) {
1845 - description "Enable the alternative J2S Config file for headless build"
1847 - outputFile = jalviewjsJ2sSettingsFileName
1848 - def j2sPropsFile = file(jalviewjsJ2sSettingsFileName)
1849 - def j2sProps = new Properties()
1850 - if (j2sPropsFile.exists()) {
1852 - def j2sPropsFileFIS = new FileInputStream(j2sPropsFile)
1853 - j2sProps.load(j2sPropsFileFIS)
1854 - j2sPropsFileFIS.close()
1856 - j2sProps.each { prop, val ->
1857 - property(prop, val)
1859 - } catch (Exception e) {
1860 - println("Exception reading ${jalviewjsJ2sSettingsFileName}")
1861 - e.printStackTrace()
1864 - if (! j2sProps.stringPropertyNames().contains(jalviewjs_j2s_alt_file_property_config)) {
1865 - property(jalviewjs_j2s_alt_file_property_config, jalviewjs_j2s_alt_file_property)
1870 -task jalviewjsSetEclipseWorkspace {
1871 - def propKey = "jalviewjs_eclipse_workspace"
1872 - def propVal = null
1873 - if (project.hasProperty(propKey)) {
1874 - propVal = project.getProperty(propKey)
1875 - if (propVal.startsWith("~/")) {
1876 - propVal = System.getProperty("user.home") + propVal.substring(1)
1879 - def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1880 - def propsFile = file(propsFileName)
1881 - def eclipseWsDir = propVal
1882 - def props = new Properties()
1884 - def writeProps = true
1885 - if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
1886 - def ins = new FileInputStream(propsFileName)
1889 - if (props.getProperty(propKey, null) != null) {
1890 - eclipseWsDir = props.getProperty(propKey)
1891 - writeProps = false
1895 - if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1896 - def tempDir = File.createTempDir()
1897 - eclipseWsDir = tempDir.getAbsolutePath()
1900 - eclipseWorkspace = file(eclipseWsDir)
1903 - // do not run a headless transpile when we claim to be in Eclipse
1905 - println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1906 - throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1908 - println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1912 - props.setProperty(propKey, eclipseWsDir)
1913 - propsFile.parentFile.mkdirs()
1914 - def bytes = new ByteArrayOutputStream()
1915 - props.store(bytes, null)
1916 - def propertiesString = bytes.toString()
1917 - propsFile.text = propertiesString
1920 - print("EXISTING ")
1923 - println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1926 - //inputs.property(propKey, eclipseWsDir) // eclipseWsDir only gets set once this task runs, so will be out-of-date
1927 - outputs.file(propsFileName)
1928 - outputs.upToDateWhen { eclipseWorkspace.exists() && propsFile.exists() }
1932 -task jalviewjsEclipsePaths {
1933 - def eclipseProduct
1935 - def eclipseRoot = jalviewjs_eclipse_root
1936 - if (eclipseRoot.startsWith("~/")) {
1937 - eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1939 - if (OperatingSystem.current().isMacOsX()) {
1940 - eclipseRoot += "/Eclipse.app"
1941 - eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1942 - eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1943 - } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1944 - if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1945 - eclipseRoot += "/eclipse"
1947 - eclipseBinary = "${eclipseRoot}/eclipse.exe"
1948 - eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1949 - } else { // linux or unix
1950 - if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1951 - eclipseRoot += "/eclipse"
1952 -println("eclipseDir exists")
1954 - eclipseBinary = "${eclipseRoot}/eclipse"
1955 - eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1958 - eclipseVersion = "4.13" // default
1959 - def assumedVersion = true
1960 - if (file(eclipseProduct).exists()) {
1961 - def fis = new FileInputStream(eclipseProduct)
1962 - def props = new Properties()
1964 - eclipseVersion = props.getProperty("version")
1966 - assumedVersion = false
1969 - def propKey = "eclipse_debug"
1970 - eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1973 - // do not run a headless transpile when we claim to be in Eclipse
1975 - println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1976 - throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1978 - println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1981 - if (!assumedVersion) {
1982 - println("ECLIPSE VERSION=${eclipseVersion}")
1988 -task printProperties {
1990 - description "Output to console all System.properties"
1992 - System.properties.each { key, val -> System.out.println("Property: ${key}=${val}") }
1997 -task eclipseSetup {
1998 - dependsOn eclipseProject
1999 - dependsOn eclipseClasspath
2000 - dependsOn eclipseJdt
2004 -// this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
2005 -task jalviewjsEclipseCopyDropins(type: Copy) {
2006 - dependsOn jalviewjsEclipsePaths
2008 - def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
2009 - inputFiles += file("${jalviewDir}/${jalviewjsJ2sPlugin}")
2010 - def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
2017 -// this eclipse -clean doesn't actually work
2018 -task jalviewjsCleanEclipse(type: Exec) {
2019 - dependsOn eclipseSetup
2020 - dependsOn jalviewjsEclipsePaths
2021 - dependsOn jalviewjsEclipseCopyDropins
2023 - executable(eclipseBinary)
2024 - args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
2025 - if (eclipseDebug) {
2030 - def inputString = """exit
2033 - def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
2034 - standardInput = inputByteStream
2037 -/* not really working yet
2038 -jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
2042 -task jalviewjsTransferUnzipSwingJs {
2043 - def file_zip = "${jalviewDir}/${jalviewjs_swingjs_zip}"
2047 - from zipTree(file_zip)
2048 - into "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2052 - inputs.file file_zip
2053 - outputs.dir "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2057 -task jalviewjsTransferUnzipLib {
2058 - def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
2061 - zipFiles.each { file_zip ->
2063 - from zipTree(file_zip)
2064 - into "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2069 - inputs.files zipFiles
2070 - outputs.dir "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2074 -task jalviewjsTransferUnzipAllLibs {
2075 - dependsOn jalviewjsTransferUnzipSwingJs
2076 - dependsOn jalviewjsTransferUnzipLib
2080 -task jalviewjsCreateJ2sSettings(type: WriteProperties) {
2082 - description "Create the alternative j2s file from the j2s.* properties"
2084 - jalviewjsJ2sProps = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
2085 - def siteDirProperty = "j2s.site.directory"
2086 - def setSiteDir = false
2087 - jalviewjsJ2sProps.each { prop, val ->
2088 - if (val != null) {
2089 - if (prop == siteDirProperty) {
2090 - if (!(val.startsWith('/') || val.startsWith("file://") )) {
2091 - val = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${val}"
2095 - property(prop,val)
2097 - if (!setSiteDir) { // default site location, don't override specifically set property
2098 - property(siteDirProperty,"${jalviewDirRelativePath}/${jalviewjsTransferSiteJsDir}")
2101 - outputFile = jalviewjsJ2sAltSettingsFileName
2103 - if (! IN_ECLIPSE) {
2104 - inputs.properties(jalviewjsJ2sProps)
2105 - outputs.file(jalviewjsJ2sAltSettingsFileName)
2110 -task jalviewjsEclipseSetup {
2111 - dependsOn jalviewjsEclipseCopyDropins
2112 - dependsOn jalviewjsSetEclipseWorkspace
2113 - dependsOn jalviewjsCreateJ2sSettings
2117 -task jalviewjsSyncAllLibs (type: Sync) {
2118 - dependsOn jalviewjsTransferUnzipAllLibs
2119 - def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteLibDir}")
2120 - inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
2121 - def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2125 - def outputFiles = []
2126 - rename { filename ->
2127 - outputFiles += "${outputDir}/${filename}"
2133 - outputs.files outputFiles
2134 - inputs.files inputFiles
2138 -task jalviewjsSyncResources (type: Sync) {
2139 - dependsOn buildResources
2141 - def inputFiles = fileTree(dir: resourcesBuildDir)
2142 - def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
2146 - def outputFiles = []
2147 - rename { filename ->
2148 - outputFiles += "${outputDir}/${filename}"
2154 - outputs.files outputFiles
2155 - inputs.files inputFiles
2159 -task jalviewjsSyncSiteResources (type: Sync) {
2160 - def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
2161 - def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2165 - def outputFiles = []
2166 - rename { filename ->
2167 - outputFiles += "${outputDir}/${filename}"
2173 - outputs.files outputFiles
2174 - inputs.files inputFiles
2178 -task jalviewjsSyncBuildProperties (type: Sync) {
2179 - dependsOn createBuildProperties
2180 - def inputFiles = [file(buildProperties)]
2181 - def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
2185 - def outputFiles = []
2186 - rename { filename ->
2187 - outputFiles += "${outputDir}/${filename}"
2193 - outputs.files outputFiles
2194 - inputs.files inputFiles
2198 -task jalviewjsProjectImport(type: Exec) {
2199 - dependsOn eclipseSetup
2200 - dependsOn jalviewjsEclipsePaths
2201 - dependsOn jalviewjsEclipseSetup
2204 - // do not run a headless import when we claim to be in Eclipse
2206 - println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2207 - throw new StopExecutionException("Not running headless import whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
2209 - println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2213 - //def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
2214 - def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview"
2215 - executable(eclipseBinary)
2216 - args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
2217 - if (eclipseDebug) {
2220 - args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
2221 - if (!IN_ECLIPSE) {
2222 - args += [ "-D${j2sHeadlessBuildProperty}=true" ]
2223 - args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ]
2226 - inputs.file("${jalviewDir}/.project")
2227 - outputs.upToDateWhen {
2228 - file(projdir).exists()
2233 -task jalviewjsTranspile(type: Exec) {
2234 - dependsOn jalviewjsEclipseSetup
2235 - dependsOn jalviewjsProjectImport
2236 - dependsOn jalviewjsEclipsePaths
2237 - if (!IN_ECLIPSE) {
2238 - dependsOn jalviewjsEnableAltFileProperty
2242 - // do not run a headless transpile when we claim to be in Eclipse
2244 - println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2245 - throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
2247 - println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2251 - executable(eclipseBinary)
2252 - args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
2253 - if (eclipseDebug) {
2256 - args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
2257 - if (!IN_ECLIPSE) {
2258 - args += [ "-D${j2sHeadlessBuildProperty}=true" ]
2259 - args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ]
2265 - stdout = new ByteArrayOutputStream()
2266 - stderr = new ByteArrayOutputStream()
2268 - def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}"
2269 - def logOutFile = file(logOutFileName)
2270 - logOutFile.createNewFile()
2271 - logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
2272 -BINARY: ${eclipseBinary}
2273 -VERSION: ${eclipseVersion}
2274 -WORKSPACE: ${eclipseWorkspace}
2275 -DEBUG: ${eclipseDebug}
2278 - def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
2279 - // combine stdout and stderr
2280 - def logErrFOS = logOutFOS
2282 - if (jalviewjs_j2s_to_console.equals("true")) {
2283 - standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2284 - new org.apache.tools.ant.util.TeeOutputStream(
2288 - errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2289 - new org.apache.tools.ant.util.TeeOutputStream(
2294 - standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2297 - errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2304 - if (stdout.toString().contains("Error processing ")) {
2305 - // j2s did not complete transpile
2306 - //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
2307 - if (jalviewjs_ignore_transpile_errors.equals("true")) {
2308 - println("IGNORING TRANSPILE ERRORS")
2309 - println("See eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
2311 - throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
2316 - inputs.dir("${jalviewDir}/${sourceDir}")
2317 - outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
2318 - outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
2322 -def jalviewjsCallCore(String name, FileCollection list, String prefixFile, String suffixFile, String jsfile, String zjsfile, File logOutFile, Boolean logOutConsole) {
2324 - def stdout = new ByteArrayOutputStream()
2325 - def stderr = new ByteArrayOutputStream()
2327 - def coreFile = file(jsfile)
2329 - msg = "Creating core for ${name}...\nGenerating ${jsfile}"
2331 - logOutFile.createNewFile()
2332 - logOutFile.append(msg+"\n")
2334 - def coreTop = file(prefixFile)
2335 - def coreBottom = file(suffixFile)
2336 - coreFile.getParentFile().mkdirs()
2337 - coreFile.createNewFile()
2338 - coreFile.write( coreTop.getText("UTF-8") )
2342 - def t = f.getText("UTF-8")
2343 - t.replaceAll("Clazz\\.([^_])","Clazz_${1}")
2344 - coreFile.append( t )
2346 - msg = "...file '"+f.getPath()+"' does not exist, skipping"
2348 - logOutFile.append(msg+"\n")
2351 - coreFile.append( coreBottom.getText("UTF-8") )
2353 - msg = "Generating ${zjsfile}"
2355 - logOutFile.append(msg+"\n")
2356 - def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
2357 - def logErrFOS = logOutFOS
2360 - classpath = files(["${jalviewDir}/${jalviewjs_closure_compiler}"])
2361 - main = "com.google.javascript.jscomp.CommandLineRunner"
2362 - jvmArgs = [ "-Dfile.encoding=UTF-8" ]
2363 - args = [ "--compilation_level", "SIMPLE_OPTIMIZATIONS", "--warning_level", "QUIET", "--charset", "UTF-8", "--js", jsfile, "--js_output_file", zjsfile ]
2364 - maxHeapSize = "2g"
2366 - msg = "\nRunning '"+commandLine.join(' ')+"'\n"
2368 - logOutFile.append(msg+"\n")
2370 - if (logOutConsole) {
2371 - standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2372 - new org.apache.tools.ant.util.TeeOutputStream(
2376 - errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2377 - new org.apache.tools.ant.util.TeeOutputStream(
2382 - standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2385 - errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2392 - logOutFile.append(msg+"\n")
2396 -task jalviewjsBuildAllCores {
2398 - description "Build the core js lib closures listed in the classlists dir"
2399 - dependsOn jalviewjsTranspile
2400 - dependsOn jalviewjsTransferUnzipSwingJs
2402 - def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}"
2403 - def swingJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_j2s_subdir}"
2404 - def libJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${jalviewjs_j2s_subdir}"
2405 - def jsDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_js_subdir}"
2406 - def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core"
2407 - def prefixFile = "${jsDir}/core/coretop2.js"
2408 - def suffixFile = "${jsDir}/core/corebottom2.js"
2410 - inputs.file prefixFile
2411 - inputs.file suffixFile
2413 - def classlistFiles = []
2414 - // add the classlists found int the jalviewjs_classlists_dir
2415 - fileTree(dir: "${jalviewDir}/${jalviewjs_classlists_dir}", include: "*.txt").each {
2417 - def name = file.getName() - ".txt"
2418 - classlistFiles += [
2424 - // _jmol and _jalview cores. Add any other peculiar classlist.txt files here
2425 - //classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jmol}"), 'name': "_jvjmol" ]
2426 - classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jalview}"), 'name': jalviewjsJalviewCoreName ]
2428 - jalviewjsCoreClasslists = []
2430 - classlistFiles.each {
2433 - def file = hash['file']
2434 - if (! file.exists()) {
2435 - //println("...classlist file '"+file.getPath()+"' does not exist, skipping")
2436 - return false // this is a "continue" in groovy .each closure
2438 - def name = hash['name']
2439 - if (name == null) {
2440 - name = file.getName() - ".txt"
2448 - def list = fileTree(dir: j2sDir, includes: filelist)
2450 - def jsfile = "${outputDir}/core${name}.js"
2451 - def zjsfile = "${outputDir}/core${name}.z.js"
2453 - jalviewjsCoreClasslists += [
2455 - 'zjsfile': zjsfile,
2461 - inputs.files(list)
2462 - outputs.file(jsfile)
2463 - outputs.file(zjsfile)
2466 - // _stevesoft core. add any cores without a classlist here (and the inputs and outputs)
2467 - def stevesoftClasslistName = "_stevesoft"
2468 - def stevesoftClasslist = [
2469 - 'jsfile': "${outputDir}/core${stevesoftClasslistName}.js",
2470 - 'zjsfile': "${outputDir}/core${stevesoftClasslistName}.z.js",
2471 - 'list': fileTree(dir: j2sDir, include: "com/stevesoft/pat/**/*.js"),
2472 - 'name': stevesoftClasslistName
2474 - jalviewjsCoreClasslists += stevesoftClasslist
2475 - inputs.files(stevesoftClasslist['list'])
2476 - outputs.file(stevesoftClasslist['jsfile'])
2477 - outputs.file(stevesoftClasslist['zjsfile'])
2480 - def allClasslistName = "_all"
2481 - def allJsFiles = fileTree(dir: j2sDir, include: "**/*.js")
2482 - allJsFiles += fileTree(
2484 - include: "**/*.js",
2486 - // these exlusions are files that the closure-compiler produces errors for. Should fix them
2487 - "**/org/jmol/jvxl/readers/IsoIntersectFileReader.js",
2488 - "**/org/jmol/export/JSExporter.js"
2491 - allJsFiles += fileTree(
2493 - include: "**/*.js",
2495 - // these exlusions are files that the closure-compiler produces errors for. Should fix them
2496 - "**/sun/misc/Unsafe.js",
2497 - "**/swingjs/jquery/jquery-editable-select.js",
2498 - "**/swingjs/jquery/j2sComboBox.js",
2499 - "**/sun/misc/FloatingDecimal.js"
2502 - def allClasslist = [
2503 - 'jsfile': "${outputDir}/core${allClasslistName}.js",
2504 - 'zjsfile': "${outputDir}/core${allClasslistName}.z.js",
2505 - 'list': allJsFiles,
2506 - 'name': allClasslistName
2508 - // not including this version of "all" core at the moment
2509 - //jalviewjsCoreClasslists += allClasslist
2510 - inputs.files(allClasslist['list'])
2511 - outputs.file(allClasslist['jsfile'])
2512 - outputs.file(allClasslist['zjsfile'])
2515 - def logOutFile = file("${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_closure_stdout}")
2516 - logOutFile.getParentFile().mkdirs()
2517 - logOutFile.createNewFile()
2518 - logOutFile.write(getDate("yyyy-MM-dd HH:mm:ss")+" jalviewjsBuildAllCores\n----\n")
2520 - jalviewjsCoreClasslists.each {
2521 - jalviewjsCallCore(it.name, it.list, prefixFile, suffixFile, it.jsfile, it.zjsfile, logOutFile, jalviewjs_j2s_to_console.equals("true"))
2528 -def jalviewjsPublishCoreTemplate(String coreName, String templateName, File inputFile, String outputFile) {
2531 - into file(outputFile).getParentFile()
2532 - rename { filename ->
2533 - if (filename.equals(inputFile.getName())) {
2534 - return file(outputFile).getName()
2538 - filter(ReplaceTokens,
2542 - 'MAIN': '"'+main_class+'"',
2544 - 'NAME': jalviewjsJalviewTemplateName+" [core ${coreName}]",
2545 - 'COREKEY': jalviewjs_core_key,
2546 - 'CORENAME': coreName
2553 -task jalviewjsPublishCoreTemplates {
2554 - dependsOn jalviewjsBuildAllCores
2555 - def inputFileName = "${jalviewDir}/${j2s_coretemplate_html}"
2556 - def inputFile = file(inputFileName)
2557 - def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2559 - def outputFiles = []
2560 - jalviewjsCoreClasslists.each { cl ->
2561 - def outputFile = "${outputDir}/${jalviewjsJalviewTemplateName}_${cl.name}.html"
2562 - cl['outputfile'] = outputFile
2563 - outputFiles += outputFile
2567 - jalviewjsCoreClasslists.each { cl ->
2568 - jalviewjsPublishCoreTemplate(cl.name, jalviewjsJalviewTemplateName, inputFile, cl.outputfile)
2571 - inputs.file(inputFile)
2572 - outputs.files(outputFiles)
2576 -task jalviewjsSyncCore (type: Sync) {
2577 - dependsOn jalviewjsBuildAllCores
2578 - dependsOn jalviewjsPublishCoreTemplates
2579 - def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
2580 - def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2584 - def outputFiles = []
2585 - rename { filename ->
2586 - outputFiles += "${outputDir}/${filename}"
2592 - outputs.files outputFiles
2593 - inputs.files inputFiles
2597 -// this Copy version of TransferSiteJs will delete anything else in the target dir
2598 -task jalviewjsCopyTransferSiteJs(type: Copy) {
2599 - dependsOn jalviewjsTranspile
2600 - from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2601 - into "${jalviewDir}/${jalviewjsSiteDir}"
2605 -// this Sync version of TransferSite is used by buildship to keep the website automatically up to date when a file changes
2606 -task jalviewjsSyncTransferSiteJs(type: Sync) {
2607 - from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2609 - into "${jalviewDir}/${jalviewjsSiteDir}"
2616 -jalviewjsSyncAllLibs.mustRunAfter jalviewjsCopyTransferSiteJs
2617 -jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSiteJs
2618 -jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSiteJs
2619 -jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSiteJs
2621 -jalviewjsSyncAllLibs.mustRunAfter jalviewjsSyncTransferSiteJs
2622 -jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSiteJs
2623 -jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSiteJs
2624 -jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSiteJs
2627 -task jalviewjsPrepareSite {
2629 - description "Prepares the website folder including unzipping files and copying resources"
2630 - dependsOn jalviewjsSyncAllLibs
2631 - dependsOn jalviewjsSyncResources
2632 - dependsOn jalviewjsSyncSiteResources
2633 - dependsOn jalviewjsSyncBuildProperties
2634 - dependsOn jalviewjsSyncCore
2638 -task jalviewjsBuildSite {
2640 - description "Builds the whole website including transpiled code"
2641 - dependsOn jalviewjsCopyTransferSiteJs
2642 - dependsOn jalviewjsPrepareSite
2646 -task cleanJalviewjsTransferSite {
2648 - delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2649 - delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2650 - delete "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2651 - delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2656 -task cleanJalviewjsSite {
2657 - dependsOn cleanJalviewjsTransferSite
2659 - delete "${jalviewDir}/${jalviewjsSiteDir}"
2664 -task jalviewjsSiteTar(type: Tar) {
2666 - description "Creates a tar.gz file for the website"
2667 - dependsOn jalviewjsBuildSite
2668 - def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
2669 - archiveFileName = outputFilename
2671 - compression Compression.GZIP
2673 - from "${jalviewDir}/${jalviewjsSiteDir}"
2674 - into jalviewjs_site_dir // this is inside the tar file
2676 - inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
2680 -task jalviewjsServer {
2682 - def filename = "jalviewjsTest.html"
2683 - description "Starts a webserver on localhost to test the website. See ${filename} to access local site on most recently used port."
2684 - def htmlFile = "${jalviewDirAbsolutePath}/${filename}"
2689 - def f = Class.forName("org.gradle.plugins.javascript.envjs.http.simple.SimpleHttpFileServerFactory")
2690 - factory = f.newInstance()
2691 - } catch (ClassNotFoundException e) {
2692 - throw new GradleException("Unable to create SimpleHttpFileServerFactory")
2694 - def port = Integer.valueOf(jalviewjs_server_port)
2696 - def running = false
2698 - def jalviewjsServer
2699 - while(port < start+1000 && !running) {
2701 - def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
2702 - jalviewjsServer = factory.start(doc_root, port)
2704 - url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
2705 - println("SERVER STARTED with document root ${doc_root}.")
2706 - println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
2707 - println("For debug: "+url+"?j2sdebug")
2708 - println("For verbose: "+url+"?j2sverbose")
2709 - } catch (Exception e) {
2713 - def htmlText = """
2714 - <p><a href="${url}">JalviewJS Test. <${url}></a></p>
2715 - <p><a href="${url}?j2sdebug">JalviewJS Test with debug. <${url}?j2sdebug></a></p>
2716 - <p><a href="${url}?j2sverbose">JalviewJS Test with verbose. <${url}?j2sdebug></a></p>
2718 - jalviewjsCoreClasslists.each { cl ->
2719 - def urlcore = jalviewjsServer.getResourceUrl(file(cl.outputfile).getName())
2721 - <p><a href="${urlcore}">${jalviewjsJalviewTemplateName} [core ${cl.name}]. <${urlcore}></a></p>
2723 - println("For core ${cl.name}: "+urlcore)
2726 - file(htmlFile).text = htmlText
2729 - outputs.file(htmlFile)
2730 - outputs.upToDateWhen({false})
2734 -task cleanJalviewjsAll {
2736 - description "Delete all configuration and build artifacts to do with JalviewJS build"
2737 - dependsOn cleanJalviewjsSite
2738 - dependsOn jalviewjsEclipsePaths
2741 - delete "${jalviewDir}/${jalviewjsBuildDir}"
2742 - delete "${jalviewDir}/${eclipse_bin_dir}"
2743 - if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
2744 - delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
2746 - delete jalviewjsJ2sAltSettingsFileName
2749 - outputs.upToDateWhen( { false } )
2753 -task jalviewjsIDE_checkJ2sPlugin {
2754 - group "00 JalviewJS in Eclipse"
2755 - description "Compare the swingjs/net.sf.j2s.core(-j11)?.jar file with the Eclipse IDE's plugin version (found in the 'dropins' dir)"
2758 - def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}")
2759 - def j2sPluginFile = file(j2sPlugin)
2760 - def eclipseHome = System.properties["eclipse.home.location"]
2761 - if (eclipseHome == null || ! IN_ECLIPSE) {
2762 - throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.")
2764 - def eclipseJ2sPluginDirs = [ "${eclipseHome}/dropins" ]
2765 - def altPluginsDir = System.properties["org.eclipse.equinox.p2.reconciler.dropins.directory"]
2766 - if (altPluginsDir != null && file(altPluginsDir).exists()) {
2767 - eclipseJ2sPluginDirs += altPluginsDir
2769 - def foundPlugin = false
2770 - def j2sPluginFileName = j2sPluginFile.getName()
2771 - def eclipseJ2sPlugin
2772 - def eclipseJ2sPluginFile
2773 - eclipseJ2sPluginDirs.any { dir ->
2774 - eclipseJ2sPlugin = "${dir}/${j2sPluginFileName}"
2775 - eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
2776 - if (eclipseJ2sPluginFile.exists()) {
2777 - foundPlugin = true
2781 - if (!foundPlugin) {
2782 - def msg = "Eclipse J2S Plugin is not installed (could not find '${j2sPluginFileName}' in\n"+eclipseJ2sPluginDirs.join("\n")+"\n)\nTry running task jalviewjsIDE_copyJ2sPlugin"
2783 - System.err.println(msg)
2784 - throw new StopExecutionException(msg)
2787 - def digest = MessageDigest.getInstance("MD5")
2789 - digest.update(j2sPluginFile.text.bytes)
2790 - def j2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2792 - digest.update(eclipseJ2sPluginFile.text.bytes)
2793 - def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2795 - if (j2sPluginMd5 != eclipseJ2sPluginMd5) {
2796 - def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'"
2797 - System.err.println(msg)
2798 - throw new StopExecutionException(msg)
2800 - def msg = "Eclipse J2S Plugin '${eclipseJ2sPlugin}' is the same as '${j2sPlugin}' (this is good)"
2806 -task jalviewjsIDE_copyJ2sPlugin {
2807 - group "00 JalviewJS in Eclipse"
2808 - description "Copy the swingjs/net.sf.j2s.core(-j11)?.jar file into the Eclipse IDE's 'dropins' dir"
2811 - def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}")
2812 - def j2sPluginFile = file(j2sPlugin)
2813 - def eclipseHome = System.properties["eclipse.home.location"]
2814 - if (eclipseHome == null || ! IN_ECLIPSE) {
2815 - throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. NOT copying J2S Plugin.")
2817 - def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}"
2818 - def eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
2819 - def msg = "WARNING! Copying this commit's j2s plugin '${j2sPlugin}' to Eclipse J2S Plugin '${eclipseJ2sPlugin}'\n* May require an Eclipse restart"
2820 - System.err.println(msg)
2823 - eclipseJ2sPluginFile.getParentFile().mkdirs()
2824 - into eclipseJ2sPluginFile.getParent()
2830 -task jalviewjsIDE_j2sFile {
2831 - group "00 JalviewJS in Eclipse"
2832 - description "Creates the .j2s file"
2833 - dependsOn jalviewjsCreateJ2sSettings
2837 -task jalviewjsIDE_SyncCore {
2838 - group "00 JalviewJS in Eclipse"
2839 - description "Build the core js lib closures listed in the classlists dir and publish core html from template"
2840 - dependsOn jalviewjsSyncCore
2844 -task jalviewjsIDE_SyncSiteAll {
2845 - dependsOn jalviewjsSyncAllLibs
2846 - dependsOn jalviewjsSyncResources
2847 - dependsOn jalviewjsSyncSiteResources
2848 - dependsOn jalviewjsSyncBuildProperties
2852 -cleanJalviewjsTransferSite.mustRunAfter jalviewjsIDE_SyncSiteAll
2855 -task jalviewjsIDE_PrepareSite {
2856 - group "00 JalviewJS in Eclipse"
2857 - description "Sync libs and resources to site dir, but not closure cores"
2859 - dependsOn jalviewjsIDE_SyncSiteAll
2860 - //dependsOn cleanJalviewjsTransferSite // not sure why this clean is here -- will slow down a re-run of this task
2864 -task jalviewjsIDE_AssembleSite {
2865 - group "00 JalviewJS in Eclipse"
2866 - description "Assembles unzipped supporting zipfiles, resources, site resources and closure cores into the Eclipse transpiled site"
2867 - dependsOn jalviewjsPrepareSite
2871 -task jalviewjsIDE_SiteClean {
2872 - group "00 JalviewJS in Eclipse"
2873 - description "Deletes the Eclipse transpiled site"
2874 - dependsOn cleanJalviewjsSite
2878 -task jalviewjsIDE_Server {
2879 - group "00 JalviewJS in Eclipse"
2880 - description "Starts a webserver on localhost to test the website"
2881 - dependsOn jalviewjsServer
2885 -// buildship runs this at import or gradle refresh
2886 -task eclipseSynchronizationTask {
2887 - //dependsOn eclipseSetup
2888 - dependsOn createBuildProperties
2889 - if (J2S_ENABLED) {
2890 - dependsOn jalviewjsIDE_j2sFile
2891 - dependsOn jalviewjsIDE_checkJ2sPlugin
2892 - dependsOn jalviewjsIDE_PrepareSite
2897 -// buildship runs this at build time or project refresh
2898 -task eclipseAutoBuildTask {
2899 - //dependsOn jalviewjsIDE_checkJ2sPlugin
2900 - //dependsOn jalviewjsIDE_PrepareSite
2901 + outputs.file("${outputDir}/${archiveFileName}")
2907 - description "Build the site"
2908 - dependsOn jalviewjsBuildSite