1 import org.apache.tools.ant.filters.ReplaceTokens
2 import org.gradle.internal.os.OperatingSystem
3 import org.gradle.plugins.ide.eclipse.model.Output
4 import org.gradle.plugins.ide.eclipse.model.Library
5 import java.security.MessageDigest
7 import groovy.transform.ExternalizeMethods
11 classpath 'org.openclover:clover:4.3.1'
19 id 'com.github.johnrengelman.shadow' version '4.0.3'
20 id 'com.install4j.gradle' version '7.0.9'
21 id 'com.dorongold.task-tree' version '1.4' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
34 compile 'org.apache.commons:commons-compress:1.18'
38 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
39 def string(Object o) {
45 jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
46 jalviewDirRelativePath = jalviewDir
48 // local build environment properties
49 def localProps = "${jalviewDirAbsolutePath}/local.properties"
50 if (file(localProps).exists()) {
52 def p = new Properties()
53 def localPropsFIS = new FileInputStream(localProps)
58 def over = getProperty(key) != null
61 println("Overriding property '${key}' with local.properties value '${val}'")
64 } catch (Exception e) {
65 System.out.println("Exception reading local.properties")
69 // this property set when running Eclipse headlessly
70 j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
71 // this property set by Eclipse
72 eclipseApplicationProperty = string("eclipse.application")
73 // CHECK IF RUNNING FROM WITHIN ECLIPSE
74 def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
75 IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
76 // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
77 if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
78 println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
82 println("WITHIN ECLIPSE IDE")
84 println("HEADLESS BUILD")
87 J2S_ENABLED = (project.hasProperty('j2s.compiler.status') && project['j2s.compiler.status'] != null && project['j2s.compiler.status'] == "enable")
89 println("J2S ENABLED")
93 System.properties.sort { it.key }.each {
94 key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
97 if (false && IN_ECLIPSE) {
98 jalviewDir = jalviewDirAbsolutePath
103 bareSourceDir = string(source_dir)
104 sourceDir = string("${jalviewDir}/${bareSourceDir}")
105 resourceDir = string("${jalviewDir}/${resource_dir}")
106 bareTestSourceDir = string(test_source_dir)
107 testSourceDir = string("${jalviewDir}/${bareTestSourceDir}")
110 cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
111 classesDir = string("${jalviewDir}/${classes_dir}")
112 if (clover.equals("true")) {
114 classesDir = string("${buildDir}/${cloverClassesDir}")
117 classesDir = string("${jalviewDir}/${classes_dir}")
122 getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
123 getdownDir = string("")
124 reportRsyncCmd = false
126 buildProperties = build_properties_file
127 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
131 // TODO: get bamboo build artifact URL for getdown artifacts
132 getdown_channel_base = bamboo_channelbase
133 getdown_channel_name = string("${bamboo_planKey}/${JAVA_VERSION}")
134 getdown_app_base = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
135 getdown_app_dir = getdown_app_dir_alt
136 buildProperties = string("${classesDir}/${build_properties_file}")
140 getdown_channel_name = CHANNEL.toLowerCase()
141 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
142 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
143 getdown_app_dir = getdown_app_dir_release
144 buildProperties = string("${classesDir}/${build_properties_file}")
145 reportRsyncCommand = true
149 getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
150 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
151 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
152 getdown_app_dir = getdown_app_dir_alt
153 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
154 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
157 packageDir = string("${ARCHIVEDIR}/${packageDir}")
158 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
161 reportRsyncCommand = true
165 getdown_channel_name = string("archive/${JALVIEW_VERSION}")
166 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
167 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
168 getdown_app_dir = getdown_app_dir_alt
169 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
170 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
173 packageDir = string("${ARCHIVEDIR}/${packageDir}")
174 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
177 reportRsyncCommand = true
178 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
182 getdown_channel_name = CHANNEL.toLowerCase()
183 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
184 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
185 getdown_app_dir = getdown_app_dir_alt
186 buildProperties = string("${classesDir}/${build_properties_file}")
187 reportRsyncCommand = true
191 getdown_channel_name = CHANNEL.toLowerCase()
192 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
193 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
194 getdown_app_dir = getdown_app_dir_alt
195 buildProperties = string("${classesDir}/${build_properties_file}")
196 reportRsyncCommand = true
199 case ~/^SCRATCH(|-[-\w]*)$/:
200 getdown_channel_name = CHANNEL
201 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
202 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
203 getdown_app_dir = getdown_app_dir_alt
204 buildProperties = string("${classesDir}/${build_properties_file}")
205 reportRsyncCommand = true
209 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
210 getdown_app_dir = getdown_app_dir_alt
211 buildProperties = string("${classesDir}/${build_properties_file}")
212 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
215 default: // something wrong specified
216 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
221 buildProperties = string("${resourceDir}/${build_properties_file}")
223 getdownAppDir = string("${getdownWebsiteDir}/${getdown_app_dir}")
224 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
225 getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
226 getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
227 getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
228 getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
229 /* compile without modules -- using classpath libraries
230 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
231 modules_runtimeClasspath = modules_compileClasspath
234 gitBranch = string("")
236 println("Using a ${CHANNEL} profile.")
238 additional_compiler_args = []
239 // configure classpath/args for j8/j11 compilation
240 if (JAVA_VERSION.equals("1.8")) {
241 JAVA_INTEGER_VERSION = string("8")
244 libDistDir = j8libDir
245 compile_source_compatibility = 1.8
246 compile_target_compatibility = 1.8
247 // these are getdown.txt properties defined dependent on the JAVA_VERSION
248 getdown_alt_java_min_version = getdown_alt_java8_min_version
249 getdown_alt_java_max_version = getdown_alt_java8_max_version
250 // this property is assigned below and expanded to multiple lines in the getdown task
251 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
252 // this property is for the Java library used in eclipse
253 eclipse_java_runtime_name = string("JavaSE-1.8")
254 } else if (JAVA_VERSION.equals("11")) {
255 JAVA_INTEGER_VERSION = string("11")
257 libDistDir = j11libDir
258 compile_source_compatibility = 11
259 compile_target_compatibility = 11
260 getdown_alt_java_min_version = getdown_alt_java11_min_version
261 getdown_alt_java_max_version = getdown_alt_java11_max_version
262 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
263 eclipse_java_runtime_name = string("JavaSE-11")
264 /* compile without modules -- using classpath libraries
265 additional_compiler_args += [
266 '--module-path', modules_compileClasspath.asPath,
267 '--add-modules', j11modules
270 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
271 JAVA_INTEGER_VERSION = JAVA_VERSION
273 libDistDir = j11libDir
274 compile_source_compatibility = JAVA_VERSION
275 compile_target_compatibility = JAVA_VERSION
276 getdown_alt_java_min_version = getdown_alt_java11_min_version
277 getdown_alt_java_max_version = getdown_alt_java11_max_version
278 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
279 eclipse_java_runtime_name = string("JavaSE-11")
280 /* compile without modules -- using classpath libraries
281 additional_compiler_args += [
282 '--module-path', modules_compileClasspath.asPath,
283 '--add-modules', j11modules
287 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
292 macosJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre")
293 macosJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz")
294 windowsJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre")
295 windowsJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz")
296 install4jDir = string("${jalviewDir}/${install4jResourceDir}")
297 install4jConfFileName = string("jalview-installers-java${JAVA_VERSION}.install4j")
298 install4jConfFile = string("${install4jDir}/${install4jConfFileName}")
301 buildingHTML = string("${jalviewDir}/${docDir}/building.html")
302 helpFile = string("${classesDir}/${help_dir}/help.jhm")
303 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
304 helpDir = string("${help_dir}")
305 helpSourceDir = string("${helpParentDir}/${helpDir}")
308 relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
309 jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
310 jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
312 jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
314 jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
316 jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
317 jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
318 jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
319 jalviewjsJalviewCoreHtmlFile = string("")
320 jalviewjsJalviewCoreName = string(jalviewjs_core_name)
321 jalviewjsCoreClasslists = []
322 jalviewjsJalviewTemplateName = string(jalviewjs_name)
323 jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
324 jalviewjsJ2sProps = null
326 eclipseWorkspace = null
327 eclipseBinary = string("")
328 eclipseVersion = string("")
338 outputDir = file(classesDir)
345 jar.destinationDir = file("${jalviewDir}/${packageDir}")
347 compileClasspath = files(sourceSets.main.java.outputDir)
348 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
350 runtimeClasspath = compileClasspath
355 srcDirs = [ cloverInstrDir ]
356 outputDir = file("${buildDir}/${cloverClassesDir}")
360 srcDirs = sourceSets.main.resources.srcDirs
362 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
363 compileClasspath += files(sourceSets.main.java.outputDir)
364 compileClasspath += sourceSets.main.compileClasspath
365 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
366 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
368 runtimeClasspath = compileClasspath
373 srcDirs testSourceDir
374 outputDir = file("${jalviewDir}/${testOutputDir}")
378 srcDirs = sourceSets.main.resources.srcDirs
381 compileClasspath = files( sourceSets.test.java.outputDir )
384 compileClasspath += sourceSets.clover.compileClasspath
386 compileClasspath += files(sourceSets.main.java.outputDir)
389 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
390 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
391 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
393 runtimeClasspath = compileClasspath
401 cloverCompile 'org.openclover:clover:4.3.1'
402 testCompile 'org.openclover:clover:4.3.1'
409 cloverRuntime.extendsFrom cloverCompile
414 name = eclipse_project_name
416 natures 'org.eclipse.jdt.core.javanature',
417 'org.eclipse.jdt.groovy.core.groovyNature',
418 'org.eclipse.buildship.core.gradleprojectnature'
420 buildCommand 'org.eclipse.jdt.core.javabuilder'
421 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
425 //defaultOutputDir = sourceSets.main.java.outputDir
428 if (it.isCanBeResolved()) {
433 minusConfigurations += removeThese
434 plusConfigurations = [ ]
438 def removeTheseToo = []
439 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
440 cp.entries.each { entry ->
441 // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
442 // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
443 // we add the resources and help/help dirs in as libs afterwards (see below)
444 if (entry.kind == 'src') {
445 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
446 removeTheseToo += entry
448 alreadyAddedSrcPath.putAt(entry.path, true)
453 cp.entries.removeAll(removeTheseToo)
455 //cp.entries += new Output("${eclipse_bin_dir}/main")
456 if (file(helpSourceDir).isDirectory()) {
457 cp.entries += new Library(fileReference(helpSourceDir))
459 if (file(resourceDir).isDirectory()) {
460 cp.entries += new Library(fileReference(resourceDir))
463 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
465 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
466 //don't want to add outputDir as eclipse is using its own output dir in bin/main
467 if (it.isDirectory() || ! it.exists()) {
468 // don't add dirs to classpath, especially if they don't exist
469 return false // groovy "continue" in .any closure
471 def itPath = it.toString()
472 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
473 // make relative path
474 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
476 if (alreadyAddedLibPath.get(itPath)) {
477 //println("Not adding duplicate entry "+itPath)
479 //println("Adding entry "+itPath)
480 cp.entries += new Library(fileReference(itPath))
481 alreadyAddedLibPath.put(itPath, true)
485 //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
486 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
487 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
488 if (it.isDirectory() || ! it.exists()) {
489 // don't add dirs to classpath
490 return false // groovy "continue" in .any closure
493 def itPath = it.toString()
494 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
495 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
497 if (alreadyAddedLibPath.get(itPath)) {
500 def lib = new Library(fileReference(itPath))
501 lib.entryAttributes["test"] = "true"
503 alreadyAddedLibPath.put(itPath, true)
511 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
516 // for the IDE, use java 11 compatibility
517 sourceCompatibility = compile_source_compatibility
518 targetCompatibility = compile_target_compatibility
519 javaRuntimeName = eclipse_java_runtime_name
521 // add in jalview project specific properties/preferences into eclipse core preferences
523 withProperties { props ->
524 def jalview_prefs = new Properties()
525 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
526 jalview_prefs.load(ins)
528 jalview_prefs.forEach { t, v ->
529 if (props.getAt(t) == null) {
539 // Don't want these to be activated if in headless build
540 synchronizationTasks "eclipseSynchronizationTask"
541 //autoBuildTasks "eclipseAutoBuildTask"
548 // only instrument source, we build test classes as normal
549 inputs.files files (sourceSets.main.allJava) // , fileTree(dir: testSourceDir, include: ["**/*.java"]))
550 outputs.dir cloverInstrDir
553 delete cloverInstrDir
554 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
555 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
556 argsList.addAll(inputs.files.files.collect({ file ->
559 String[] args = argsList.toArray()
560 println("About to instrument "+args.length +" files")
561 com.atlassian.clover.CloverInstr.mainImpl(args)
567 group = "Verification"
568 description = "Createst the Clover report"
569 inputs.dir "${buildDir}/clover"
570 outputs.dir "${reportsDir}/clover"
572 file("${buildDir}/clover/clover.db").exists()
575 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
576 "-o", "${reportsDir}/clover"]
577 String[] args = argsList.toArray()
578 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
580 // and generate ${reportsDir}/clover/clover.xml
581 args = ["--initstring", "${buildDir}/clover/clover.db",
582 "-o", "${reportsDir}/clover/clover.xml"].toArray()
583 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
592 sourceCompatibility = compile_source_compatibility
593 targetCompatibility = compile_target_compatibility
594 options.compilerArgs = additional_compiler_args
595 print ("Setting target compatibility to "+targetCompatibility+"\n")
603 dependsOn compileCloverJava
604 classpath += configurations.cloverRuntime
606 classpath += sourceSets.main.runtimeClasspath
609 sourceCompatibility = compile_source_compatibility
610 targetCompatibility = compile_target_compatibility
611 options.compilerArgs = additional_compiler_args
612 print ("Setting target compatibility to "+targetCompatibility+"\n")
620 sourceCompatibility = compile_source_compatibility
621 targetCompatibility = compile_target_compatibility
622 options.compilerArgs += additional_compiler_args
623 print ("Setting target compatibility to "+targetCompatibility+"\n")
625 classpath += configurations.cloverRuntime
631 delete sourceSets.main.java.outputDir
638 delete sourceSets.test.java.outputDir
639 delete cloverInstrDir
644 // format is a string like date.format("dd MMMM yyyy")
645 def getDate(format) {
646 def date = new Date()
647 return date.format(format)
652 def hashStdOut = new ByteArrayOutputStream()
654 commandLine "git", "rev-parse", "--short", "HEAD"
655 standardOutput = hashStdOut
659 def branchStdOut = new ByteArrayOutputStream()
661 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
662 standardOutput = branchStdOut
666 gitHash = hashStdOut.toString().trim()
667 gitBranch = branchStdOut.toString().trim()
669 outputs.upToDateWhen { false }
673 task createBuildProperties(type: WriteProperties) {
675 description = "Create the ${buildProperties} file"
677 inputs.dir(sourceDir)
678 inputs.dir(resourceDir)
679 file(buildProperties).getParentFile().mkdirs()
680 outputFile (buildProperties)
681 // taking time specific comment out to allow better incremental builds
682 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
683 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
684 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
685 property "VERSION", JALVIEW_VERSION
686 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
687 outputs.file(outputFile)
693 delete buildProperties
698 task cleanBuildingHTML(type: Delete) {
705 task convertBuildingMD(type: Exec) {
706 dependsOn cleanBuildingHTML
707 def buildingMD = "${jalviewDir}/${docDir}/building.md"
708 def css = "${jalviewDir}/${docDir}/github.css"
711 pandoc_exec.split(",").each {
712 if (file(it.trim()).exists()) {
718 def hostname = "hostname".execute().text.trim()
719 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
720 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
724 if (pandoc != null && file(pandoc).exists()) {
725 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
727 println("Cannot find pandoc. Skipping convert building.md to HTML")
728 throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
734 inputs.file(buildingMD)
736 outputs.file(buildingHTML)
747 task syncDocs(type: Sync) {
748 dependsOn convertBuildingMD
749 def syncDir = "${classesDir}/${docDir}"
750 from fileTree("${jalviewDir}/${docDir}")
756 task copyHelp(type: Copy) {
757 def inputDir = helpSourceDir
758 def outputDir = "${classesDir}/${helpDir}"
763 filter(ReplaceTokens,
767 'Version-Rel': JALVIEW_VERSION,
768 'Year-Rel': getDate("yyyy")
780 outputs.files(helpFile)
781 outputs.dir(outputDir)
785 task syncLib(type: Sync) {
786 def syncDir = "${classesDir}/${libDistDir}"
787 from fileTree("${jalviewDir}/${libDistDir}")
792 task syncResources(type: Sync) {
793 dependsOn createBuildProperties
804 dependsOn syncResources
810 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
813 dependsOn compileJava
815 dependsOn cloverInstr
819 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
823 includeGroups testngGroups
825 useDefaultListeners=true
828 workingDir = jalviewDir
829 //systemProperties 'clover.jar' System.properties.clover.jar
830 sourceCompatibility = compile_source_compatibility
831 targetCompatibility = compile_target_compatibility
832 jvmArgs += additional_compiler_args
837 task buildIndices(type: JavaExec) {
839 classpath = sourceSets.main.compileClasspath
840 main = "com.sun.java.help.search.Indexer"
841 workingDir = "${classesDir}/${helpDir}"
844 inputs.dir("${workingDir}/${argDir}")
846 outputs.dir("${classesDir}/doc")
847 outputs.dir("${classesDir}/help")
848 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
849 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
850 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
851 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
852 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
853 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
857 task compileLinkCheck(type: JavaCompile) {
859 classpath = files("${jalviewDir}/${utilsDir}")
860 destinationDir = file("${jalviewDir}/${utilsDir}")
861 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
863 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
864 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
865 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
866 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
870 task linkCheck(type: JavaExec) {
871 dependsOn prepare, compileLinkCheck
873 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
874 classpath = files("${jalviewDir}/${utilsDir}")
875 main = "HelpLinksChecker"
876 workingDir = jalviewDir
877 def help = "${classesDir}/${helpDir}"
878 args = [ "${classesDir}/${helpDir}", "-nointernet" ]
880 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
882 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
885 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
889 inputs.dir("${classesDir}/${helpDir}")
890 outputs.file(helpLinksCheckerOutFile)
893 // import the pubhtmlhelp target
894 ant.properties.basedir = "${jalviewDir}"
895 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${helpDir}"
896 ant.importBuild "${utilsDir}/publishHelp.xml"
899 task cleanPackageDir(type: Delete) {
901 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
908 dependsOn buildIndices
909 dependsOn createBuildProperties
912 attributes "Main-Class": mainClass,
913 "Permissions": "all-permissions",
914 "Application-Name": "Jalview Desktop",
915 "Codebase": application_codebase
918 destinationDir = file("${jalviewDir}/${packageDir}")
919 archiveName = rootProject.name+".jar"
927 inputs.dir(classesDir)
928 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
932 task copyJars(type: Copy) {
933 from fileTree(dir: classesDir, include: "**/*.jar").files
934 into "${jalviewDir}/${packageDir}"
938 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
939 task syncJars(type: Sync) {
940 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
941 into "${jalviewDir}/${packageDir}"
943 include jar.archiveName
950 description = "Put all required libraries in dist"
951 // order of "cleanPackageDir", "copyJars", "jar" important!
952 jar.mustRunAfter cleanPackageDir
953 syncJars.mustRunAfter cleanPackageDir
954 dependsOn cleanPackageDir
957 outputs.dir("${jalviewDir}/${packageDir}")
962 dependsOn cleanPackageDir
968 group = "distribution"
972 from ("${jalviewDir}/${libDistDir}") {
976 attributes 'Implementation-Version': JALVIEW_VERSION
978 mainClassName = shadowJarMainClass
980 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
985 task getdownWebsite() {
986 group = "distribution"
987 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
992 def getdownWebsiteResourceFilenames = []
993 def getdownTextString = ""
994 def getdownResourceDir = getdownResourceDir
995 def getdownAppDir = getdownAppDir
996 def getdownResourceFilenames = []
999 // clean the getdown website and files dir before creating getdown folders
1000 delete getdownWebsiteDir
1001 delete getdownFilesDir
1004 from buildProperties
1005 rename(build_properties_file, getdown_build_properties)
1008 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
1010 // go through properties looking for getdown_txt_...
1011 def props = project.properties.sort { it.key }
1012 if (getdown_alt_java_min_version.length() > 0) {
1013 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
1015 if (getdown_alt_java_max_version.length() > 0) {
1016 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
1018 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
1020 props.put("getdown_txt_appbase", getdown_app_base)
1021 props.each{ prop, val ->
1022 if (prop.startsWith("getdown_txt_") && val != null) {
1023 if (prop.startsWith("getdown_txt_multi_")) {
1024 def key = prop.substring(18)
1025 val.split(",").each{ v ->
1026 def line = "${key} = ${v}\n"
1027 getdownTextString += line
1030 // file values rationalised
1031 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1033 if (val.indexOf('/') == 0) {
1036 } else if (val.indexOf('/') > 0) {
1037 // relative path (relative to jalviewDir)
1038 r = file( "${jalviewDir}/${val}" )
1041 val = "${getdown_resource_dir}/" + r.getName()
1042 getdownWebsiteResourceFilenames += val
1043 getdownResourceFilenames += r.getPath()
1046 if (! prop.startsWith("getdown_txt_resource")) {
1047 def line = prop.substring(12) + " = ${val}\n"
1048 getdownTextString += line
1054 getdownWebsiteResourceFilenames.each{ filename ->
1055 getdownTextString += "resource = ${filename}\n"
1057 getdownResourceFilenames.each{ filename ->
1060 into getdownResourceDir
1065 fileTree(file(packageDir)).each{ f ->
1066 if (f.isDirectory()) {
1067 def files = fileTree(dir: f, include: ["*"]).getFiles()
1069 } else if (f.exists()) {
1073 codeFiles.sort().each{f ->
1074 def name = f.getName()
1075 def line = "code = ${getdown_app_dir}/${name}\n"
1076 getdownTextString += line
1083 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1085 if (JAVA_VERSION.equals("11")) {
1086 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1087 j11libFiles.sort().each{f ->
1088 def name = f.getName()
1089 def line = "code = ${getdown_j11lib_dir}/${name}\n"
1090 getdownTextString += line
1093 into getdownJ11libDir
1099 // 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.
1100 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1101 getdownTextString += "resource = ${getdown_launcher_new}\n"
1102 getdownTextString += "class = ${mainClass}\n"
1104 def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1105 getdown_txt.write(getdownTextString)
1107 def launch_jvl = file("${getdownWebsiteDir}/${getdown_launch_jvl}")
1108 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
1111 from getdownLauncher
1112 rename(file(getdownLauncher).getName(), getdown_launcher_new)
1113 into getdownWebsiteDir
1117 from getdownLauncher
1118 if (file(getdownLauncher).getName() != getdown_launcher) {
1119 rename(file(getdownLauncher).getName(), getdown_launcher)
1121 into getdownWebsiteDir
1124 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1127 from getdownLauncher
1128 from "${getdownWebsiteDir}/${getdown_build_properties}"
1129 if (file(getdownLauncher).getName() != getdown_launcher) {
1130 rename(file(getdownLauncher).getName(), getdown_launcher)
1132 into getdownInstallDir
1136 from getdownInstallDir
1137 into getdownFilesInstallDir
1144 from getdownLauncher
1145 from "${getdownWebsiteDir}/${getdown_build_properties}"
1146 if (file(getdownLauncher).getName() != getdown_launcher) {
1147 rename(file(getdownLauncher).getName(), getdown_launcher)
1149 into getdownFilesDir
1153 from getdownResourceDir
1154 into "${getdownFilesDir}/${getdown_resource_dir}"
1159 inputs.dir("${jalviewDir}/${packageDir}")
1161 outputs.dir(getdownWebsiteDir)
1162 outputs.dir(getdownFilesDir)
1166 task getdownDigest(type: JavaExec) {
1167 group = "distribution"
1168 description = "Digest the getdown website folder"
1169 dependsOn getdownWebsite
1171 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1173 main = "com.threerings.getdown.tools.Digester"
1174 args getdownWebsiteDir
1175 inputs.dir(getdownWebsiteDir)
1176 outputs.file("${getdownWebsiteDir}/digest2.txt")
1181 group = "distribution"
1182 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1183 dependsOn getdownDigest
1185 if (reportRsyncCommand) {
1186 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1187 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1188 println "LIKELY RSYNC COMMAND:"
1189 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1190 if (RUNRSYNC == "true") {
1192 commandLine "mkdir", "-p", toDir
1195 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1205 delete getdownWebsiteDir
1206 delete getdownFilesDir
1212 def install4jHomeDir = "/opt/install4j"
1213 def hostname = "hostname".execute().text.trim()
1214 if (hostname.equals("jv-bamboo")) {
1215 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1216 } else if (OperatingSystem.current().isMacOsX()) {
1217 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1218 if (! file(install4jHomeDir).exists()) {
1219 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1221 } else if (OperatingSystem.current().isLinux()) {
1222 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1224 installDir = file(install4jHomeDir)
1225 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1226 if (install4jFaster.equals("true")) {
1232 task copyInstall4jTemplate(type: Copy) {
1233 from (install4jDir) {
1234 include install4jTemplate
1235 rename (install4jTemplate, install4jConfFileName)
1236 filter(ReplaceTokens,
1240 '9999999999': JAVA_VERSION
1243 filter(ReplaceTokens,
1247 'JAVA_VERSION': JAVA_VERSION,
1248 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1249 'VERSION': JALVIEW_VERSION,
1250 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1251 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1252 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1253 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1254 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1255 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1256 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1257 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1258 'GETDOWN_DIST_DIR': getdown_app_dir,
1259 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1260 'GETDOWN_INSTALL_DIR': getdown_install_dir
1263 if (OSX_KEYPASS == "") {
1264 filter(ReplaceTokens,
1265 beginToken: 'codeSigning macEnabled="',
1268 'true': 'codeSigning macEnabled="false"'
1271 filter(ReplaceTokens,
1272 beginToken: 'runPostProcessor="true" ',
1273 endToken: 'Processor',
1275 'post': 'runPostProcessor="false" postProcessor'
1281 outputs.files(install4jConfFile)
1284 // include file associations in installer
1285 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1289 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1290 replace: installerFileAssociationsXml,
1291 file: install4jConfFile
1294 // include uninstaller applescript app files in dmg
1295 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1299 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1300 replace: installerDMGUninstallerXml,
1301 file: install4jConfFile
1310 delete install4jConfFile
1315 task installers(type: com.install4j.gradle.Install4jTask) {
1316 group = "distribution"
1317 description = "Create the install4j installers"
1319 dependsOn copyInstall4jTemplate
1320 projectFile = file(install4jConfFile)
1321 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1322 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1323 buildSelected = true
1326 macKeystorePassword=OSX_KEYPASS
1330 println("Using projectFile "+projectFile)
1333 inputs.dir(getdownWebsiteDir)
1334 inputs.file(install4jConfFile)
1335 inputs.dir(macosJavaVMDir)
1336 inputs.dir(windowsJavaVMDir)
1337 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1341 task sourceDist (type: Tar) {
1343 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1344 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1345 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1347 archiveFileName = outputFileName
1348 } catch (Exception e) {
1349 archiveName = outputFileName
1352 compression Compression.GZIP
1356 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1361 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1363 ,"utils/InstallAnywhere"]
1364 def PROCESS_FILES=[ "AUTHORS",
1372 "THIRDPARTYLIBS","TESTNG",
1374 "gradle.properties",
1385 exclude (EXCLUDE_FILES)
1386 include (PROCESS_FILES)
1387 filter(ReplaceTokens,
1391 'Version-Rel': JALVIEW_VERSION,
1392 'Year-Rel': getDate("yyyy")
1397 exclude (EXCLUDE_FILES)
1398 exclude (PROCESS_FILES)
1399 exclude ("appletlib")
1400 exclude ("**/*locales")
1401 exclude ("*locales/**")
1402 exclude ("utils/InstallAnywhere")
1404 exclude (getdown_files_dir)
1405 exclude (getdown_website_dir)
1407 // exluding these as not using jars as modules yet
1408 exclude ("${j11modDir}/**/*.jar")
1410 // from (jalviewDir) {
1411 // // explicit includes for stuff that seemed to not get included
1412 // include(fileTree("test/**/*."))
1413 // exclude(EXCLUDE_FILES)
1414 // exclude(PROCESS_FILES)
1421 dependsOn pubhtmlhelp
1423 inputs.dir("${classesDir}/${helpDir}")
1424 outputs.dir("${buildDir}/distributions/${helpDir}")
1428 task j2sSetHeadlessBuild {
1435 task jalviewjsSetEclipseWorkspace {
1436 def propKey = "jalviewjs_eclipse_workspace"
1438 if (project.hasProperty(propKey)) {
1439 propVal = project.getProperty(propKey)
1440 if (propVal.startsWith("~/")) {
1441 propVal = System.getProperty("user.home") + propVal.substring(1)
1444 def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1445 def propsFile = file(propsFileName)
1446 def eclipseWsDir = propVal
1447 def props = new Properties()
1449 def writeProps = true
1450 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
1451 def ins = new FileInputStream(propsFileName)
1454 if (props.getProperty(propKey, null) != null) {
1455 eclipseWsDir = props.getProperty(propKey)
1460 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1461 def tempDir = File.createTempDir()
1462 eclipseWsDir = tempDir.getAbsolutePath()
1465 eclipseWorkspace = file(eclipseWsDir)
1468 // do not run a headless transpile when we claim to be in Eclipse
1470 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1471 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1473 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1477 props.setProperty(propKey, eclipseWsDir)
1478 propsFile.parentFile.mkdirs()
1479 def bytes = new ByteArrayOutputStream()
1480 props.store(bytes, null)
1481 def propertiesString = bytes.toString()
1482 propsFile.text = propertiesString
1488 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1491 //inputs.property(propKey, eclipseWsDir) // eclipseWsDir only gets set once this task runs, so will be out-of-date
1492 outputs.file(propsFileName)
1493 outputs.upToDateWhen { eclipseWorkspace.exists() && propsFile.exists() }
1497 task jalviewjsEclipsePaths {
1500 def eclipseRoot = jalviewjs_eclipse_root
1501 if (eclipseRoot.startsWith("~/")) {
1502 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1504 if (OperatingSystem.current().isMacOsX()) {
1505 eclipseRoot += "/Eclipse.app"
1506 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1507 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1508 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1509 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1510 eclipseRoot += "/eclipse.exe"
1512 eclipseBinary = "${eclipseRoot}/eclipse"
1513 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1514 } else { // linux or unix
1515 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1516 eclipseRoot += "/eclipse"
1518 eclipseBinary = "${eclipseRoot}/eclipse"
1519 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1522 eclipseVersion = "4.13" // default
1523 def assumedVersion = true
1524 if (file(eclipseProduct).exists()) {
1525 def fis = new FileInputStream(eclipseProduct)
1526 def props = new Properties()
1528 eclipseVersion = props.getProperty("version")
1530 assumedVersion = false
1533 def propKey = "eclipse_debug"
1534 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1537 // do not run a headless transpile when we claim to be in Eclipse
1539 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1540 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1542 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1545 if (!assumedVersion) {
1546 println("ECLIPSE VERSION=${eclipseVersion}")
1553 dependsOn eclipseProject
1554 dependsOn eclipseClasspath
1555 dependsOn eclipseJdt
1559 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1560 task jalviewjsEclipseCopyDropins(type: Copy) {
1561 dependsOn jalviewjsEclipsePaths
1563 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1564 inputFiles += file("${jalviewDir}/${jalviewjs_j2s_plugin}")
1565 def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
1572 // this eclipse -clean doesn't actually work
1573 task jalviewjsCleanEclipse(type: Exec) {
1574 dependsOn eclipseSetup
1575 dependsOn jalviewjsEclipsePaths
1576 dependsOn jalviewjsEclipseCopyDropins
1578 executable(eclipseBinary)
1579 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
1585 def inputString = """exit
1588 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
1589 standardInput = inputByteStream
1592 /* not really working yet
1593 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
1597 task jalviewjsTransferUnzipSwingJs {
1598 def file_zip = "${jalviewDir}/${jalviewjs_swingjs_zip}"
1602 from zipTree(file_zip)
1603 into "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
1607 inputs.file file_zip
1608 outputs.dir "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
1612 task jalviewjsTransferUnzipLib {
1613 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
1616 zipFiles.each { file_zip ->
1618 from zipTree(file_zip)
1619 into "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
1624 inputs.files zipFiles
1625 outputs.dir "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
1629 task jalviewjsTransferUnzipAllLibs {
1630 dependsOn jalviewjsTransferUnzipSwingJs
1631 dependsOn jalviewjsTransferUnzipLib
1635 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1637 description "Create the .j2s file from the j2s.* properties"
1639 jalviewjsJ2sProps = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1640 def siteDirProperty = "j2s.site.directory"
1641 def setSiteDir = false
1642 jalviewjsJ2sProps.each { prop, val ->
1644 if (prop == siteDirProperty) {
1645 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1646 val = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${val}"
1652 if (!setSiteDir) { // default site location, don't override specifically set property
1653 property(siteDirProperty,"${jalviewDirRelativePath}/${jalviewjsTransferSiteJsDir}")
1656 outputFile = jalviewjsJ2sSettingsFileName
1659 inputs.properties(jalviewjsJ2sProps)
1660 outputs.file(jalviewjsJ2sSettingsFileName)
1665 task jalviewjsEclipseSetup {
1666 dependsOn jalviewjsEclipseCopyDropins
1667 dependsOn jalviewjsSetEclipseWorkspace
1668 dependsOn jalviewjsCreateJ2sSettings
1672 task jalviewjsSyncAllLibs (type: Sync) {
1673 dependsOn jalviewjsTransferUnzipAllLibs
1674 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteLibDir}")
1675 inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
1676 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1680 def outputFiles = []
1681 rename { filename ->
1682 outputFiles += "${outputDir}/${filename}"
1688 outputs.files outputFiles
1689 inputs.files inputFiles
1693 task jalviewjsSyncResources (type: Sync) {
1694 def inputFiles = fileTree(dir: resourceDir)
1695 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1699 def outputFiles = []
1700 rename { filename ->
1701 outputFiles += "${outputDir}/${filename}"
1707 outputs.files outputFiles
1708 inputs.files inputFiles
1712 task jalviewjsSyncSiteResources (type: Sync) {
1713 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
1714 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1718 def outputFiles = []
1719 rename { filename ->
1720 outputFiles += "${outputDir}/${filename}"
1726 outputs.files outputFiles
1727 inputs.files inputFiles
1731 task jalviewjsSyncBuildProperties (type: Sync) {
1732 dependsOn createBuildProperties
1733 def inputFiles = [file(buildProperties)]
1734 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1738 def outputFiles = []
1739 rename { filename ->
1740 outputFiles += "${outputDir}/${filename}"
1746 outputs.files outputFiles
1747 inputs.files inputFiles
1751 task jalviewjsProjectImport(type: Exec) {
1752 dependsOn eclipseSetup
1753 dependsOn jalviewjsEclipsePaths
1754 dependsOn jalviewjsEclipseSetup
1757 // do not run a headless import when we claim to be in Eclipse
1759 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1760 throw new StopExecutionException("Not running headless import whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1762 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1766 //def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1767 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview"
1768 executable(eclipseBinary)
1769 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1773 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1775 args += [ "-D${j2sHeadlessBuildProperty}=true" ]
1778 inputs.file("${jalviewDir}/.project")
1779 outputs.upToDateWhen {
1780 file(projdir).exists()
1785 task jalviewjsTranspile(type: Exec) {
1786 dependsOn jalviewjsEclipseSetup
1787 dependsOn jalviewjsProjectImport
1788 dependsOn jalviewjsEclipsePaths
1791 // do not run a headless transpile when we claim to be in Eclipse
1793 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1794 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1796 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1800 executable(eclipseBinary)
1801 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
1805 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1807 args += [ "-D${j2sHeadlessBuildProperty}=true" ]
1813 stdout = new ByteArrayOutputStream()
1814 stderr = new ByteArrayOutputStream()
1816 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}"
1817 def logOutFile = file(logOutFileName)
1818 logOutFile.createNewFile()
1819 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
1820 BINARY: ${eclipseBinary}
1821 VERSION: ${eclipseVersion}
1822 WORKSPACE: ${eclipseWorkspace}
1823 DEBUG: ${eclipseDebug}
1826 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1827 // combine stdout and stderr
1828 def logErrFOS = logOutFOS
1830 if (jalviewjs_j2s_to_console.equals("true")) {
1831 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1832 new org.apache.tools.ant.util.TeeOutputStream(
1836 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1837 new org.apache.tools.ant.util.TeeOutputStream(
1842 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1845 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1852 if (stdout.toString().contains("Error processing ")) {
1853 // j2s did not complete transpile
1854 //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
1855 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
1859 inputs.dir("${jalviewDir}/${sourceDir}")
1860 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
1861 outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
1865 def jalviewjsCallCore(String name, FileCollection list, String prefixFile, String suffixFile, String jsfile, String zjsfile, File logOutFile, Boolean logOutConsole) {
1867 def stdout = new ByteArrayOutputStream()
1868 def stderr = new ByteArrayOutputStream()
1870 def coreFile = file(jsfile)
1872 msg = "Creating core for ${name}...\nGenerating ${jsfile}"
1874 logOutFile.createNewFile()
1875 logOutFile.append(msg+"\n")
1877 def coreTop = file(prefixFile)
1878 def coreBottom = file(suffixFile)
1879 coreFile.getParentFile().mkdirs()
1880 coreFile.createNewFile()
1881 coreFile.write( coreTop.text )
1886 t.replaceAll("Clazz\\.([^_])","Clazz_${1}")
1887 coreFile.append( t )
1889 msg = "...file '"+f.getPath()+"' does not exist, skipping"
1891 logOutFile.append(msg+"\n")
1894 coreFile.append( coreBottom.text )
1896 msg = "Generating ${zjsfile}"
1898 logOutFile.append(msg+"\n")
1899 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1900 def logErrFOS = logOutFOS
1903 classpath = files(["${jalviewDir}/tools/closure_compiler.jar"])
1904 args = [ "--js", jsfile, "--js_output_file", zjsfile ]
1907 msg = "\nRunning '"+commandLine.join(' ')+"'\n"
1909 logOutFile.append(msg+"\n")
1911 if (logOutConsole) {
1912 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1913 new org.apache.tools.ant.util.TeeOutputStream(
1917 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1918 new org.apache.tools.ant.util.TeeOutputStream(
1923 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1926 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1933 logOutFile.append(msg+"\n")
1937 task jalviewjsBuildAllCores {
1939 description "Build the core js lib closures listed in the classlists dir"
1940 dependsOn jalviewjsTranspile
1941 dependsOn jalviewjsTransferUnzipSwingJs
1943 def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}"
1944 def swingJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_j2s_subdir}"
1945 def libJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${jalviewjs_j2s_subdir}"
1946 def jsDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_js_subdir}"
1947 def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core"
1948 def prefixFile = "${jsDir}/core/coretop2.js"
1949 def suffixFile = "${jsDir}/core/corebottom2.js"
1951 inputs.file prefixFile
1952 inputs.file suffixFile
1954 def classlistFiles = []
1955 // add the classlists found int the jalviewjs_classlists_dir
1956 fileTree(dir: "${jalviewDir}/${jalviewjs_classlists_dir}", include: "*.txt").each {
1958 def name = file.getName() - ".txt"
1965 // _jmol and _jalview cores. Add any other peculiar classlist.txt files here
1966 //classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jmol}"), 'name': "_jvjmol" ]
1967 classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jalview}"), 'name': jalviewjsJalviewCoreName ]
1969 jalviewjsCoreClasslists = []
1971 classlistFiles.each {
1974 def file = hash['file']
1975 if (! file.exists()) {
1976 println("...classlist file '"+file.getPath()+"' does not exist, skipping")
1977 return false // this is a "continue" in groovy .each closure
1979 def name = hash['name']
1981 name = file.getName() - ".txt"
1989 def list = fileTree(dir: j2sDir, includes: filelist)
1991 def jsfile = "${outputDir}/core${name}.js"
1992 def zjsfile = "${outputDir}/core${name}.z.js"
1994 jalviewjsCoreClasslists += [
2003 outputs.file(jsfile)
2004 outputs.file(zjsfile)
2007 // _stevesoft core. add any cores without a classlist here (and the inputs and outputs)
2008 def stevesoftClasslistName = "_stevesoft"
2009 def stevesoftClasslist = [
2010 'jsfile': "${outputDir}/core${stevesoftClasslistName}.js",
2011 'zjsfile': "${outputDir}/core${stevesoftClasslistName}.z.js",
2012 'list': fileTree(dir: j2sDir, include: "com/stevesoft/pat/**/*.js"),
2013 'name': stevesoftClasslistName
2015 jalviewjsCoreClasslists += stevesoftClasslist
2016 inputs.files(stevesoftClasslist['list'])
2017 outputs.file(stevesoftClasslist['jsfile'])
2018 outputs.file(stevesoftClasslist['zjsfile'])
2021 def allClasslistName = "_all"
2022 def allJsFiles = fileTree(dir: j2sDir, include: "**/*.js")
2023 allJsFiles += fileTree(
2027 // these exlusions are files that the closure-compiler produces errors for. Should fix them
2028 "**/org/jmol/jvxl/readers/IsoIntersectFileReader.js",
2029 "**/org/jmol/export/JSExporter.js"
2032 allJsFiles += fileTree(
2036 // these exlusions are files that the closure-compiler produces errors for. Should fix them
2037 "**/sun/misc/Unsafe.js",
2038 "**/swingjs/jquery/jquery-editable-select.js",
2039 "**/swingjs/jquery/j2sComboBox.js",
2040 "**/sun/misc/FloatingDecimal.js"
2043 def allClasslist = [
2044 'jsfile': "${outputDir}/core${allClasslistName}.js",
2045 'zjsfile': "${outputDir}/core${allClasslistName}.z.js",
2047 'name': allClasslistName
2049 jalviewjsCoreClasslists += allClasslist
2050 inputs.files(allClasslist['list'])
2051 outputs.file(allClasslist['jsfile'])
2052 outputs.file(allClasslist['zjsfile'])
2055 def logOutFile = file("${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_closure_stdout}")
2056 logOutFile.getParentFile().mkdirs()
2057 logOutFile.createNewFile()
2058 logOutFile.write(getDate("yyyy-MM-dd HH:mm:ss")+" jalviewjsBuildAllCores\n----\n")
2060 jalviewjsCoreClasslists.each {
2061 jalviewjsCallCore(it.name, it.list, prefixFile, suffixFile, it.jsfile, it.zjsfile, logOutFile, jalviewjs_j2s_to_console.equals("true"))
2068 def jalviewjsPublishCoreTemplate(String coreName, String templateName, File inputFile, String outputFile) {
2071 into file(outputFile).getParentFile()
2072 rename { filename ->
2073 if (filename.equals(inputFile.getName())) {
2074 return file(outputFile).getName()
2078 filter(ReplaceTokens,
2082 'MAIN': '"'+mainClass+'"',
2084 'NAME': jalviewjsJalviewTemplateName+" [core ${coreName}]",
2085 'COREKEY': jalviewjs_core_key,
2086 'CORENAME': coreName
2093 task jalviewjsPublishCoreTemplates {
2094 dependsOn jalviewjsBuildAllCores
2095 def inputFileName = "${jalviewDir}/${j2s_coretemplate_html}"
2096 def inputFile = file(inputFileName)
2097 def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2099 def outputFiles = []
2100 jalviewjsCoreClasslists.each { cl ->
2101 def outputFile = "${outputDir}/${jalviewjsJalviewTemplateName}_${cl.name}.html"
2102 cl['outputfile'] = outputFile
2103 outputFiles += outputFile
2107 jalviewjsCoreClasslists.each { cl ->
2108 jalviewjsPublishCoreTemplate(cl.name, jalviewjsJalviewTemplateName, inputFile, cl.outputfile)
2111 inputs.file(inputFile)
2112 outputs.files(outputFiles)
2116 task jalviewjsSyncCore (type: Sync) {
2117 dependsOn jalviewjsBuildAllCores
2118 dependsOn jalviewjsPublishCoreTemplates
2119 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
2120 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2124 def outputFiles = []
2125 rename { filename ->
2126 outputFiles += "${outputDir}/${filename}"
2132 outputs.files outputFiles
2133 inputs.files inputFiles
2137 // this Copy version of TransferSiteJs will delete anything else in the target dir
2138 task jalviewjsCopyTransferSiteJs(type: Copy) {
2139 dependsOn jalviewjsTranspile
2140 from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2141 into "${jalviewDir}/${jalviewjsSiteDir}"
2145 // this Sync version of TransferSite is used by buildship to keep the website automatically up to date when a file changes
2146 task jalviewjsSyncTransferSiteJs(type: Sync) {
2147 from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2149 into "${jalviewDir}/${jalviewjsSiteDir}"
2156 jalviewjsSyncAllLibs.mustRunAfter jalviewjsCopyTransferSiteJs
2157 jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSiteJs
2158 jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSiteJs
2159 jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSiteJs
2161 jalviewjsSyncAllLibs.mustRunAfter jalviewjsSyncTransferSiteJs
2162 jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSiteJs
2163 jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSiteJs
2164 jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSiteJs
2167 task jalviewjsPrepareSite {
2169 description "Prepares the website folder including unzipping files and copying resources"
2170 dependsOn jalviewjsSyncAllLibs
2171 dependsOn jalviewjsSyncResources
2172 dependsOn jalviewjsSyncSiteResources
2173 dependsOn jalviewjsSyncBuildProperties
2174 dependsOn jalviewjsSyncCore
2178 task jalviewjsBuildSite {
2180 description "Builds the whole website including transpiled code"
2181 dependsOn jalviewjsCopyTransferSiteJs
2182 dependsOn jalviewjsPrepareSite
2186 task cleanJalviewjsSite {
2188 delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2189 delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2190 delete "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2191 delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2192 delete "${jalviewDir}/${jalviewjsSiteDir}"
2197 task jalviewjsSiteTar(type: Tar) {
2199 description "Creates a tar.gz file for the website"
2200 dependsOn jalviewjsBuildSite
2201 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
2203 archiveFileName = outputFilename
2204 } catch (Exception e) {
2205 archiveName = outputFilename
2208 compression Compression.GZIP
2210 from "${jalviewDir}/${jalviewjsSiteDir}"
2211 into jalviewjs_site_dir // this is inside the tar file
2213 inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
2217 task jalviewjsServer {
2219 def filename = "jalviewjsTest.html"
2220 description "Starts a webserver on localhost to test the website. See ${filename} to access local site on most recently used port."
2221 def htmlFile = "${jalviewDirAbsolutePath}/${filename}"
2224 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
2225 def port = Integer.valueOf(jalviewjs_server_port)
2230 while(port < start+1000 && !running) {
2232 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
2233 jalviewjsServer = factory.start(doc_root, port)
2235 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
2236 println("SERVER STARTED with document root ${doc_root}.")
2237 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
2238 println("For debug: "+url+"?j2sdebug")
2239 println("For verbose: "+url+"?j2sverbose")
2240 } catch (Exception e) {
2245 <p><a href="${url}">JalviewJS Test. <${url}></a></p>
2246 <p><a href="${url}?j2sdebug">JalviewJS Test with debug. <${url}?j2sdebug></a></p>
2247 <p><a href="${url}?j2sverbose">JalviewJS Test with verbose. <${url}?j2sdebug></a></p>
2249 jalviewjsCoreClasslists.each { cl ->
2250 def urlcore = jalviewjsServer.getResourceUrl(file(cl.outputfile).getName())
2252 <p><a href="${urlcore}">${jalviewjsJalviewTemplateName} [core ${cl.name}]. <${urlcore}></a></p>
2254 println("For core ${cl.name}: "+urlcore)
2257 file(htmlFile).text = htmlText
2260 outputs.file(htmlFile)
2261 outputs.upToDateWhen({false})
2265 task cleanJalviewjsAll {
2267 description "Delete all configuration and build artifacts to do with JalviewJS build"
2268 dependsOn cleanJalviewjsSite
2269 dependsOn jalviewjsEclipsePaths
2272 delete "${jalviewDir}/${jalviewjsBuildDir}"
2273 delete "${jalviewDir}/${eclipse_bin_dir}"
2274 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
2275 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
2277 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
2280 outputs.upToDateWhen( { false } )
2284 task jalviewjsIDE_checkJ2sPlugin {
2285 group "00 JalviewJS in Eclipse"
2286 description "Compare the swingjs/net.sf.j2s.core.jar file with the Eclipse IDE's plugin version (found in the 'dropins' dir)"
2289 def j2sPlugin = string("${jalviewDir}/${jalviewjs_j2s_plugin}")
2290 def j2sPluginFile = file(j2sPlugin)
2291 def copyPlugin = jalviewjs_eclipseIDE_auto_copy_j2s_plugin == "true"
2292 def eclipseHome = System.properties["eclipse.home.location"]
2294 if (eclipseHome == null || ! IN_ECLIPSE) {
2295 throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.")
2297 def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}"
2298 def eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
2299 if (!eclipseJ2sPluginFile.exists()) {
2300 def msg = "Eclipse J2S Plugin is not installed"
2303 throw new GradleException(msg)
2308 def digest = MessageDigest.getInstance("MD5")
2310 digest.update(j2sPluginFile.text.bytes)
2311 def j2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2313 digest.update(eclipseJ2sPluginFile.text.bytes)
2314 def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2316 if (j2sPluginMd5 != eclipseJ2sPluginMd5) {
2317 def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'"
2320 throw new StopExecutionException(msg)
2326 def msg = "WARNING! Auto-copying this commit's j2s plugin version '${j2sPlugin}' to Eclipse J2S Plugin '${eclipseJ2sPlugin}'\n May require an Eclipse restart"
2330 eclipseJ2sPluginFile.getParentFile().mkdirs()
2331 into eclipseJ2sPluginFile.getParent()
2334 def msg = "Eclipse J2S Plugin is the same as '${j2sPlugin}'"
2341 task jalviewjsIDE_j2sFile {
2342 group "00 JalviewJS in Eclipse"
2343 description "Creates the .j2s file"
2344 dependsOn jalviewjsCreateJ2sSettings
2348 task jalviewjsIDE_SyncCore {
2349 group "00 JalviewJS in Eclipse"
2350 description "Build the core js lib closures listed in the classlists dir and publish core html from template"
2351 dependsOn jalviewjsSyncCore
2355 task jalviewjsIDE_PrepareSite {
2356 group "00 JalviewJS in Eclipse"
2357 description "Sync libs and resources to site dir, but not closure cores"
2358 dependsOn jalviewjsSyncAllLibs
2359 dependsOn jalviewjsSyncResources
2360 dependsOn jalviewjsSyncSiteResources
2361 dependsOn jalviewjsSyncBuildProperties
2365 task jalviewjsIDE_AssembleSite {
2366 group "00 JalviewJS in Eclipse"
2367 description "Assembles unzipped supporting zipfiles, resources, site resources and closure cores into the Eclipse transpiled site"
2368 dependsOn jalviewjsPrepareSite
2372 task jalviewjsIDE_SiteClean {
2373 group "00 JalviewJS in Eclipse"
2374 description "Deletes the Eclipse transpiled site"
2375 dependsOn cleanJalviewjsSite
2379 task jalviewjsIDE_Server {
2380 group "00 JalviewJS in Eclipse"
2381 description "Starts a webserver on localhost to test the website"
2382 dependsOn jalviewjsServer
2386 // buildship runs this at import or gradle refresh
2387 task eclipseSynchronizationTask {
2388 //dependsOn eclipseSetup
2389 dependsOn createBuildProperties
2391 dependsOn jalviewjsIDE_j2sFile
2392 dependsOn jalviewjsIDE_checkJ2sPlugin
2393 dependsOn jalviewjsIDE_PrepareSite
2398 // buildship runs this at build time or project refresh
2399 task eclipseAutoBuildTask {
2400 //dependsOn jalviewjsIDE_checkJ2sPlugin
2401 //dependsOn jalviewjsIDE_PrepareSite
2413 description "Build the site"
2414 dependsOn jalviewjsBuildSite