1 /* Convention for properties. Read from gradle.properties, use lower_case_underlines for property names.
2 * For properties set within build.gradle, use camelCaseNoSpace.
4 import org.apache.tools.ant.filters.ReplaceTokens
5 import org.gradle.internal.os.OperatingSystem
6 import org.gradle.plugins.ide.internal.generator.PropertiesPersistableConfigurationObject
7 import org.gradle.api.internal.PropertiesTransformer
8 import org.gradle.util.ConfigureUtil
9 import org.gradle.plugins.ide.eclipse.model.Output
10 import org.gradle.plugins.ide.eclipse.model.Library
11 import java.security.MessageDigest
12 import groovy.transform.ExternalizeMethods
13 import groovy.util.XmlParser
14 import groovy.xml.XmlUtil
15 import com.vladsch.flexmark.util.ast.Node
16 import com.vladsch.flexmark.html.HtmlRenderer
17 import com.vladsch.flexmark.parser.Parser
18 import com.vladsch.flexmark.util.data.MutableDataSet
19 import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension
20 import com.vladsch.flexmark.ext.tables.TablesExtension
21 import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension
22 import com.vladsch.flexmark.ext.autolink.AutolinkExtension
23 import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension
24 import com.vladsch.flexmark.ext.toc.TocExtension
32 classpath "com.vladsch.flexmark:flexmark-all:0.62.0"
41 id "com.diffplug.gradle.spotless" version "3.28.0"
42 id 'com.github.johnrengelman.shadow' version '4.0.3'
43 id 'com.install4j.gradle' version '8.0.4'
44 id 'com.dorongold.task-tree' version '1.5' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
55 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
56 def string(Object o) {
57 return o == null ? "" : o.toString()
62 jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
63 jalviewDirRelativePath = jalviewDir
65 // local build environment properties
66 // can be "projectDir/local.properties"
67 def localProps = "${projectDir}/local.properties"
69 if (file(localProps).exists()) {
70 propsFile = localProps
72 // or "../projectDir_local.properties"
73 def dirLocalProps = projectDir.getParent() + "/" + projectDir.getName() + "_local.properties"
74 if (file(dirLocalProps).exists()) {
75 propsFile = dirLocalProps
77 if (propsFile != null) {
79 def p = new Properties()
80 def localPropsFIS = new FileInputStream(propsFile)
85 def oldval = findProperty(key)
88 println("Overriding property '${key}' ('${oldval}') with ${file(propsFile).getName()} value '${val}'")
90 println("Setting unknown property '${key}' with ${file(propsFile).getName()}s value '${val}'")
93 } catch (Exception e) {
94 System.out.println("Exception reading local.properties")
99 // Import releaseProps from the RELEASE file
100 // or a file specified via JALVIEW_RELEASE_FILE if defined
101 // Expect jalview.version and target release branch in jalview.release
102 def releaseProps = new Properties();
103 def releasePropFile = findProperty("JALVIEW_RELEASE_FILE");
104 def defaultReleasePropFile = "${jalviewDirAbsolutePath}/RELEASE";
106 (new File(releasePropFile!=null ? releasePropFile : defaultReleasePropFile)).withInputStream {
107 releaseProps.load(it)
109 } catch (Exception fileLoadError) {
110 throw new Error("Couldn't load release properties file "+(releasePropFile==null ? defaultReleasePropFile : "from custom location: releasePropFile"),fileLoadError);
113 // Set JALVIEW_VERSION if it is not already set
114 if (findProperty("JALVIEW_VERSION")==null || "".equals(JALVIEW_VERSION)) {
115 JALVIEW_VERSION = releaseProps.get("jalview.version")
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]}'")
131 println("WITHIN ECLIPSE IDE")
133 println("HEADLESS BUILD")
136 J2S_ENABLED = (project.hasProperty('j2s.compiler.status') && project['j2s.compiler.status'] != null && project['j2s.compiler.status'] == "enable")
138 println("J2S ENABLED")
141 System.properties.sort { it.key }.each {
142 key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
145 if (false && IN_ECLIPSE) {
146 jalviewDir = jalviewDirAbsolutePath
151 bareSourceDir = string(source_dir)
152 sourceDir = string("${jalviewDir}/${bareSourceDir}")
153 resourceDir = string("${jalviewDir}/${resource_dir}")
154 bareTestSourceDir = string(test_source_dir)
155 testDir = string("${jalviewDir}/${bareTestSourceDir}")
157 classesDir = string("${jalviewDir}/${classes_dir}")
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")
170 resourceClassesDir = useClover ? cloverClassesDir : classesDir
172 testSourceDir = useClover ? cloverTestInstrDir : testDir
173 testClassesDir = useClover ? cloverTestClassesDir : "${jalviewDir}/${test_output_dir}"
175 getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
178 // the following values might be overridden by the CHANNEL switch
179 getdownChannelName = CHANNEL.toLowerCase()
180 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
181 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
182 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
183 getdownAppDistDir = getdown_app_dir_alt
184 buildProperties = string("${resourceDir}/${build_properties_file}")
185 reportRsyncCommand = false
186 jvlChannelName = CHANNEL.toLowerCase()
187 install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build
188 install4jDSStore = "DS_Store-NON-RELEASE"
189 install4jDMGBackgroundImage = "jalview_dmg_background-NON-RELEASE.png"
190 install4jInstallerName = "${jalview_name} Non-Release Installer"
191 install4jExecutableName = jalview_name.replaceAll("[^\\w]+", "_").toLowerCase()
192 install4jExtraScheme = "jalviewx"
196 // TODO: get bamboo build artifact URL for getdown artifacts
197 getdown_channel_base = bamboo_channelbase
198 getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
199 getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
200 jvlChannelName += "_${getdownChannelName}"
201 // automatically add the test group Not-bamboo for exclusion
202 if ("".equals(testng_excluded_groups)) {
203 testng_excluded_groups = "Not-bamboo"
205 install4jExtraScheme = "jalviewb"
209 getdownAppDistDir = getdown_app_dir_release
210 reportRsyncCommand = true
212 install4jDSStore = "DS_Store"
213 install4jDMGBackgroundImage = "jalview_dmg_background.png"
214 install4jInstallerName = "${jalview_name} Installer"
218 getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
219 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
220 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
221 if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
222 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
224 package_dir = string("${ARCHIVEDIR}/${package_dir}")
225 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
228 reportRsyncCommand = true
229 install4jExtraScheme = "jalviewa"
233 getdownChannelName = string("archive/${JALVIEW_VERSION}")
234 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
235 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
236 if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
237 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
239 package_dir = string("${ARCHIVEDIR}/${package_dir}")
240 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
243 reportRsyncCommand = true
244 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
245 install4jSuffix = "Archive"
246 install4jExtraScheme = "jalviewa"
250 reportRsyncCommand = true
252 // DEVELOP-RELEASE is usually associated with a Jalview release series so set the version
253 JALVIEW_VERSION=JALVIEW_VERSION+"-develop"
255 install4jSuffix = "Develop"
256 install4jDSStore = "DS_Store-DEVELOP"
257 install4jDMGBackgroundImage = "jalview_dmg_background-DEVELOP.png"
258 install4jExtraScheme = "jalviewd"
259 install4jInstallerName = "${jalview_name} Develop Installer"
263 reportRsyncCommand = true
264 // Don't ignore transpile errors for release build
265 if (jalviewjs_ignore_transpile_errors.equals("true")) {
266 jalviewjs_ignore_transpile_errors = "false"
267 println("Setting jalviewjs_ignore_transpile_errors to 'false'")
269 JALVIEW_VERSION = JALVIEW_VERSION+"-test"
270 install4jSuffix = "Test"
271 install4jDSStore = "DS_Store-TEST-RELEASE"
272 install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
273 install4jExtraScheme = "jalviewt"
274 install4jInstallerName = "${jalview_name} Test Installer"
277 case ~/^SCRATCH(|-[-\w]*)$/:
278 getdownChannelName = CHANNEL
279 JALVIEW_VERSION = JALVIEW_VERSION+"-"+CHANNEL
281 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
282 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
283 reportRsyncCommand = true
284 install4jSuffix = "Scratch"
288 if (!file("${LOCALDIR}").exists()) {
289 throw new GradleException("Must provide a LOCALDIR value to produce a local distribution")
291 getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
292 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
294 JALVIEW_VERSION = "TEST"
295 install4jSuffix = "Test-Local"
296 install4jDSStore = "DS_Store-TEST-RELEASE"
297 install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
298 install4jExtraScheme = "jalviewt"
299 install4jInstallerName = "${jalview_name} Test Installer"
303 JALVIEW_VERSION = "TEST"
304 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
305 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
306 install4jExtraScheme = "jalviewl"
309 default: // something wrong specified
310 throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
314 // override getdownAppBase if requested
315 if (findProperty("getdown_appbase_override") != null) {
316 getdownAppBase = string(getProperty("getdown_appbase_override"))
317 println("Overriding getdown appbase with '${getdownAppBase}'")
319 // sanitise file name for jalview launcher file for this channel
320 jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_")
321 // install4j application and folder names
322 if (install4jSuffix == "") {
323 install4jApplicationName = "${jalview_name}"
324 install4jBundleId = "${install4j_bundle_id}"
325 install4jWinApplicationId = install4j_release_win_application_id
327 install4jApplicationName = "${jalview_name} ${install4jSuffix}"
328 install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase()
329 // add int hash of install4jSuffix to the last part of the application_id
330 def id = install4j_release_win_application_id
331 def idsplitreverse = id.split("-").reverse()
332 idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode()
333 install4jWinApplicationId = idsplitreverse.reverse().join("-")
335 // sanitise folder and id names
336 // install4jApplicationFolder = e.g. "Jalview Build"
337 install4jApplicationFolder = install4jApplicationName
338 .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \
339 .replaceAll("_+", "_") // collapse __
340 install4jInternalId = install4jApplicationName
342 .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
343 .replaceAll("_+", "") // collapse __
344 //.replaceAll("_*-_*", "-") // collapse _-_
345 install4jUnixApplicationFolder = install4jApplicationName
347 .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
348 .replaceAll("_+", "_") // collapse __
349 .replaceAll("_*-_*", "-") // collapse _-_
352 getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
353 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
354 getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
355 getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
356 getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
357 getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
358 /* compile without modules -- using classpath libraries
359 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
360 modules_runtimeClasspath = modules_compileClasspath
363 gitBranch = string("")
365 println("Using a ${CHANNEL} profile.")
367 additional_compiler_args = []
368 // configure classpath/args for j8/j11 compilation
369 if (JAVA_VERSION.equals("1.8")) {
370 JAVA_INTEGER_VERSION = string("8")
373 libDistDir = j8libDir
374 compile_source_compatibility = 1.8
375 compile_target_compatibility = 1.8
376 // these are getdown.txt properties defined dependent on the JAVA_VERSION
377 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version"))
378 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version"))
379 // this property is assigned below and expanded to multiple lines in the getdown task
380 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location"))
381 // this property is for the Java library used in eclipse
382 eclipseJavaRuntimeName = string("JavaSE-1.8")
383 } else if (JAVA_VERSION.equals("11")) {
384 JAVA_INTEGER_VERSION = string("11")
386 libDistDir = j11libDir
387 compile_source_compatibility = 11
388 compile_target_compatibility = 11
389 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
390 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
391 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
392 eclipseJavaRuntimeName = string("JavaSE-11")
393 /* compile without modules -- using classpath libraries
394 additional_compiler_args += [
395 '--module-path', modules_compileClasspath.asPath,
396 '--add-modules', j11modules
399 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
400 JAVA_INTEGER_VERSION = JAVA_VERSION
402 libDistDir = j11libDir
403 compile_source_compatibility = JAVA_VERSION
404 compile_target_compatibility = JAVA_VERSION
405 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
406 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
407 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
408 eclipseJavaRuntimeName = string("JavaSE-11")
409 /* compile without modules -- using classpath libraries
410 additional_compiler_args += [
411 '--module-path', modules_compileClasspath.asPath,
412 '--add-modules', j11modules
416 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
421 JAVA_MIN_VERSION = JAVA_VERSION
422 JAVA_MAX_VERSION = JAVA_VERSION
423 def jreInstallsDir = string(jre_installs_dir)
424 if (jreInstallsDir.startsWith("~/")) {
425 jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1)
427 macosJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-mac-x64/jre")
428 macosJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-mac-x64.tar.gz")
429 windowsJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-windows-x64/jre")
430 windowsJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-windows-x64.tar.gz")
431 linuxJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-linux-x64/jre")
432 linuxJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-linux-x64.tar.gz")
433 install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
434 install4jConfFileName = string("jalview-install4j-conf.install4j")
435 install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
436 install4jHomeDir = install4j_home_dir
437 if (install4jHomeDir.startsWith("~/")) {
438 install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
443 buildingHTML = string("${jalviewDir}/${doc_dir}/building.html")
444 helpFile = string("${resourceClassesDir}/${help_dir}/help.jhm")
445 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
446 helpSourceDir = string("${helpParentDir}/${help_dir}")
449 relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
450 jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
451 jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
453 jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
455 jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
457 jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
458 jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
459 jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
460 jalviewjsJalviewCoreHtmlFile = string("")
461 jalviewjsCoreClasslists = []
462 jalviewjsJalviewTemplateName = string(jalviewjs_name)
463 jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
464 jalviewjsJ2sAltSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_alt_settings}")
465 jalviewjsJ2sProps = null
466 jalviewjsJ2sPlugin = jalviewjs_j2s_plugin
468 eclipseWorkspace = null
469 eclipseBinary = string("")
470 eclipseVersion = string("")
480 outputDir = file(classesDir)
485 srcDirs += helpParentDir
488 jar.destinationDir = file("${jalviewDir}/${package_dir}")
490 compileClasspath = files(sourceSets.main.java.outputDir)
491 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
493 runtimeClasspath = compileClasspath
498 srcDirs cloverInstrDir
499 outputDir = cloverClassesDir
503 srcDirs = sourceSets.main.resources.srcDirs
506 compileClasspath = files( sourceSets.clover.java.outputDir )
507 //compileClasspath += files( testClassesDir )
508 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
509 compileClasspath += fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
510 compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
512 runtimeClasspath = compileClasspath
517 srcDirs testSourceDir
518 outputDir = file(testClassesDir)
522 srcDirs = useClover ? sourceSets.clover.resources.srcDirs : sourceSets.main.resources.srcDirs
525 compileClasspath = files( sourceSets.test.java.outputDir )
526 compileClasspath += useClover ? sourceSets.clover.compileClasspath : sourceSets.main.compileClasspath
527 compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
529 runtimeClasspath = compileClasspath
535 // eclipse project and settings files creation, also used by buildship
538 name = eclipse_project_name
540 natures 'org.eclipse.jdt.core.javanature',
541 'org.eclipse.jdt.groovy.core.groovyNature',
542 'org.eclipse.buildship.core.gradleprojectnature'
544 buildCommand 'org.eclipse.jdt.core.javabuilder'
545 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
549 //defaultOutputDir = sourceSets.main.java.outputDir
552 if (it.isCanBeResolved()) {
557 minusConfigurations += removeThese
558 plusConfigurations = [ ]
562 def removeTheseToo = []
563 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
564 cp.entries.each { entry ->
565 // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
566 // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
567 // we add the resources and help/help dirs in as libs afterwards (see below)
568 if (entry.kind == 'src') {
569 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
570 removeTheseToo += entry
572 alreadyAddedSrcPath.putAt(entry.path, true)
577 cp.entries.removeAll(removeTheseToo)
579 //cp.entries += new Output("${eclipse_bin_dir}/main")
580 if (file(helpParentDir).isDirectory()) {
581 cp.entries += new Library(fileReference(helpParentDir))
583 if (file(resourceDir).isDirectory()) {
584 cp.entries += new Library(fileReference(resourceDir))
587 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
589 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
590 //don't want to add outputDir as eclipse is using its own output dir in bin/main
591 if (it.isDirectory() || ! it.exists()) {
592 // don't add dirs to classpath, especially if they don't exist
593 return false // groovy "continue" in .any closure
595 def itPath = it.toString()
596 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
597 // make relative path
598 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
600 if (alreadyAddedLibPath.get(itPath)) {
601 //println("Not adding duplicate entry "+itPath)
603 //println("Adding entry "+itPath)
604 cp.entries += new Library(fileReference(itPath))
605 alreadyAddedLibPath.put(itPath, true)
609 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
610 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
611 if (it.isDirectory() || ! it.exists()) {
612 // don't add dirs to classpath
613 return false // groovy "continue" in .any closure
616 def itPath = it.toString()
617 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
618 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
620 if (alreadyAddedLibPath.get(itPath)) {
623 def lib = new Library(fileReference(itPath))
624 lib.entryAttributes["test"] = "true"
626 alreadyAddedLibPath.put(itPath, true)
634 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
639 // for the IDE, use java 11 compatibility
640 sourceCompatibility = compile_source_compatibility
641 targetCompatibility = compile_target_compatibility
642 javaRuntimeName = eclipseJavaRuntimeName
644 // add in jalview project specific properties/preferences into eclipse core preferences
646 withProperties { props ->
647 def jalview_prefs = new Properties()
648 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
649 jalview_prefs.load(ins)
651 jalview_prefs.forEach { t, v ->
652 if (props.getAt(t) == null) {
656 // codestyle file -- overrides previous formatter prefs
657 def csFile = file("${jalviewDirAbsolutePath}/${eclipse_codestyle_file}")
658 if (csFile.exists()) {
659 XmlParser parser = new XmlParser()
660 def profiles = parser.parse(csFile)
661 def profile = profiles.'profile'.find { p -> (p.'@kind' == "CodeFormatterProfile" && p.'@name' == "Jalview") }
662 if (profile != null) {
663 profile.'setting'.each { s ->
665 def value = s.'@value'
666 if (id != null && value != null) {
667 props.putAt(id, value)
678 // Don't want these to be activated if in headless build
679 synchronizationTasks "eclipseSynchronizationTask"
680 //autoBuildTasks "eclipseAutoBuildTask"
686 /* hack to change eclipse prefs in .settings files other than org.eclipse.jdt.core.prefs */
687 // Class to allow updating arbitrary properties files
688 class PropertiesFile extends PropertiesPersistableConfigurationObject {
689 public PropertiesFile(PropertiesTransformer t) { super(t); }
690 @Override protected void load(Properties properties) { }
691 @Override protected void store(Properties properties) { }
692 @Override protected String getDefaultResourceName() { return ""; }
693 // This is necessary, because PropertiesPersistableConfigurationObject fails
694 // if no default properties file exists.
695 @Override public void loadDefaults() { load(new StringBufferInputStream("")); }
698 // Task to update arbitrary properties files (set outputFile)
699 class PropertiesFileTask extends PropertiesGeneratorTask<PropertiesFile> {
700 private final PropertiesFileContentMerger file;
701 public PropertiesFileTask() { file = new PropertiesFileContentMerger(getTransformer()); }
702 protected PropertiesFile create() { return new PropertiesFile(getTransformer()); }
703 protected void configure(PropertiesFile props) {
704 file.getBeforeMerged().execute(props); file.getWhenMerged().execute(props);
706 public void file(Closure closure) { ConfigureUtil.configure(closure, file); }
709 task eclipseUIPreferences(type: PropertiesFileTask) {
710 description = "Generate Eclipse additional settings"
711 def filename = "org.eclipse.jdt.ui.prefs"
712 outputFile = "$projectDir/.settings/${filename}" as File
715 it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
720 task eclipseGroovyCorePreferences(type: PropertiesFileTask) {
721 description = "Generate Eclipse additional settings"
722 def filename = "org.eclipse.jdt.groovy.core.prefs"
723 outputFile = "$projectDir/.settings/${filename}" as File
726 it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
731 task eclipseAllPreferences {
733 dependsOn eclipseUIPreferences
734 dependsOn eclipseGroovyCorePreferences
737 eclipseUIPreferences.mustRunAfter eclipseJdt
738 eclipseGroovyCorePreferences.mustRunAfter eclipseJdt
740 /* end of eclipse preferences hack */
748 delete cloverBuildDir
749 delete cloverReportDir
754 task cloverInstrJava(type: JavaExec) {
755 group = "Verification"
756 description = "Create clover instrumented source java files"
758 dependsOn cleanClover
760 inputs.files(sourceSets.main.allJava)
761 outputs.dir(cloverInstrDir)
763 //classpath = fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
764 classpath = sourceSets.clover.compileClasspath
765 main = "com.atlassian.clover.CloverInstr"
773 cloverInstrDir.getPath(),
775 def srcFiles = sourceSets.main.allJava.files
778 { file -> file.absolutePath }
781 args argsList.toArray()
784 delete cloverInstrDir
785 println("Clover: About to instrument "+srcFiles.size() +" files")
790 task cloverInstrTests(type: JavaExec) {
791 group = "Verification"
792 description = "Create clover instrumented source test files"
794 dependsOn cleanClover
796 inputs.files(testDir)
797 outputs.dir(cloverTestInstrDir)
799 classpath = sourceSets.clover.compileClasspath
800 main = "com.atlassian.clover.CloverInstr"
810 cloverTestInstrDir.getPath(),
812 args argsList.toArray()
815 delete cloverTestInstrDir
816 println("Clover: About to instrument test files")
822 group = "Verification"
823 description = "Create clover instrumented all source files"
825 dependsOn cloverInstrJava
826 dependsOn cloverInstrTests
830 cloverClasses.dependsOn cloverInstr
833 task cloverConsoleReport(type: JavaExec) {
834 group = "Verification"
835 description = "Creates clover console report"
838 file(cloverDb).exists()
841 inputs.dir cloverClassesDir
843 classpath = sourceSets.clover.runtimeClasspath
844 main = "com.atlassian.clover.reporters.console.ConsoleReporter"
846 if (cloverreport_mem.length() > 0) {
847 maxHeapSize = cloverreport_mem
849 if (cloverreport_jvmargs.length() > 0) {
850 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
860 args argsList.toArray()
864 task cloverHtmlReport(type: JavaExec) {
865 group = "Verification"
866 description = "Creates clover HTML report"
869 file(cloverDb).exists()
872 def cloverHtmlDir = cloverReportDir
873 inputs.dir cloverClassesDir
874 outputs.dir cloverHtmlDir
876 classpath = sourceSets.clover.runtimeClasspath
877 main = "com.atlassian.clover.reporters.html.HtmlReporter"
879 if (cloverreport_mem.length() > 0) {
880 maxHeapSize = cloverreport_mem
882 if (cloverreport_jvmargs.length() > 0) {
883 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
894 if (cloverreport_html_options.length() > 0) {
895 argsList += cloverreport_html_options.split(" ")
898 args argsList.toArray()
902 task cloverXmlReport(type: JavaExec) {
903 group = "Verification"
904 description = "Creates clover XML report"
907 file(cloverDb).exists()
910 def cloverXmlFile = "${cloverReportDir}/clover.xml"
911 inputs.dir cloverClassesDir
912 outputs.file cloverXmlFile
914 classpath = sourceSets.clover.runtimeClasspath
915 main = "com.atlassian.clover.reporters.xml.XMLReporter"
917 if (cloverreport_mem.length() > 0) {
918 maxHeapSize = cloverreport_mem
920 if (cloverreport_jvmargs.length() > 0) {
921 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
932 if (cloverreport_xml_options.length() > 0) {
933 argsList += cloverreport_xml_options.split(" ")
936 args argsList.toArray()
941 group = "Verification"
942 description = "Creates clover reports"
944 dependsOn cloverXmlReport
945 dependsOn cloverHtmlReport
952 sourceCompatibility = compile_source_compatibility
953 targetCompatibility = compile_target_compatibility
954 options.compilerArgs += additional_compiler_args
955 print ("Setting target compatibility to "+targetCompatibility+"\n")
957 //classpath += configurations.cloverRuntime
963 // JBP->BS should the print statement in doFirst refer to compile_target_compatibility ?
964 sourceCompatibility = compile_source_compatibility
965 targetCompatibility = compile_target_compatibility
966 options.compilerArgs = additional_compiler_args
967 options.encoding = "UTF-8"
969 print ("Setting target compatibility to "+compile_target_compatibility+"\n")
976 sourceCompatibility = compile_source_compatibility
977 targetCompatibility = compile_target_compatibility
978 options.compilerArgs = additional_compiler_args
980 print ("Setting target compatibility to "+targetCompatibility+"\n")
987 delete sourceSets.main.java.outputDir
993 dependsOn cleanClover
995 delete sourceSets.test.java.outputDir
1000 // format is a string like date.format("dd MMMM yyyy")
1001 def getDate(format) {
1002 def date = new Date()
1003 return date.format(format)
1010 def hashStdOut = new ByteArrayOutputStream()
1011 def resultHash = exec {
1012 commandLine "git", "rev-parse", "--short", "HEAD"
1013 standardOutput = hashStdOut
1014 ignoreExitValue true
1017 def branchStdOut = new ByteArrayOutputStream()
1018 def resultBranch = exec {
1019 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
1020 standardOutput = branchStdOut
1021 ignoreExitValue true
1024 gitHash = resultHash.getExitValue() == 0 ? hashStdOut.toString().trim() : "NO_GIT_COMMITID_FOUND"
1025 gitBranch = resultBranch.getExitValue() == 0 ? branchStdOut.toString().trim() : "NO_GIT_BRANCH_FOUND"
1028 outputs.upToDateWhen { false }
1032 task createBuildProperties(type: WriteProperties) {
1034 description = "Create the ${buildProperties} file"
1036 dependsOn setGitVals
1037 inputs.dir(sourceDir)
1038 inputs.dir(resourceDir)
1039 file(buildProperties).getParentFile().mkdirs()
1040 outputFile (buildProperties)
1041 // taking time specific comment out to allow better incremental builds
1042 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
1043 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
1044 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
1045 property "VERSION", JALVIEW_VERSION
1046 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
1047 outputs.file(outputFile)
1053 delete buildProperties
1058 task cleanBuildingHTML(type: Delete) {
1065 def convertMdToHtml (FileTree mdFiles, File cssFile) {
1066 MutableDataSet options = new MutableDataSet()
1068 def extensions = new ArrayList<>()
1069 extensions.add(AnchorLinkExtension.create())
1070 extensions.add(AutolinkExtension.create())
1071 extensions.add(StrikethroughExtension.create())
1072 extensions.add(TaskListExtension.create())
1073 extensions.add(TablesExtension.create())
1074 extensions.add(TocExtension.create())
1076 options.set(Parser.EXTENSIONS, extensions)
1078 // set GFM table parsing options
1079 options.set(TablesExtension.WITH_CAPTION, false)
1080 options.set(TablesExtension.COLUMN_SPANS, false)
1081 options.set(TablesExtension.MIN_HEADER_ROWS, 1)
1082 options.set(TablesExtension.MAX_HEADER_ROWS, 1)
1083 options.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
1084 options.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
1085 options.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
1087 options.set(AnchorLinkExtension.ANCHORLINKS_SET_ID, false)
1088 options.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor")
1089 options.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true)
1090 options.set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "<span class=\"octicon octicon-link\"></span>")
1092 Parser parser = Parser.builder(options).build()
1093 HtmlRenderer renderer = HtmlRenderer.builder(options).build()
1095 mdFiles.each { mdFile ->
1096 // add table of contents
1097 def mdText = "[TOC]\n"+mdFile.text
1099 // grab the first top-level title
1101 def titleRegex = /(?m)^#(\s+|([^#]))(.*)/
1102 def matcher = mdText =~ titleRegex
1103 if (matcher.size() > 0) {
1104 // matcher[0][2] is the first character of the title if there wasn't any whitespace after the #
1105 title = (matcher[0][2] != null ? matcher[0][2] : "")+matcher[0][3]
1107 // or use the filename if none found
1108 if (title == null) {
1109 title = mdFile.getName()
1112 Node document = parser.parse(mdText)
1113 String htmlBody = renderer.render(document)
1114 def htmlText = '''<html>
1115 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1116 <html xmlns="http://www.w3.org/1999/xhtml">
1118 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1119 <meta http-equiv="Content-Style-Type" content="text/css" />
1120 <meta name="generator" content="flexmark" />
1122 htmlText += ((title != null) ? " <title>${title}</title>" : '' )
1124 <style type="text/css">code{white-space: pre;}</style>
1126 htmlText += ((cssFile != null) ? cssFile.text : '')
1127 htmlText += '''</head>
1130 htmlText += htmlBody
1136 def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html")
1137 def htmlFile = file(htmlFilePath)
1138 htmlFile.text = htmlText
1143 task convertMdFiles {
1144 dependsOn cleanBuildingHTML
1145 def mdFiles = fileTree(dir: "${jalviewDir}/${doc_dir}", include: "*.md")
1146 def cssFile = file("${jalviewDir}/${flexmark_css}")
1149 convertMdToHtml(mdFiles, cssFile)
1152 inputs.files(mdFiles)
1153 inputs.file(cssFile)
1156 mdFiles.each { mdFile ->
1157 def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html")
1158 htmlFiles.add(file(htmlFilePath))
1160 outputs.files(htmlFiles)
1164 task syncDocs(type: Sync) {
1165 dependsOn convertMdFiles
1166 def syncDir = "${classesDir}/${doc_dir}"
1167 from fileTree("${jalviewDir}/${doc_dir}")
1172 task copyHelp(type: Copy) {
1173 def inputDir = helpSourceDir
1174 def outputDir = "${resourceClassesDir}/${help_dir}"
1179 filter(ReplaceTokens,
1183 'Version-Rel': JALVIEW_VERSION,
1184 'Year-Rel': getDate("yyyy")
1195 inputs.dir(inputDir)
1196 outputs.files(helpFile)
1197 outputs.dir(outputDir)
1201 task syncLib(type: Sync) {
1202 def syncDir = "${resourceClassesDir}/${libDistDir}"
1203 from fileTree("${jalviewDir}/${libDistDir}")
1208 task syncResources(type: Sync) {
1209 dependsOn createBuildProperties
1212 into "${resourceClassesDir}"
1220 dependsOn syncResources
1226 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
1229 //dependsOn compileJava ////? DELETE
1232 dependsOn cloverClasses
1234 dependsOn compileJava //?
1238 includeGroups testng_groups
1239 excludeGroups testng_excluded_groups
1241 useDefaultListeners=true
1244 maxHeapSize = "1024m"
1246 workingDir = jalviewDir
1247 //systemProperties 'clover.jar' System.properties.clover.jar
1248 sourceCompatibility = compile_source_compatibility
1249 targetCompatibility = compile_target_compatibility
1250 jvmArgs += additional_compiler_args
1254 println("Running tests " + (useClover?"WITH":"WITHOUT") + " clover")
1260 task buildIndices(type: JavaExec) {
1262 classpath = sourceSets.main.compileClasspath
1263 main = "com.sun.java.help.search.Indexer"
1264 workingDir = "${classesDir}/${help_dir}"
1267 inputs.dir("${workingDir}/${argDir}")
1269 outputs.dir("${classesDir}/doc")
1270 outputs.dir("${classesDir}/help")
1271 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
1272 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
1273 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
1274 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
1275 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
1276 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
1280 task compileLinkCheck(type: JavaCompile) {
1282 classpath = files("${jalviewDir}/${utils_dir}")
1283 destinationDir = file("${jalviewDir}/${utils_dir}")
1284 source = fileTree(dir: "${jalviewDir}/${utils_dir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
1286 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
1287 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
1288 outputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.class")
1289 outputs.file("${jalviewDir}/${utils_dir}/BufferedLineReader.class")
1293 task linkCheck(type: JavaExec) {
1294 dependsOn prepare, compileLinkCheck
1296 def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out")
1297 classpath = files("${jalviewDir}/${utils_dir}")
1298 main = "HelpLinksChecker"
1299 workingDir = jalviewDir
1300 args = [ "${classesDir}/${help_dir}", "-nointernet" ]
1302 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
1303 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1306 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1310 inputs.dir("${classesDir}/${help_dir}")
1311 outputs.file(helpLinksCheckerOutFile)
1314 // import the pubhtmlhelp target
1315 ant.properties.basedir = "${jalviewDir}"
1316 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
1317 ant.importBuild "${utils_dir}/publishHelp.xml"
1320 task cleanPackageDir(type: Delete) {
1322 delete fileTree(dir: "${jalviewDir}/${package_dir}", include: "*.jar")
1329 dependsOn buildIndices
1330 dependsOn createBuildProperties
1333 attributes "Main-Class": main_class,
1334 "Permissions": "all-permissions",
1335 "Application-Name": "Jalview Desktop",
1336 "Codebase": application_codebase
1339 duplicatesStrategy "EXCLUDE"
1342 destinationDir = file("${jalviewDir}/${package_dir}")
1343 archiveName = rootProject.name+".jar"
1349 exclude "**/*.jar.*"
1351 inputs.dir(classesDir)
1352 outputs.file("${jalviewDir}/${package_dir}/${archiveName}")
1356 task copyJars(type: Copy) {
1357 from fileTree(dir: classesDir, include: "**/*.jar").files
1358 into "${jalviewDir}/${package_dir}"
1362 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
1363 task syncJars(type: Sync) {
1364 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
1365 into "${jalviewDir}/${package_dir}"
1367 include jar.archiveName
1374 description = "Put all required libraries in dist"
1375 // order of "cleanPackageDir", "copyJars", "jar" important!
1376 jar.mustRunAfter cleanPackageDir
1377 syncJars.mustRunAfter cleanPackageDir
1378 dependsOn cleanPackageDir
1381 outputs.dir("${jalviewDir}/${package_dir}")
1386 dependsOn cleanPackageDir
1392 group = "distribution"
1393 description = "Create a single jar file with all dependency libraries merged. Can be run with java -jar"
1397 from ("${jalviewDir}/${libDistDir}") {
1401 attributes 'Implementation-Version': JALVIEW_VERSION
1404 duplicatesStrategy "EXCLUDE"
1406 mainClassName = shadow_jar_main_class
1408 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
1413 task getdownWebsite() {
1414 group = "distribution"
1415 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
1420 def getdownWebsiteResourceFilenames = []
1421 def getdownTextString = ""
1422 def getdownResourceDir = getdownResourceDir
1423 def getdownResourceFilenames = []
1426 // clean the getdown website and files dir before creating getdown folders
1427 delete getdownWebsiteDir
1428 delete getdownFilesDir
1431 from buildProperties
1432 rename(build_properties_file, getdown_build_properties)
1435 getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
1437 // set some getdown_txt_ properties then go through all properties looking for getdown_txt_...
1438 def props = project.properties.sort { it.key }
1439 if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) {
1440 props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion)
1442 if (getdownAltJavaMaxVersion != null && getdownAltJavaMaxVersion.length() > 0) {
1443 props.put("getdown_txt_java_max_version", getdownAltJavaMaxVersion)
1445 if (getdownAltMultiJavaLocation != null && getdownAltMultiJavaLocation.length() > 0) {
1446 props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
1449 props.put("getdown_txt_title", jalview_name)
1450 props.put("getdown_txt_ui.name", install4jApplicationName)
1452 // start with appbase
1453 getdownTextString += "appbase = ${getdownAppBase}\n"
1454 props.each{ prop, val ->
1455 if (prop.startsWith("getdown_txt_") && val != null) {
1456 if (prop.startsWith("getdown_txt_multi_")) {
1457 def key = prop.substring(18)
1458 val.split(",").each{ v ->
1459 def line = "${key} = ${v}\n"
1460 getdownTextString += line
1463 // file values rationalised
1464 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1466 if (val.indexOf('/') == 0) {
1469 } else if (val.indexOf('/') > 0) {
1470 // relative path (relative to jalviewDir)
1471 r = file( "${jalviewDir}/${val}" )
1474 val = "${getdown_resource_dir}/" + r.getName()
1475 getdownWebsiteResourceFilenames += val
1476 getdownResourceFilenames += r.getPath()
1479 if (! prop.startsWith("getdown_txt_resource")) {
1480 def line = prop.substring(12) + " = ${val}\n"
1481 getdownTextString += line
1487 getdownWebsiteResourceFilenames.each{ filename ->
1488 getdownTextString += "resource = ${filename}\n"
1490 getdownResourceFilenames.each{ filename ->
1493 into getdownResourceDir
1498 fileTree(file(package_dir)).each{ f ->
1499 if (f.isDirectory()) {
1500 def files = fileTree(dir: f, include: ["*"]).getFiles()
1502 } else if (f.exists()) {
1506 codeFiles.sort().each{f ->
1507 def name = f.getName()
1508 def line = "code = ${getdownAppDistDir}/${name}\n"
1509 getdownTextString += line
1516 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1518 if (JAVA_VERSION.equals("11")) {
1519 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1520 j11libFiles.sort().each{f ->
1521 def name = f.getName()
1522 def line = "code = ${getdown_j11lib_dir}/${name}\n"
1523 getdownTextString += line
1526 into getdownJ11libDir
1532 // 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.
1533 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1534 getdownTextString += "resource = ${getdown_launcher_new}\n"
1535 getdownTextString += "class = ${main_class}\n"
1537 def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1538 getdown_txt.write(getdownTextString)
1540 def getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl"
1541 def launchJvl = file("${getdownWebsiteDir}/${getdownLaunchJvl}")
1542 launchJvl.write("appbase=${getdownAppBase}")
1545 from getdownLauncher
1546 rename(file(getdownLauncher).getName(), getdown_launcher_new)
1547 into getdownWebsiteDir
1551 from getdownLauncher
1552 if (file(getdownLauncher).getName() != getdown_launcher) {
1553 rename(file(getdownLauncher).getName(), getdown_launcher)
1555 into getdownWebsiteDir
1558 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1561 from getdownLauncher
1562 from "${getdownWebsiteDir}/${getdown_build_properties}"
1563 if (file(getdownLauncher).getName() != getdown_launcher) {
1564 rename(file(getdownLauncher).getName(), getdown_launcher)
1566 into getdownInstallDir
1570 from getdownInstallDir
1571 into getdownFilesInstallDir
1578 from getdownLauncher
1579 from "${getdownWebsiteDir}/${getdown_build_properties}"
1580 if (file(getdownLauncher).getName() != getdown_launcher) {
1581 rename(file(getdownLauncher).getName(), getdown_launcher)
1583 into getdownFilesDir
1587 from getdownResourceDir
1588 into "${getdownFilesDir}/${getdown_resource_dir}"
1593 inputs.dir("${jalviewDir}/${package_dir}")
1595 outputs.dir(getdownWebsiteDir)
1596 outputs.dir(getdownFilesDir)
1600 // a helper task to allow getdown digest of any dir: `gradle getdownDigestDir -PDIGESTDIR=/path/to/my/random/getdown/dir
1601 task getdownDigestDir(type: JavaExec) {
1603 description "A task to run a getdown Digest on a dir with getdown.txt. Provide a DIGESTDIR property via -PDIGESTDIR=..."
1605 def digestDirPropertyName = "DIGESTDIR"
1607 classpath = files(getdownLauncher)
1608 def digestDir = findProperty(digestDirPropertyName)
1609 if (digestDir == null) {
1610 throw new GradleException("Must provide a DIGESTDIR value to produce an alternative getdown digest")
1614 main = "com.threerings.getdown.tools.Digester"
1618 task getdownDigest(type: JavaExec) {
1619 group = "distribution"
1620 description = "Digest the getdown website folder"
1621 dependsOn getdownWebsite
1623 classpath = files(getdownLauncher)
1625 main = "com.threerings.getdown.tools.Digester"
1626 args getdownWebsiteDir
1627 inputs.dir(getdownWebsiteDir)
1628 outputs.file("${getdownWebsiteDir}/digest2.txt")
1633 group = "distribution"
1634 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1635 dependsOn getdownDigest
1637 if (reportRsyncCommand) {
1638 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1639 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1640 println "LIKELY RSYNC COMMAND:"
1641 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1642 if (RUNRSYNC == "true") {
1644 commandLine "mkdir", "-p", toDir
1647 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1655 tasks.withType(JavaCompile) {
1656 options.encoding = 'UTF-8'
1662 delete getdownWebsiteDir
1663 delete getdownFilesDir
1669 if (file(install4jHomeDir).exists()) {
1671 } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
1672 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1673 } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
1674 install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
1676 installDir(file(install4jHomeDir))
1678 mediaTypes = Arrays.asList(install4j_media_types.split(","))
1682 task copyInstall4jTemplate {
1683 def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
1684 def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
1685 inputs.file(install4jTemplateFile)
1686 inputs.file(install4jFileAssociationsFile)
1687 inputs.property("CHANNEL", { CHANNEL })
1688 outputs.file(install4jConfFile)
1691 def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
1693 // turn off code signing if no OSX_KEYPASS
1694 if (OSX_KEYPASS == "") {
1695 install4jConfigXml.'**'.codeSigning.each { codeSigning ->
1696 codeSigning.'@macEnabled' = "false"
1698 install4jConfigXml.'**'.windows.each { windows ->
1699 windows.'@runPostProcessor' = "false"
1703 // turn off checksum creation for LOCAL channel
1704 def e = install4jConfigXml.application[0]
1705 if (CHANNEL == "LOCAL") {
1706 e.'@createChecksums' = "false"
1708 e.'@createChecksums' = "true"
1711 // put file association actions where placeholder action is
1712 def install4jFileAssociationsText = install4jFileAssociationsFile.text
1713 def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
1714 install4jConfigXml.'**'.action.any { a -> // .any{} stops after the first one that returns true
1715 if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
1716 def parent = a.parent()
1718 fileAssociationActions.each { faa ->
1721 // don't need to continue in .any loop once replacements have been made
1726 // use Windows Program Group with Examples folder for RELEASE, and Program Group without Examples for everything else
1727 // NB we're deleting the /other/ one!
1728 // Also remove the examples subdir from non-release versions
1729 def customizedIdToDelete = "PROGRAM_GROUP_RELEASE"
1730 // 2.11.1.0 NOT releasing with the Examples folder in the Program Group
1731 if (false && CHANNEL=="RELEASE") { // remove 'false && ' to include Examples folder in RELEASE channel
1732 customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE"
1734 // remove the examples subdir from Full File Set
1735 def files = install4jConfigXml.files[0]
1736 def fileset = files.filesets.fileset.find { fs -> fs.'@customizedId' == "FULL_FILE_SET" }
1737 def root = files.roots.root.find { r -> r.'@fileset' == fileset.'@id' }
1738 def mountPoint = files.mountPoints.mountPoint.find { mp -> mp.'@root' == root.'@id' }
1739 def dirEntry = files.entries.dirEntry.find { de -> de.'@mountPoint' == mountPoint.'@id' && de.'@subDirectory' == "examples" }
1740 dirEntry.parent().remove(dirEntry)
1742 install4jConfigXml.'**'.action.any { a ->
1743 if (a.'@customizedId' == customizedIdToDelete) {
1744 def parent = a.parent()
1750 // remove the "Uninstall Old Jalview (optional)" symlink from DMG for non-release DS_Stores
1751 if (! (CHANNEL == "RELEASE" || CHANNEL == "TEST-RELEASE" ) ) {
1752 def symlink = install4jConfigXml.'**'.topLevelFiles.symlink.find { sl -> sl.'@name' == "Uninstall Old Jalview (optional).app" }
1753 symlink.parent().remove(symlink)
1756 // write install4j file
1757 install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
1764 delete install4jConfFile
1769 task installers(type: com.install4j.gradle.Install4jTask) {
1770 group = "distribution"
1771 description = "Create the install4j installers"
1772 dependsOn setGitVals
1774 dependsOn copyInstall4jTemplate
1776 projectFile = install4jConfFile
1778 // create an md5 for the input files to use as version for install4j conf file
1779 def digest = MessageDigest.getInstance("MD5")
1781 (file("${install4jDir}/${install4j_template}").text +
1782 file("${install4jDir}/${install4j_info_plist_file_associations}").text +
1783 file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
1784 def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
1785 if (filesMd5.length() >= 8) {
1786 filesMd5 = filesMd5.substring(0,8)
1788 def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
1789 // make install4jBuildDir relative to jalviewDir
1790 def install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}"
1793 'JALVIEW_NAME': jalview_name,
1794 'JALVIEW_APPLICATION_NAME': install4jApplicationName,
1795 'JALVIEW_DIR': "../..",
1796 'OSX_KEYSTORE': OSX_KEYSTORE,
1797 'JSIGN_SH': JSIGN_SH,
1798 'JRE_DIR': getdown_app_dir_java,
1799 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
1800 'JALVIEW_VERSION': JALVIEW_VERSION,
1801 'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
1802 'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
1803 'JAVA_VERSION': JAVA_VERSION,
1804 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1805 'VERSION': JALVIEW_VERSION,
1806 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1807 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1808 'LINUX_JAVA_VM_DIR': linuxJavaVMDir,
1809 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1810 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1811 'LINUX_JAVA_VM_TGZ': linuxJavaVMTgz,
1812 'COPYRIGHT_MESSAGE': install4j_copyright_message,
1813 'BUNDLE_ID': install4jBundleId,
1814 'INTERNAL_ID': install4jInternalId,
1815 'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
1816 'MACOS_DS_STORE': install4jDSStore,
1817 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage,
1818 'INSTALLER_NAME': install4jInstallerName,
1819 'INSTALL4J_UTILS_DIR': install4j_utils_dir,
1820 'GETDOWN_WEBSITE_DIR': getdown_website_dir,
1821 'GETDOWN_FILES_DIR': getdown_files_dir,
1822 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1823 'GETDOWN_DIST_DIR': getdownAppDistDir,
1824 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1825 'GETDOWN_INSTALL_DIR': getdown_install_dir,
1826 'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
1827 'BUILD_DIR': install4jBuildDir,
1828 'APPLICATION_CATEGORIES': install4j_application_categories,
1829 'APPLICATION_FOLDER': install4jApplicationFolder,
1830 'UNIX_APPLICATION_FOLDER': install4jUnixApplicationFolder,
1831 'EXECUTABLE_NAME': install4jExecutableName,
1832 'EXTRA_SCHEME': install4jExtraScheme,
1835 //println("INSTALL4J VARIABLES:")
1836 //variables.each{k,v->println("${k}=${v}")}
1838 destination = "${jalviewDir}/${install4jBuildDir}"
1839 buildSelected = true
1841 if (install4j_faster.equals("true") || CHANNEL.startsWith("LOCAL")) {
1843 disableSigning = true
1847 macKeystorePassword = OSX_KEYPASS
1851 println("Using projectFile "+projectFile)
1854 inputs.dir(getdownWebsiteDir)
1855 inputs.file(install4jConfFile)
1856 inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
1857 inputs.dir(macosJavaVMDir)
1858 inputs.dir(windowsJavaVMDir)
1859 outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
1865 eclipse().configFile(eclipse_codestyle_file)
1870 task sourceDist(type: Tar) {
1871 group "distribution"
1872 description "Create a source .tar.gz file for distribution"
1874 dependsOn convertMdFiles
1876 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1877 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1878 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1880 archiveFileName = outputFileName
1881 } catch (Exception e) {
1882 archiveName = outputFileName
1885 compression Compression.GZIP
1900 "**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales",
1902 "utils/InstallAnywhere",
1917 "gradle.properties",
1928 ".settings/org.eclipse.jdt.core.jalview.prefs",
1932 exclude (EXCLUDE_FILES)
1933 include (PROCESS_FILES)
1934 filter(ReplaceTokens,
1938 'Version-Rel': JALVIEW_VERSION,
1939 'Year-Rel': getDate("yyyy")
1944 exclude (EXCLUDE_FILES)
1945 exclude (PROCESS_FILES)
1946 exclude ("appletlib")
1947 exclude ("**/*locales")
1948 exclude ("*locales/**")
1949 exclude ("utils/InstallAnywhere")
1951 exclude (getdown_files_dir)
1952 exclude (getdown_website_dir)
1954 // exluding these as not using jars as modules yet
1955 exclude ("${j11modDir}/**/*.jar")
1958 include(INCLUDE_FILES)
1960 // from (jalviewDir) {
1961 // // explicit includes for stuff that seemed to not get included
1962 // include(fileTree("test/**/*."))
1963 // exclude(EXCLUDE_FILES)
1964 // exclude(PROCESS_FILES)
1971 dependsOn pubhtmlhelp
1973 inputs.dir("${classesDir}/${help_dir}")
1974 outputs.dir("${buildDir}/distributions/${help_dir}")
1978 task j2sSetHeadlessBuild {
1985 task jalviewjsEnableAltFileProperty(type: WriteProperties) {
1987 description "Enable the alternative J2S Config file for headless build"
1989 outputFile = jalviewjsJ2sSettingsFileName
1990 def j2sPropsFile = file(jalviewjsJ2sSettingsFileName)
1991 def j2sProps = new Properties()
1992 if (j2sPropsFile.exists()) {
1994 def j2sPropsFileFIS = new FileInputStream(j2sPropsFile)
1995 j2sProps.load(j2sPropsFileFIS)
1996 j2sPropsFileFIS.close()
1998 j2sProps.each { prop, val ->
2001 } catch (Exception e) {
2002 println("Exception reading ${jalviewjsJ2sSettingsFileName}")
2006 if (! j2sProps.stringPropertyNames().contains(jalviewjs_j2s_alt_file_property_config)) {
2007 property(jalviewjs_j2s_alt_file_property_config, jalviewjs_j2s_alt_file_property)
2012 task jalviewjsSetEclipseWorkspace {
2013 def propKey = "jalviewjs_eclipse_workspace"
2015 if (project.hasProperty(propKey)) {
2016 propVal = project.getProperty(propKey)
2017 if (propVal.startsWith("~/")) {
2018 propVal = System.getProperty("user.home") + propVal.substring(1)
2021 def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
2022 def propsFile = file(propsFileName)
2023 def eclipseWsDir = propVal
2024 def props = new Properties()
2026 def writeProps = true
2027 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
2028 def ins = new FileInputStream(propsFileName)
2031 if (props.getProperty(propKey, null) != null) {
2032 eclipseWsDir = props.getProperty(propKey)
2037 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
2038 def tempDir = File.createTempDir()
2039 eclipseWsDir = tempDir.getAbsolutePath()
2042 eclipseWorkspace = file(eclipseWsDir)
2045 // do not run a headless transpile when we claim to be in Eclipse
2047 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2048 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
2050 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2054 props.setProperty(propKey, eclipseWsDir)
2055 propsFile.parentFile.mkdirs()
2056 def bytes = new ByteArrayOutputStream()
2057 props.store(bytes, null)
2058 def propertiesString = bytes.toString()
2059 propsFile.text = propertiesString
2065 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
2068 //inputs.property(propKey, eclipseWsDir) // eclipseWsDir only gets set once this task runs, so will be out-of-date
2069 outputs.file(propsFileName)
2070 outputs.upToDateWhen { eclipseWorkspace.exists() && propsFile.exists() }
2074 task jalviewjsEclipsePaths {
2077 def eclipseRoot = jalviewjs_eclipse_root
2078 if (eclipseRoot.startsWith("~/")) {
2079 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
2081 if (OperatingSystem.current().isMacOsX()) {
2082 eclipseRoot += "/Eclipse.app"
2083 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
2084 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
2085 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
2086 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
2087 eclipseRoot += "/eclipse"
2089 eclipseBinary = "${eclipseRoot}/eclipse.exe"
2090 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
2091 } else { // linux or unix
2092 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
2093 eclipseRoot += "/eclipse"
2094 println("eclipseDir exists")
2096 eclipseBinary = "${eclipseRoot}/eclipse"
2097 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
2100 eclipseVersion = "4.13" // default
2101 def assumedVersion = true
2102 if (file(eclipseProduct).exists()) {
2103 def fis = new FileInputStream(eclipseProduct)
2104 def props = new Properties()
2106 eclipseVersion = props.getProperty("version")
2108 assumedVersion = false
2111 def propKey = "eclipse_debug"
2112 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
2115 // do not run a headless transpile when we claim to be in Eclipse
2117 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2118 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
2120 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2123 if (!assumedVersion) {
2124 println("ECLIPSE VERSION=${eclipseVersion}")
2130 task printProperties {
2132 description "Output to console all System.properties"
2134 System.properties.each { key, val -> System.out.println("Property: ${key}=${val}") }
2140 dependsOn eclipseProject
2141 dependsOn eclipseClasspath
2142 dependsOn eclipseJdt
2146 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
2147 task jalviewjsEclipseCopyDropins(type: Copy) {
2148 dependsOn jalviewjsEclipsePaths
2150 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
2151 inputFiles += file("${jalviewDir}/${jalviewjsJ2sPlugin}")
2152 def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
2159 // this eclipse -clean doesn't actually work
2160 task jalviewjsCleanEclipse(type: Exec) {
2161 dependsOn eclipseSetup
2162 dependsOn jalviewjsEclipsePaths
2163 dependsOn jalviewjsEclipseCopyDropins
2165 executable(eclipseBinary)
2166 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
2172 def inputString = """exit
2175 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
2176 standardInput = inputByteStream
2179 /* not really working yet
2180 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
2184 task jalviewjsTransferUnzipSwingJs {
2185 def file_zip = "${jalviewDir}/${jalviewjs_swingjs_zip}"
2189 from zipTree(file_zip)
2190 into "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2194 inputs.file file_zip
2195 outputs.dir "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2199 task jalviewjsTransferUnzipLib {
2200 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
2203 zipFiles.each { file_zip ->
2205 from zipTree(file_zip)
2206 into "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2211 inputs.files zipFiles
2212 outputs.dir "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2216 task jalviewjsTransferUnzipAllLibs {
2217 dependsOn jalviewjsTransferUnzipSwingJs
2218 dependsOn jalviewjsTransferUnzipLib
2222 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
2224 description "Create the alternative j2s file from the j2s.* properties"
2226 jalviewjsJ2sProps = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
2227 def siteDirProperty = "j2s.site.directory"
2228 def setSiteDir = false
2229 jalviewjsJ2sProps.each { prop, val ->
2231 if (prop == siteDirProperty) {
2232 if (!(val.startsWith('/') || val.startsWith("file://") )) {
2233 val = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${val}"
2239 if (!setSiteDir) { // default site location, don't override specifically set property
2240 property(siteDirProperty,"${jalviewDirRelativePath}/${jalviewjsTransferSiteJsDir}")
2243 outputFile = jalviewjsJ2sAltSettingsFileName
2246 inputs.properties(jalviewjsJ2sProps)
2247 outputs.file(jalviewjsJ2sAltSettingsFileName)
2252 task jalviewjsEclipseSetup {
2253 dependsOn jalviewjsEclipseCopyDropins
2254 dependsOn jalviewjsSetEclipseWorkspace
2255 dependsOn jalviewjsCreateJ2sSettings
2259 task jalviewjsSyncAllLibs (type: Sync) {
2260 dependsOn jalviewjsTransferUnzipAllLibs
2261 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteLibDir}")
2262 inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
2263 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2267 def outputFiles = []
2268 rename { filename ->
2269 outputFiles += "${outputDir}/${filename}"
2275 outputs.files outputFiles
2276 inputs.files inputFiles
2280 task jalviewjsSyncResources (type: Sync) {
2281 def inputFiles = fileTree(dir: resourceDir)
2282 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
2286 def outputFiles = []
2287 rename { filename ->
2288 outputFiles += "${outputDir}/${filename}"
2294 outputs.files outputFiles
2295 inputs.files inputFiles
2299 task jalviewjsSyncSiteResources (type: Sync) {
2300 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
2301 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2305 def outputFiles = []
2306 rename { filename ->
2307 outputFiles += "${outputDir}/${filename}"
2313 outputs.files outputFiles
2314 inputs.files inputFiles
2318 task jalviewjsSyncBuildProperties (type: Sync) {
2319 dependsOn createBuildProperties
2320 def inputFiles = [file(buildProperties)]
2321 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
2325 def outputFiles = []
2326 rename { filename ->
2327 outputFiles += "${outputDir}/${filename}"
2333 outputs.files outputFiles
2334 inputs.files inputFiles
2338 task jalviewjsProjectImport(type: Exec) {
2339 dependsOn eclipseSetup
2340 dependsOn jalviewjsEclipsePaths
2341 dependsOn jalviewjsEclipseSetup
2344 // do not run a headless import when we claim to be in Eclipse
2346 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2347 throw new StopExecutionException("Not running headless import whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
2349 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2353 //def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
2354 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview"
2355 executable(eclipseBinary)
2356 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
2360 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
2362 args += [ "-D${j2sHeadlessBuildProperty}=true" ]
2363 args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ]
2366 inputs.file("${jalviewDir}/.project")
2367 outputs.upToDateWhen {
2368 file(projdir).exists()
2373 task jalviewjsTranspile(type: Exec) {
2374 dependsOn jalviewjsEclipseSetup
2375 dependsOn jalviewjsProjectImport
2376 dependsOn jalviewjsEclipsePaths
2378 dependsOn jalviewjsEnableAltFileProperty
2382 // do not run a headless transpile when we claim to be in Eclipse
2384 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2385 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
2387 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
2391 executable(eclipseBinary)
2392 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
2396 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
2398 args += [ "-D${j2sHeadlessBuildProperty}=true" ]
2399 args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ]
2405 stdout = new ByteArrayOutputStream()
2406 stderr = new ByteArrayOutputStream()
2408 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}"
2409 def logOutFile = file(logOutFileName)
2410 logOutFile.createNewFile()
2411 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
2412 BINARY: ${eclipseBinary}
2413 VERSION: ${eclipseVersion}
2414 WORKSPACE: ${eclipseWorkspace}
2415 DEBUG: ${eclipseDebug}
2418 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
2419 // combine stdout and stderr
2420 def logErrFOS = logOutFOS
2422 if (jalviewjs_j2s_to_console.equals("true")) {
2423 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2424 new org.apache.tools.ant.util.TeeOutputStream(
2428 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2429 new org.apache.tools.ant.util.TeeOutputStream(
2434 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2437 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2444 if (stdout.toString().contains("Error processing ")) {
2445 // j2s did not complete transpile
2446 //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
2447 if (jalviewjs_ignore_transpile_errors.equals("true")) {
2448 println("IGNORING TRANSPILE ERRORS")
2449 println("See eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
2451 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
2456 inputs.dir("${jalviewDir}/${sourceDir}")
2457 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
2458 outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
2462 def jalviewjsCallCore(String name, FileCollection list, String prefixFile, String suffixFile, String jsfile, String zjsfile, File logOutFile, Boolean logOutConsole) {
2464 def stdout = new ByteArrayOutputStream()
2465 def stderr = new ByteArrayOutputStream()
2467 def coreFile = file(jsfile)
2469 msg = "Creating core for ${name}...\nGenerating ${jsfile}"
2471 logOutFile.createNewFile()
2472 logOutFile.append(msg+"\n")
2474 def coreTop = file(prefixFile)
2475 def coreBottom = file(suffixFile)
2476 coreFile.getParentFile().mkdirs()
2477 coreFile.createNewFile()
2478 coreFile.write( coreTop.getText("UTF-8") )
2482 def t = f.getText("UTF-8")
2483 t.replaceAll("Clazz\\.([^_])","Clazz_${1}")
2484 coreFile.append( t )
2486 msg = "...file '"+f.getPath()+"' does not exist, skipping"
2488 logOutFile.append(msg+"\n")
2491 coreFile.append( coreBottom.getText("UTF-8") )
2493 msg = "Generating ${zjsfile}"
2495 logOutFile.append(msg+"\n")
2496 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
2497 def logErrFOS = logOutFOS
2500 classpath = files(["${jalviewDir}/${jalviewjs_closure_compiler}"])
2501 main = "com.google.javascript.jscomp.CommandLineRunner"
2502 jvmArgs = [ "-Dfile.encoding=UTF-8" ]
2503 args = [ "--compilation_level", "SIMPLE_OPTIMIZATIONS", "--warning_level", "QUIET", "--charset", "UTF-8", "--js", jsfile, "--js_output_file", zjsfile ]
2506 msg = "\nRunning '"+commandLine.join(' ')+"'\n"
2508 logOutFile.append(msg+"\n")
2510 if (logOutConsole) {
2511 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2512 new org.apache.tools.ant.util.TeeOutputStream(
2516 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2517 new org.apache.tools.ant.util.TeeOutputStream(
2522 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
2525 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
2532 logOutFile.append(msg+"\n")
2536 task jalviewjsBuildAllCores {
2538 description "Build the core js lib closures listed in the classlists dir"
2539 dependsOn jalviewjsTranspile
2540 dependsOn jalviewjsTransferUnzipSwingJs
2542 def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}"
2543 def swingJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_j2s_subdir}"
2544 def libJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${jalviewjs_j2s_subdir}"
2545 def jsDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_js_subdir}"
2546 def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core"
2547 def prefixFile = "${jsDir}/core/coretop2.js"
2548 def suffixFile = "${jsDir}/core/corebottom2.js"
2550 inputs.file prefixFile
2551 inputs.file suffixFile
2553 def classlistFiles = []
2554 // add the classlists found int the jalviewjs_classlists_dir
2555 fileTree(dir: "${jalviewDir}/${jalviewjs_classlists_dir}", include: "*.txt").each {
2557 def name = file.getName() - ".txt"
2564 jalviewjsCoreClasslists = []
2566 classlistFiles.each {
2569 def file = hash['file']
2570 if (! file.exists()) {
2571 //println("...classlist file '"+file.getPath()+"' does not exist, skipping")
2572 return false // this is a "continue" in groovy .each closure
2574 def name = hash['name']
2576 name = file.getName() - ".txt"
2584 def list = fileTree(dir: j2sDir, includes: filelist)
2586 def jsfile = "${outputDir}/core_${name}.js"
2587 def zjsfile = "${outputDir}/core_${name}.z.js"
2589 jalviewjsCoreClasslists += [
2598 outputs.file(jsfile)
2599 outputs.file(zjsfile)
2603 def allClasslistName = "all"
2604 def allJsFiles = fileTree(dir: j2sDir, include: "**/*.js")
2605 allJsFiles += fileTree(
2609 // these exlusions are files that the closure-compiler produces errors for. Should fix them
2610 "**/org/jmol/jvxl/readers/IsoIntersectFileReader.js",
2611 "**/org/jmol/export/JSExporter.js"
2614 allJsFiles += fileTree(
2618 // these exlusions are files that the closure-compiler produces errors for. Should fix them
2619 "**/sun/misc/Unsafe.js",
2620 "**/swingjs/jquery/jquery-editable-select.js",
2621 "**/swingjs/jquery/j2sComboBox.js",
2622 "**/sun/misc/FloatingDecimal.js"
2625 def allClasslist = [
2626 'jsfile': "${outputDir}/core_${allClasslistName}.js",
2627 'zjsfile': "${outputDir}/core_${allClasslistName}.z.js",
2629 'name': allClasslistName
2631 // not including this version of "all" core at the moment
2632 //jalviewjsCoreClasslists += allClasslist
2633 inputs.files(allClasslist['list'])
2634 outputs.file(allClasslist['jsfile'])
2635 outputs.file(allClasslist['zjsfile'])
2638 def logOutFile = file("${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_closure_stdout}")
2639 logOutFile.getParentFile().mkdirs()
2640 logOutFile.createNewFile()
2641 logOutFile.write(getDate("yyyy-MM-dd HH:mm:ss")+" jalviewjsBuildAllCores\n----\n")
2643 jalviewjsCoreClasslists.each {
2644 jalviewjsCallCore(it.name, it.list, prefixFile, suffixFile, it.jsfile, it.zjsfile, logOutFile, jalviewjs_j2s_to_console.equals("true"))
2651 def jalviewjsPublishCoreTemplate(String coreName, String templateName, File inputFile, String outputFile) {
2654 into file(outputFile).getParentFile()
2655 rename { filename ->
2656 if (filename.equals(inputFile.getName())) {
2657 return file(outputFile).getName()
2661 filter(ReplaceTokens,
2665 'MAIN': '"'+main_class+'"',
2667 'NAME': jalviewjsJalviewTemplateName+" [core ${coreName}]",
2668 'COREKEY': jalviewjs_core_key,
2669 'CORENAME': coreName
2676 task jalviewjsPublishCoreTemplates {
2677 dependsOn jalviewjsBuildAllCores
2678 def inputFileName = "${jalviewDir}/${j2s_coretemplate_html}"
2679 def inputFile = file(inputFileName)
2680 def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2682 def outputFiles = []
2683 jalviewjsCoreClasslists.each { cl ->
2684 def outputFile = "${outputDir}/${jalviewjsJalviewTemplateName}_${cl.name}.html"
2685 cl['outputfile'] = outputFile
2686 outputFiles += outputFile
2690 jalviewjsCoreClasslists.each { cl ->
2691 jalviewjsPublishCoreTemplate(cl.name, jalviewjsJalviewTemplateName, inputFile, cl.outputfile)
2694 inputs.file(inputFile)
2695 outputs.files(outputFiles)
2699 task jalviewjsSyncCore (type: Sync) {
2700 dependsOn jalviewjsBuildAllCores
2701 dependsOn jalviewjsPublishCoreTemplates
2702 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
2703 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2707 def outputFiles = []
2708 rename { filename ->
2709 outputFiles += "${outputDir}/${filename}"
2715 outputs.files outputFiles
2716 inputs.files inputFiles
2720 // this Copy version of TransferSiteJs will delete anything else in the target dir
2721 task jalviewjsCopyTransferSiteJs(type: Copy) {
2722 dependsOn jalviewjsTranspile
2723 from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2724 into "${jalviewDir}/${jalviewjsSiteDir}"
2728 // this Sync version of TransferSite is used by buildship to keep the website automatically up to date when a file changes
2729 task jalviewjsSyncTransferSiteJs(type: Sync) {
2730 from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2732 into "${jalviewDir}/${jalviewjsSiteDir}"
2739 jalviewjsSyncAllLibs.mustRunAfter jalviewjsCopyTransferSiteJs
2740 jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSiteJs
2741 jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSiteJs
2742 jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSiteJs
2744 jalviewjsSyncAllLibs.mustRunAfter jalviewjsSyncTransferSiteJs
2745 jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSiteJs
2746 jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSiteJs
2747 jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSiteJs
2750 task jalviewjsPrepareSite {
2752 description "Prepares the website folder including unzipping files and copying resources"
2753 dependsOn jalviewjsSyncAllLibs
2754 dependsOn jalviewjsSyncResources
2755 dependsOn jalviewjsSyncSiteResources
2756 dependsOn jalviewjsSyncBuildProperties
2757 dependsOn jalviewjsSyncCore
2761 task jalviewjsBuildSite {
2763 description "Builds the whole website including transpiled code"
2764 dependsOn jalviewjsCopyTransferSiteJs
2765 dependsOn jalviewjsPrepareSite
2769 task cleanJalviewjsTransferSite {
2771 delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2772 delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2773 delete "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2774 delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2779 task cleanJalviewjsSite {
2780 dependsOn cleanJalviewjsTransferSite
2782 delete "${jalviewDir}/${jalviewjsSiteDir}"
2787 task jalviewjsSiteTar(type: Tar) {
2789 description "Creates a tar.gz file for the website"
2790 dependsOn jalviewjsBuildSite
2791 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
2793 archiveFileName = outputFilename
2794 } catch (Exception e) {
2795 archiveName = outputFilename
2798 compression Compression.GZIP
2800 from "${jalviewDir}/${jalviewjsSiteDir}"
2801 into jalviewjs_site_dir // this is inside the tar file
2803 inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
2807 task jalviewjsServer {
2809 def filename = "jalviewjsTest.html"
2810 description "Starts a webserver on localhost to test the website. See ${filename} to access local site on most recently used port."
2811 def htmlFile = "${jalviewDirAbsolutePath}/${filename}"
2814 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
2815 def port = Integer.valueOf(jalviewjs_server_port)
2820 while(port < start+1000 && !running) {
2822 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
2823 jalviewjsServer = factory.start(doc_root, port)
2825 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
2826 println("SERVER STARTED with document root ${doc_root}.")
2827 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
2828 println("For debug: "+url+"?j2sdebug")
2829 println("For verbose: "+url+"?j2sverbose")
2830 } catch (Exception e) {
2835 <p><a href="${url}">JalviewJS Test. <${url}></a></p>
2836 <p><a href="${url}?j2sdebug">JalviewJS Test with debug. <${url}?j2sdebug></a></p>
2837 <p><a href="${url}?j2sverbose">JalviewJS Test with verbose. <${url}?j2sdebug></a></p>
2839 jalviewjsCoreClasslists.each { cl ->
2840 def urlcore = jalviewjsServer.getResourceUrl(file(cl.outputfile).getName())
2842 <p><a href="${urlcore}">${jalviewjsJalviewTemplateName} [core ${cl.name}]. <${urlcore}></a></p>
2844 println("For core ${cl.name}: "+urlcore)
2847 file(htmlFile).text = htmlText
2850 outputs.file(htmlFile)
2851 outputs.upToDateWhen({false})
2855 task cleanJalviewjsAll {
2857 description "Delete all configuration and build artifacts to do with JalviewJS build"
2858 dependsOn cleanJalviewjsSite
2859 dependsOn jalviewjsEclipsePaths
2862 delete "${jalviewDir}/${jalviewjsBuildDir}"
2863 delete "${jalviewDir}/${eclipse_bin_dir}"
2864 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
2865 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
2867 delete jalviewjsJ2sAltSettingsFileName
2870 outputs.upToDateWhen( { false } )
2874 task jalviewjsIDE_checkJ2sPlugin {
2875 group "00 JalviewJS in Eclipse"
2876 description "Compare the swingjs/net.sf.j2s.core(-j11)?.jar file with the Eclipse IDE's plugin version (found in the 'dropins' dir)"
2879 def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}")
2880 def j2sPluginFile = file(j2sPlugin)
2881 def eclipseHome = System.properties["eclipse.home.location"]
2882 if (eclipseHome == null || ! IN_ECLIPSE) {
2883 throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.")
2885 def eclipseJ2sPluginDirs = [ "${eclipseHome}/dropins" ]
2886 def altPluginsDir = System.properties["org.eclipse.equinox.p2.reconciler.dropins.directory"]
2887 if (altPluginsDir != null && file(altPluginsDir).exists()) {
2888 eclipseJ2sPluginDirs += altPluginsDir
2890 def foundPlugin = false
2891 def j2sPluginFileName = j2sPluginFile.getName()
2892 def eclipseJ2sPlugin
2893 def eclipseJ2sPluginFile
2894 eclipseJ2sPluginDirs.any { dir ->
2895 eclipseJ2sPlugin = "${dir}/${j2sPluginFileName}"
2896 eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
2897 if (eclipseJ2sPluginFile.exists()) {
2903 def msg = "Eclipse J2S Plugin is not installed (could not find '${j2sPluginFileName}' in\n"+eclipseJ2sPluginDirs.join("\n")+"\n)\nTry running task jalviewjsIDE_copyJ2sPlugin"
2904 System.err.println(msg)
2905 throw new StopExecutionException(msg)
2908 def digest = MessageDigest.getInstance("MD5")
2910 digest.update(j2sPluginFile.text.bytes)
2911 def j2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2913 digest.update(eclipseJ2sPluginFile.text.bytes)
2914 def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2916 if (j2sPluginMd5 != eclipseJ2sPluginMd5) {
2917 def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'"
2918 System.err.println(msg)
2919 throw new StopExecutionException(msg)
2921 def msg = "Eclipse J2S Plugin '${eclipseJ2sPlugin}' is the same as '${j2sPlugin}' (this is good)"
2927 task jalviewjsIDE_copyJ2sPlugin {
2928 group "00 JalviewJS in Eclipse"
2929 description "Copy the swingjs/net.sf.j2s.core(-j11)?.jar file into the Eclipse IDE's 'dropins' dir"
2932 def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}")
2933 def j2sPluginFile = file(j2sPlugin)
2934 def eclipseHome = System.properties["eclipse.home.location"]
2935 if (eclipseHome == null || ! IN_ECLIPSE) {
2936 throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. NOT copying J2S Plugin.")
2938 def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}"
2939 def eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
2940 def msg = "WARNING! Copying this commit's j2s plugin '${j2sPlugin}' to Eclipse J2S Plugin '${eclipseJ2sPlugin}'\n* May require an Eclipse restart"
2941 System.err.println(msg)
2944 eclipseJ2sPluginFile.getParentFile().mkdirs()
2945 into eclipseJ2sPluginFile.getParent()
2951 task jalviewjsIDE_j2sFile {
2952 group "00 JalviewJS in Eclipse"
2953 description "Creates the .j2s file"
2954 dependsOn jalviewjsCreateJ2sSettings
2958 task jalviewjsIDE_SyncCore {
2959 group "00 JalviewJS in Eclipse"
2960 description "Build the core js lib closures listed in the classlists dir and publish core html from template"
2961 dependsOn jalviewjsSyncCore
2965 task jalviewjsIDE_SyncSiteAll {
2966 dependsOn jalviewjsSyncAllLibs
2967 dependsOn jalviewjsSyncResources
2968 dependsOn jalviewjsSyncSiteResources
2969 dependsOn jalviewjsSyncBuildProperties
2973 cleanJalviewjsTransferSite.mustRunAfter jalviewjsIDE_SyncSiteAll
2976 task jalviewjsIDE_PrepareSite {
2977 group "00 JalviewJS in Eclipse"
2978 description "Sync libs and resources to site dir, but not closure cores"
2980 dependsOn jalviewjsIDE_SyncSiteAll
2981 //dependsOn cleanJalviewjsTransferSite // not sure why this clean is here -- will slow down a re-run of this task
2985 task jalviewjsIDE_AssembleSite {
2986 group "00 JalviewJS in Eclipse"
2987 description "Assembles unzipped supporting zipfiles, resources, site resources and closure cores into the Eclipse transpiled site"
2988 dependsOn jalviewjsPrepareSite
2992 task jalviewjsIDE_SiteClean {
2993 group "00 JalviewJS in Eclipse"
2994 description "Deletes the Eclipse transpiled site"
2995 dependsOn cleanJalviewjsSite
2999 task jalviewjsIDE_Server {
3000 group "00 JalviewJS in Eclipse"
3001 description "Starts a webserver on localhost to test the website"
3002 dependsOn jalviewjsServer
3006 // buildship runs this at import or gradle refresh
3007 task eclipseSynchronizationTask {
3008 //dependsOn eclipseSetup
3009 dependsOn createBuildProperties
3011 dependsOn jalviewjsIDE_j2sFile
3012 dependsOn jalviewjsIDE_checkJ2sPlugin
3013 dependsOn jalviewjsIDE_PrepareSite
3018 // buildship runs this at build time or project refresh
3019 task eclipseAutoBuildTask {
3020 //dependsOn jalviewjsIDE_checkJ2sPlugin
3021 //dependsOn jalviewjsIDE_PrepareSite
3027 description "Build the site"
3028 dependsOn jalviewjsBuildSite