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 = string("${resourceDir}/${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("${resourceDir}/${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("${resourceDir}/${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}/${resource_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}/${resource_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("${resourceDir}/${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("${resourceDir}/${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("${resourceDir}/${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("${resourceDir}/${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]")
222 getdownAppDir = string("${getdownWebsiteDir}/${getdown_app_dir}")
223 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
224 getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
225 getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
226 getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
227 getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
228 /* compile without modules -- using classpath libraries
229 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
230 modules_runtimeClasspath = modules_compileClasspath
233 gitBranch = string("")
235 println("Using a ${CHANNEL} profile.")
237 additional_compiler_args = []
238 // configure classpath/args for j8/j11 compilation
239 if (JAVA_VERSION.equals("1.8")) {
240 JAVA_INTEGER_VERSION = string("8")
243 libDistDir = j8libDir
244 compile_source_compatibility = 1.8
245 compile_target_compatibility = 1.8
246 // these are getdown.txt properties defined dependent on the JAVA_VERSION
247 getdown_alt_java_min_version = getdown_alt_java8_min_version
248 getdown_alt_java_max_version = getdown_alt_java8_max_version
249 // this property is assigned below and expanded to multiple lines in the getdown task
250 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
251 // this property is for the Java library used in eclipse
252 eclipse_java_runtime_name = string("JavaSE-1.8")
253 } else if (JAVA_VERSION.equals("11")) {
254 JAVA_INTEGER_VERSION = string("11")
256 libDistDir = j11libDir
257 compile_source_compatibility = 11
258 compile_target_compatibility = 11
259 getdown_alt_java_min_version = getdown_alt_java11_min_version
260 getdown_alt_java_max_version = getdown_alt_java11_max_version
261 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
262 eclipse_java_runtime_name = string("JavaSE-11")
263 /* compile without modules -- using classpath libraries
264 additional_compiler_args += [
265 '--module-path', modules_compileClasspath.asPath,
266 '--add-modules', j11modules
269 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
270 JAVA_INTEGER_VERSION = JAVA_VERSION
272 libDistDir = j11libDir
273 compile_source_compatibility = JAVA_VERSION
274 compile_target_compatibility = JAVA_VERSION
275 getdown_alt_java_min_version = getdown_alt_java11_min_version
276 getdown_alt_java_max_version = getdown_alt_java11_max_version
277 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
278 eclipse_java_runtime_name = string("JavaSE-11")
279 /* compile without modules -- using classpath libraries
280 additional_compiler_args += [
281 '--module-path', modules_compileClasspath.asPath,
282 '--add-modules', j11modules
286 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
291 macosJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre")
292 macosJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz")
293 windowsJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre")
294 windowsJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz")
295 install4jDir = string("${jalviewDir}/${install4jResourceDir}")
296 install4jConfFileName = string("jalview-installers-java${JAVA_VERSION}.install4j")
297 install4jConfFile = string("${install4jDir}/${install4jConfFileName}")
300 buildingHTML = string("${jalviewDir}/${docDir}/building.html")
301 helpFile = string("${classesDir}/${help_dir}/help.jhm")
302 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
303 helpDir = string("${help_dir}")
304 helpSourceDir = string("${helpParentDir}/${helpDir}")
307 relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
308 jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
309 jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
311 jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
313 jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
315 jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
316 jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
317 jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
318 jalviewjsJalviewCoreHtmlFile = string("")
319 jalviewjsJalviewCoreName = string(jalviewjs_core_name)
320 jalviewjsCoreClasslists = []
321 jalviewjsJalviewTemplateName = string(jalviewjs_name)
322 jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
323 jalviewjsJ2sProps = null
325 eclipseWorkspace = null
326 eclipseBinary = string("")
327 eclipseVersion = string("")
337 outputDir = file(classesDir)
344 jar.destinationDir = file("${jalviewDir}/${packageDir}")
346 compileClasspath = files(sourceSets.main.java.outputDir)
347 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
349 runtimeClasspath = compileClasspath
354 srcDirs = [ cloverInstrDir ]
355 outputDir = file("${buildDir}/${cloverClassesDir}")
359 srcDirs = sourceSets.main.resources.srcDirs
361 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
362 compileClasspath += files(sourceSets.main.java.outputDir)
363 compileClasspath += sourceSets.main.compileClasspath
364 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
365 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
367 runtimeClasspath = compileClasspath
372 srcDirs testSourceDir
373 outputDir = file("${jalviewDir}/${testOutputDir}")
377 srcDirs = sourceSets.main.resources.srcDirs
380 compileClasspath = files( sourceSets.test.java.outputDir )
383 compileClasspath += sourceSets.clover.compileClasspath
385 compileClasspath += files(sourceSets.main.java.outputDir)
388 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
389 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
390 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
392 runtimeClasspath = compileClasspath
400 cloverCompile 'org.openclover:clover:4.3.1'
401 testCompile 'org.openclover:clover:4.3.1'
408 cloverRuntime.extendsFrom cloverCompile
413 name = eclipse_project_name
415 natures 'org.eclipse.jdt.core.javanature',
416 'org.eclipse.jdt.groovy.core.groovyNature',
417 'org.eclipse.buildship.core.gradleprojectnature'
419 buildCommand 'org.eclipse.jdt.core.javabuilder'
420 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
424 //defaultOutputDir = sourceSets.main.java.outputDir
427 if (it.isCanBeResolved()) {
432 minusConfigurations += removeThese
433 plusConfigurations = [ ]
437 def removeTheseToo = []
438 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
439 cp.entries.each { entry ->
440 // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
441 // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
442 // we add the resources and help/help dirs in as libs afterwards (see below)
443 if (entry.kind == 'src') {
444 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
445 removeTheseToo += entry
447 alreadyAddedSrcPath.putAt(entry.path, true)
452 cp.entries.removeAll(removeTheseToo)
454 cp.entries += new Output("${eclipse_bin_dir}/main")
455 if (file(helpSourceDir).isDirectory()) {
456 cp.entries += new Library(fileReference(helpSourceDir))
458 if (file(resourceDir).isDirectory()) {
459 cp.entries += new Library(fileReference(resourceDir))
462 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
464 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
465 //don't want to add outputDir as eclipse is using its own output dir in bin/main
466 if (it.isDirectory() || ! it.exists()) {
467 // don't add dirs to classpath, especially if they don't exist
468 return false // groovy "continue" in .any closure
470 def itPath = it.toString()
471 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
472 // make relative path
473 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
475 if (alreadyAddedLibPath.get(itPath)) {
476 //println("Not adding duplicate entry "+itPath)
478 //println("Adding entry "+itPath)
479 cp.entries += new Library(fileReference(itPath))
480 alreadyAddedLibPath.put(itPath, true)
484 //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
485 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
486 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
487 if (it.isDirectory() || ! it.exists()) {
488 // don't add dirs to classpath
489 return false // groovy "continue" in .any closure
492 def itPath = it.toString()
493 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
494 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
496 if (alreadyAddedLibPath.get(itPath)) {
499 def lib = new Library(fileReference(itPath))
500 lib.entryAttributes["test"] = "true"
502 alreadyAddedLibPath.put(itPath, true)
510 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
515 // for the IDE, use java 11 compatibility
516 sourceCompatibility = compile_source_compatibility
517 targetCompatibility = compile_target_compatibility
518 javaRuntimeName = eclipse_java_runtime_name
520 // add in jalview project specific properties/preferences into eclipse core preferences
522 withProperties { props ->
523 def jalview_prefs = new Properties()
524 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
525 jalview_prefs.load(ins)
527 jalview_prefs.forEach { t, v ->
528 if (props.getAt(t) == null) {
538 // Don't want these to be activated if in headless build
539 synchronizationTasks "eclipseSynchronizationTask"
540 //autoBuildTasks "eclipseAutoBuildTask"
547 // only instrument source, we build test classes as normal
548 inputs.files files (sourceSets.main.allJava) // , fileTree(dir: testSourceDir, include: ["**/*.java"]))
549 outputs.dir cloverInstrDir
552 delete cloverInstrDir
553 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
554 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
555 argsList.addAll(inputs.files.files.collect({ file ->
558 String[] args = argsList.toArray()
559 println("About to instrument "+args.length +" files")
560 com.atlassian.clover.CloverInstr.mainImpl(args)
566 group = "Verification"
567 description = "Createst the Clover report"
568 inputs.dir "${buildDir}/clover"
569 outputs.dir "${reportsDir}/clover"
571 file("${buildDir}/clover/clover.db").exists()
574 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
575 "-o", "${reportsDir}/clover"]
576 String[] args = argsList.toArray()
577 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
579 // and generate ${reportsDir}/clover/clover.xml
580 args = ["--initstring", "${buildDir}/clover/clover.db",
581 "-o", "${reportsDir}/clover/clover.xml"].toArray()
582 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
591 sourceCompatibility = compile_source_compatibility
592 targetCompatibility = compile_target_compatibility
593 options.compilerArgs = additional_compiler_args
594 print ("Setting target compatibility to "+targetCompatibility+"\n")
602 dependsOn compileCloverJava
603 classpath += configurations.cloverRuntime
605 classpath += sourceSets.main.runtimeClasspath
608 sourceCompatibility = compile_source_compatibility
609 targetCompatibility = compile_target_compatibility
610 options.compilerArgs = additional_compiler_args
611 print ("Setting target compatibility to "+targetCompatibility+"\n")
619 sourceCompatibility = compile_source_compatibility
620 targetCompatibility = compile_target_compatibility
621 options.compilerArgs += additional_compiler_args
622 print ("Setting target compatibility to "+targetCompatibility+"\n")
624 classpath += configurations.cloverRuntime
630 delete sourceSets.main.java.outputDir
637 delete sourceSets.test.java.outputDir
638 delete cloverInstrDir
643 // format is a string like date.format("dd MMMM yyyy")
644 def getDate(format) {
645 def date = new Date()
646 return date.format(format)
651 def hashStdOut = new ByteArrayOutputStream()
653 commandLine "git", "rev-parse", "--short", "HEAD"
654 standardOutput = hashStdOut
658 def branchStdOut = new ByteArrayOutputStream()
660 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
661 standardOutput = branchStdOut
665 gitHash = hashStdOut.toString().trim()
666 gitBranch = branchStdOut.toString().trim()
668 outputs.upToDateWhen { false }
672 task createBuildProperties(type: WriteProperties) {
674 description = "Create the ${buildProperties} file"
676 inputs.dir(sourceDir)
677 inputs.dir(resourceDir)
678 file(buildProperties).getParentFile().mkdirs()
679 outputFile (buildProperties)
680 // taking time specific comment out to allow better incremental builds
681 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
682 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
683 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
684 property "VERSION", JALVIEW_VERSION
685 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
686 outputs.file(outputFile)
692 delete buildProperties
697 task cleanBuildingHTML(type: Delete) {
704 task convertBuildingMD(type: Exec) {
705 dependsOn cleanBuildingHTML
706 def buildingMD = "${jalviewDir}/${docDir}/building.md"
707 def css = "${jalviewDir}/${docDir}/github.css"
710 pandoc_exec.split(",").each {
711 if (file(it.trim()).exists()) {
717 def hostname = "hostname".execute().text.trim()
718 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
719 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
723 if (pandoc != null && file(pandoc).exists()) {
724 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
726 println("Cannot find pandoc. Skipping convert building.md to HTML")
727 throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
733 inputs.file(buildingMD)
735 outputs.file(buildingHTML)
746 task syncDocs(type: Sync) {
747 dependsOn convertBuildingMD
748 def syncDir = "${classesDir}/${docDir}"
749 from fileTree("${jalviewDir}/${docDir}")
755 task copyHelp(type: Copy) {
756 def inputDir = helpSourceDir
757 def outputDir = "${classesDir}/${helpDir}"
762 filter(ReplaceTokens,
766 'Version-Rel': JALVIEW_VERSION,
767 'Year-Rel': getDate("yyyy")
779 outputs.files(helpFile)
780 outputs.dir(outputDir)
784 task syncLib(type: Sync) {
785 def syncDir = "${classesDir}/${libDistDir}"
786 from fileTree("${jalviewDir}/${libDistDir}")
791 task syncResources(type: Sync) {
792 dependsOn createBuildProperties
803 dependsOn syncResources
809 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
812 dependsOn compileJava
814 dependsOn cloverInstr
818 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
822 includeGroups testngGroups
824 useDefaultListeners=true
827 workingDir = jalviewDir
828 //systemProperties 'clover.jar' System.properties.clover.jar
829 sourceCompatibility = compile_source_compatibility
830 targetCompatibility = compile_target_compatibility
831 jvmArgs += additional_compiler_args
836 task buildIndices(type: JavaExec) {
838 classpath = sourceSets.main.compileClasspath
839 main = "com.sun.java.help.search.Indexer"
840 workingDir = "${classesDir}/${helpDir}"
843 inputs.dir("${workingDir}/${argDir}")
845 outputs.dir("${classesDir}/doc")
846 outputs.dir("${classesDir}/help")
847 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
848 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
849 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
850 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
851 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
852 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
856 task compileLinkCheck(type: JavaCompile) {
858 classpath = files("${jalviewDir}/${utilsDir}")
859 destinationDir = file("${jalviewDir}/${utilsDir}")
860 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
862 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
863 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
864 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
865 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
869 task linkCheck(type: JavaExec) {
870 dependsOn prepare, compileLinkCheck
872 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
873 classpath = files("${jalviewDir}/${utilsDir}")
874 main = "HelpLinksChecker"
875 workingDir = jalviewDir
876 def help = "${classesDir}/${helpDir}"
877 args = [ "${classesDir}/${helpDir}", "-nointernet" ]
879 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
881 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
884 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
888 inputs.dir("${classesDir}/${helpDir}")
889 outputs.file(helpLinksCheckerOutFile)
892 // import the pubhtmlhelp target
893 ant.properties.basedir = "${jalviewDir}"
894 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${helpDir}"
895 ant.importBuild "${utilsDir}/publishHelp.xml"
898 task cleanPackageDir(type: Delete) {
900 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
907 dependsOn buildIndices
908 dependsOn createBuildProperties
911 attributes "Main-Class": mainClass,
912 "Permissions": "all-permissions",
913 "Application-Name": "Jalview Desktop",
914 "Codebase": application_codebase
917 destinationDir = file("${jalviewDir}/${packageDir}")
918 archiveName = rootProject.name+".jar"
926 inputs.dir(classesDir)
927 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
931 task copyJars(type: Copy) {
932 from fileTree(dir: classesDir, include: "**/*.jar").files
933 into "${jalviewDir}/${packageDir}"
937 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
938 task syncJars(type: Sync) {
939 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
940 into "${jalviewDir}/${packageDir}"
942 include jar.archiveName
949 description = "Put all required libraries in dist"
950 // order of "cleanPackageDir", "copyJars", "jar" important!
951 jar.mustRunAfter cleanPackageDir
952 syncJars.mustRunAfter cleanPackageDir
953 dependsOn cleanPackageDir
956 outputs.dir("${jalviewDir}/${packageDir}")
961 dependsOn cleanPackageDir
967 group = "distribution"
971 from ("${jalviewDir}/${libDistDir}") {
975 attributes 'Implementation-Version': JALVIEW_VERSION
977 mainClassName = shadowJarMainClass
979 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
984 task getdownWebsite() {
985 group = "distribution"
986 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
991 def getdownWebsiteResourceFilenames = []
992 def getdownTextString = ""
993 def getdownResourceDir = getdownResourceDir
994 def getdownAppDir = getdownAppDir
995 def getdownResourceFilenames = []
998 // clean the getdown website and files dir before creating getdown folders
999 delete getdownWebsiteDir
1000 delete getdownFilesDir
1003 from buildProperties
1004 rename(build_properties_file, getdown_build_properties)
1007 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
1009 // go through properties looking for getdown_txt_...
1010 def props = project.properties.sort { it.key }
1011 if (getdown_alt_java_min_version.length() > 0) {
1012 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
1014 if (getdown_alt_java_max_version.length() > 0) {
1015 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
1017 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
1019 props.put("getdown_txt_appbase", getdown_app_base)
1020 props.each{ prop, val ->
1021 if (prop.startsWith("getdown_txt_") && val != null) {
1022 if (prop.startsWith("getdown_txt_multi_")) {
1023 def key = prop.substring(18)
1024 val.split(",").each{ v ->
1025 def line = "${key} = ${v}\n"
1026 getdownTextString += line
1029 // file values rationalised
1030 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1032 if (val.indexOf('/') == 0) {
1035 } else if (val.indexOf('/') > 0) {
1036 // relative path (relative to jalviewDir)
1037 r = file( "${jalviewDir}/${val}" )
1040 val = "${getdown_resource_dir}/" + r.getName()
1041 getdownWebsiteResourceFilenames += val
1042 getdownResourceFilenames += r.getPath()
1045 if (! prop.startsWith("getdown_txt_resource")) {
1046 def line = prop.substring(12) + " = ${val}\n"
1047 getdownTextString += line
1053 getdownWebsiteResourceFilenames.each{ filename ->
1054 getdownTextString += "resource = ${filename}\n"
1056 getdownResourceFilenames.each{ filename ->
1059 into getdownResourceDir
1064 fileTree(file(packageDir)).each{ f ->
1065 if (f.isDirectory()) {
1066 def files = fileTree(dir: f, include: ["*"]).getFiles()
1068 } else if (f.exists()) {
1072 codeFiles.sort().each{f ->
1073 def name = f.getName()
1074 def line = "code = ${getdown_app_dir}/${name}\n"
1075 getdownTextString += line
1082 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1084 if (JAVA_VERSION.equals("11")) {
1085 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1086 j11libFiles.sort().each{f ->
1087 def name = f.getName()
1088 def line = "code = ${getdown_j11lib_dir}/${name}\n"
1089 getdownTextString += line
1092 into getdownJ11libDir
1098 // 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.
1099 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1100 getdownTextString += "resource = ${getdown_launcher_new}\n"
1101 getdownTextString += "class = ${mainClass}\n"
1103 def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1104 getdown_txt.write(getdownTextString)
1106 def launch_jvl = file("${getdownWebsiteDir}/${getdown_launch_jvl}")
1107 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
1110 from getdownLauncher
1111 rename(file(getdownLauncher).getName(), getdown_launcher_new)
1112 into getdownWebsiteDir
1116 from getdownLauncher
1117 if (file(getdownLauncher).getName() != getdown_launcher) {
1118 rename(file(getdownLauncher).getName(), getdown_launcher)
1120 into getdownWebsiteDir
1123 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1126 from getdownLauncher
1127 from "${getdownWebsiteDir}/${getdown_build_properties}"
1128 if (file(getdownLauncher).getName() != getdown_launcher) {
1129 rename(file(getdownLauncher).getName(), getdown_launcher)
1131 into getdownInstallDir
1135 from getdownInstallDir
1136 into getdownFilesInstallDir
1143 from getdownLauncher
1144 from "${getdownWebsiteDir}/${getdown_build_properties}"
1145 if (file(getdownLauncher).getName() != getdown_launcher) {
1146 rename(file(getdownLauncher).getName(), getdown_launcher)
1148 into getdownFilesDir
1152 from getdownResourceDir
1153 into "${getdownFilesDir}/${getdown_resource_dir}"
1158 inputs.dir("${jalviewDir}/${packageDir}")
1160 outputs.dir(getdownWebsiteDir)
1161 outputs.dir(getdownFilesDir)
1165 task getdownDigest(type: JavaExec) {
1166 group = "distribution"
1167 description = "Digest the getdown website folder"
1168 dependsOn getdownWebsite
1170 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1172 main = "com.threerings.getdown.tools.Digester"
1173 args getdownWebsiteDir
1174 inputs.dir(getdownWebsiteDir)
1175 outputs.file("${getdownWebsiteDir}/digest2.txt")
1180 group = "distribution"
1181 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1182 dependsOn getdownDigest
1184 if (reportRsyncCommand) {
1185 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1186 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1187 println "LIKELY RSYNC COMMAND:"
1188 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1189 if (RUNRSYNC == "true") {
1191 commandLine "mkdir", "-p", toDir
1194 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1204 delete getdownWebsiteDir
1205 delete getdownFilesDir
1211 def install4jHomeDir = "/opt/install4j"
1212 def hostname = "hostname".execute().text.trim()
1213 if (hostname.equals("jv-bamboo")) {
1214 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1215 } else if (OperatingSystem.current().isMacOsX()) {
1216 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1217 if (! file(install4jHomeDir).exists()) {
1218 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1220 } else if (OperatingSystem.current().isLinux()) {
1221 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1223 installDir = file(install4jHomeDir)
1224 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1225 if (install4jFaster.equals("true")) {
1231 task copyInstall4jTemplate(type: Copy) {
1232 from (install4jDir) {
1233 include install4jTemplate
1234 rename (install4jTemplate, install4jConfFileName)
1235 filter(ReplaceTokens,
1239 '9999999999': JAVA_VERSION
1242 filter(ReplaceTokens,
1246 'JAVA_VERSION': JAVA_VERSION,
1247 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1248 'VERSION': JALVIEW_VERSION,
1249 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1250 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1251 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1252 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1253 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1254 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1255 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1256 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1257 'GETDOWN_DIST_DIR': getdown_app_dir,
1258 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1259 'GETDOWN_INSTALL_DIR': getdown_install_dir
1262 if (OSX_KEYPASS == "") {
1263 filter(ReplaceTokens,
1264 beginToken: 'codeSigning macEnabled="',
1267 'true': 'codeSigning macEnabled="false"'
1270 filter(ReplaceTokens,
1271 beginToken: 'runPostProcessor="true" ',
1272 endToken: 'Processor',
1274 'post': 'runPostProcessor="false" postProcessor'
1280 outputs.files(install4jConfFile)
1283 // include file associations in installer
1284 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1288 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1289 replace: installerFileAssociationsXml,
1290 file: install4jConfFile
1293 // include uninstaller applescript app files in dmg
1294 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1298 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1299 replace: installerDMGUninstallerXml,
1300 file: install4jConfFile
1309 delete install4jConfFile
1314 task installers(type: com.install4j.gradle.Install4jTask) {
1315 group = "distribution"
1316 description = "Create the install4j installers"
1318 dependsOn copyInstall4jTemplate
1319 projectFile = file(install4jConfFile)
1320 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1321 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1322 buildSelected = true
1325 macKeystorePassword=OSX_KEYPASS
1329 println("Using projectFile "+projectFile)
1332 inputs.dir(getdownWebsiteDir)
1333 inputs.file(install4jConfFile)
1334 inputs.dir(macosJavaVMDir)
1335 inputs.dir(windowsJavaVMDir)
1336 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1340 task sourceDist (type: Tar) {
1342 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1343 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1344 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1346 archiveFileName = outputFileName
1347 } catch (Exception e) {
1348 archiveName = outputFileName
1351 compression Compression.GZIP
1355 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1360 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1362 ,"utils/InstallAnywhere"]
1363 def PROCESS_FILES=[ "AUTHORS",
1371 "THIRDPARTYLIBS","TESTNG",
1373 "gradle.properties",
1384 exclude (EXCLUDE_FILES)
1385 include (PROCESS_FILES)
1386 filter(ReplaceTokens,
1390 'Version-Rel': JALVIEW_VERSION,
1391 'Year-Rel': getDate("yyyy")
1396 exclude (EXCLUDE_FILES)
1397 exclude (PROCESS_FILES)
1398 exclude ("appletlib")
1399 exclude ("**/*locales")
1400 exclude ("*locales/**")
1401 exclude ("utils/InstallAnywhere")
1403 exclude (getdown_files_dir)
1404 exclude (getdown_website_dir)
1406 // exluding these as not using jars as modules yet
1407 exclude ("${j11modDir}/**/*.jar")
1409 // from (jalviewDir) {
1410 // // explicit includes for stuff that seemed to not get included
1411 // include(fileTree("test/**/*."))
1412 // exclude(EXCLUDE_FILES)
1413 // exclude(PROCESS_FILES)
1420 dependsOn pubhtmlhelp
1422 inputs.dir("${classesDir}/${helpDir}")
1423 outputs.dir("${buildDir}/distributions/${helpDir}")
1427 task j2sSetHeadlessBuild {
1434 task jalviewjsSetEclipseWorkspace {
1435 def propKey = "jalviewjs_eclipse_workspace"
1437 if (project.hasProperty(propKey)) {
1438 propVal = project.getProperty(propKey)
1439 if (propVal.startsWith("~/")) {
1440 propVal = System.getProperty("user.home") + propVal.substring(1)
1443 def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1444 def propsFile = file(propsFileName)
1445 def eclipseWsDir = propVal
1446 def props = new Properties()
1448 def writeProps = true
1449 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
1450 def ins = new FileInputStream(propsFileName)
1453 if (props.getProperty(propKey, null) != null) {
1454 eclipseWsDir = props.getProperty(propKey)
1459 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1460 def tempDir = File.createTempDir()
1461 eclipseWsDir = tempDir.getAbsolutePath()
1464 eclipseWorkspace = file(eclipseWsDir)
1467 // do not run a headless transpile when we claim to be in Eclipse
1469 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1470 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1472 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1476 props.setProperty(propKey, eclipseWsDir)
1477 propsFile.parentFile.mkdirs()
1478 def bytes = new ByteArrayOutputStream()
1479 props.store(bytes, null)
1480 def propertiesString = bytes.toString()
1481 propsFile.text = propertiesString
1487 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1490 //inputs.property(propKey, eclipseWsDir) // eclipseWsDir only gets set once this task runs, so will be out-of-date
1491 outputs.file(propsFileName)
1492 outputs.upToDateWhen { eclipseWorkspace.exists() && propsFile.exists() }
1496 task jalviewjsEclipsePaths {
1499 def eclipseRoot = jalviewjs_eclipse_root
1500 if (eclipseRoot.startsWith("~/")) {
1501 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1503 if (OperatingSystem.current().isMacOsX()) {
1504 eclipseRoot += "/Eclipse.app"
1505 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1506 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1507 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1508 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1509 eclipseRoot += "/eclipse.exe"
1511 eclipseBinary = "${eclipseRoot}/eclipse"
1512 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1513 } else { // linux or unix
1514 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1515 eclipseRoot += "/eclipse"
1517 eclipseBinary = "${eclipseRoot}/eclipse"
1518 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1521 eclipseVersion = "4.13" // default
1522 def assumedVersion = true
1523 if (file(eclipseProduct).exists()) {
1524 def fis = new FileInputStream(eclipseProduct)
1525 def props = new Properties()
1527 eclipseVersion = props.getProperty("version")
1529 assumedVersion = false
1532 def propKey = "eclipse_debug"
1533 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1536 // do not run a headless transpile when we claim to be in Eclipse
1538 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1539 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1541 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1544 if (!assumedVersion) {
1545 println("ECLIPSE VERSION=${eclipseVersion}")
1552 dependsOn eclipseProject
1553 dependsOn eclipseClasspath
1554 dependsOn eclipseJdt
1558 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1559 task jalviewjsEclipseCopyDropins(type: Copy) {
1560 dependsOn jalviewjsEclipsePaths
1562 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1563 inputFiles += file("${jalviewDir}/${jalviewjs_j2s_plugin}")
1564 def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
1571 // this eclipse -clean doesn't actually work
1572 task jalviewjsCleanEclipse(type: Exec) {
1573 dependsOn eclipseSetup
1574 dependsOn jalviewjsEclipsePaths
1575 dependsOn jalviewjsEclipseCopyDropins
1577 executable(eclipseBinary)
1578 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
1584 def inputString = """exit
1587 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
1588 standardInput = inputByteStream
1591 /* not really working yet
1592 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
1596 task jalviewjsTransferUnzipSwingJs {
1597 def file_zip = "${jalviewDir}/${jalviewjs_swingjs_zip}"
1601 from zipTree(file_zip)
1602 into "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
1606 inputs.file file_zip
1607 outputs.dir "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
1611 task jalviewjsTransferUnzipLib {
1612 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
1615 zipFiles.each { file_zip ->
1617 from zipTree(file_zip)
1618 into "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
1623 inputs.files zipFiles
1624 outputs.dir "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
1628 task jalviewjsTransferUnzipAllLibs {
1629 dependsOn jalviewjsTransferUnzipSwingJs
1630 dependsOn jalviewjsTransferUnzipLib
1634 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1636 description "Create the .j2s file from the j2s.* properties"
1638 jalviewjsJ2sProps = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1639 def siteDirProperty = "j2s.site.directory"
1640 def setSiteDir = false
1641 jalviewjsJ2sProps.each { prop, val ->
1643 if (prop == siteDirProperty) {
1644 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1645 val = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${val}"
1651 if (!setSiteDir) { // default site location, don't override specifically set property
1652 property(siteDirProperty,"${jalviewDirRelativePath}/${jalviewjsTransferSiteJsDir}")
1655 outputFile = jalviewjsJ2sSettingsFileName
1658 inputs.properties(jalviewjsJ2sProps)
1659 outputs.file(jalviewjsJ2sSettingsFileName)
1664 task jalviewjsEclipseSetup {
1665 dependsOn jalviewjsEclipseCopyDropins
1666 dependsOn jalviewjsSetEclipseWorkspace
1667 dependsOn jalviewjsCreateJ2sSettings
1671 task jalviewjsSyncAllLibs (type: Sync) {
1672 dependsOn jalviewjsTransferUnzipAllLibs
1673 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteLibDir}")
1674 inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
1675 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1679 def outputFiles = []
1680 rename { filename ->
1681 outputFiles += "${outputDir}/${filename}"
1687 outputs.files outputFiles
1688 inputs.files inputFiles
1692 task jalviewjsSyncResources (type: Sync) {
1693 def inputFiles = fileTree(dir: resourceDir)
1694 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1698 def outputFiles = []
1699 rename { filename ->
1700 outputFiles += "${outputDir}/${filename}"
1706 outputs.files outputFiles
1707 inputs.files inputFiles
1711 task jalviewjsSyncSiteResources (type: Sync) {
1712 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
1713 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1717 def outputFiles = []
1718 rename { filename ->
1719 outputFiles += "${outputDir}/${filename}"
1725 outputs.files outputFiles
1726 inputs.files inputFiles
1730 task jalviewjsSyncBuildProperties (type: Sync) {
1731 dependsOn createBuildProperties
1732 def inputFiles = [file(buildProperties)]
1733 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1737 def outputFiles = []
1738 rename { filename ->
1739 outputFiles += "${outputDir}/${filename}"
1745 outputs.files outputFiles
1746 inputs.files inputFiles
1750 task jalviewjsProjectImport(type: Exec) {
1751 dependsOn eclipseSetup
1752 dependsOn jalviewjsEclipsePaths
1753 dependsOn jalviewjsEclipseSetup
1756 // do not run a headless import when we claim to be in Eclipse
1758 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1759 throw new StopExecutionException("Not running headless import whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1761 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1765 //def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1766 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview"
1767 executable(eclipseBinary)
1768 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1772 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1774 args += [ "-D${j2sHeadlessBuildProperty}=true" ]
1777 inputs.file("${jalviewDir}/.project")
1778 outputs.upToDateWhen {
1779 file(projdir).exists()
1784 task jalviewjsTranspile(type: Exec) {
1785 dependsOn jalviewjsEclipseSetup
1786 dependsOn jalviewjsProjectImport
1787 dependsOn jalviewjsEclipsePaths
1790 // do not run a headless transpile when we claim to be in Eclipse
1792 println("Skipping task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1793 throw new StopExecutionException("Not running headless transpile whilst IN_ECLIPSE is '${IN_ECLIPSE}'")
1795 println("Running task ${name} as IN_ECLIPSE=${IN_ECLIPSE}")
1799 executable(eclipseBinary)
1800 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
1804 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1806 args += [ "-D${j2sHeadlessBuildProperty}=true" ]
1812 stdout = new ByteArrayOutputStream()
1813 stderr = new ByteArrayOutputStream()
1815 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}"
1816 def logOutFile = file(logOutFileName)
1817 logOutFile.createNewFile()
1818 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
1819 BINARY: ${eclipseBinary}
1820 VERSION: ${eclipseVersion}
1821 WORKSPACE: ${eclipseWorkspace}
1822 DEBUG: ${eclipseDebug}
1825 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1826 // combine stdout and stderr
1827 def logErrFOS = logOutFOS
1829 if (jalviewjs_j2s_to_console.equals("true")) {
1830 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1831 new org.apache.tools.ant.util.TeeOutputStream(
1835 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1836 new org.apache.tools.ant.util.TeeOutputStream(
1841 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1844 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1851 if (stdout.toString().contains("Error processing ")) {
1852 // j2s did not complete transpile
1853 //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
1854 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
1858 inputs.dir("${jalviewDir}/${sourceDir}")
1859 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
1860 outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
1864 def jalviewjsCallCore(String name, FileCollection list, String prefixFile, String suffixFile, String jsfile, String zjsfile, File logOutFile, Boolean logOutConsole) {
1866 def stdout = new ByteArrayOutputStream()
1867 def stderr = new ByteArrayOutputStream()
1869 def coreFile = file(jsfile)
1871 msg = "Creating core for ${name}...\nGenerating ${jsfile}"
1873 logOutFile.createNewFile()
1874 logOutFile.append(msg+"\n")
1876 def coreTop = file(prefixFile)
1877 def coreBottom = file(suffixFile)
1878 coreFile.getParentFile().mkdirs()
1879 coreFile.createNewFile()
1880 coreFile.write( coreTop.text )
1885 t.replaceAll("Clazz\\.([^_])","Clazz_${1}")
1886 coreFile.append( t )
1888 msg = "...file '"+f.getPath()+"' does not exist, skipping"
1890 logOutFile.append(msg+"\n")
1893 coreFile.append( coreBottom.text )
1895 msg = "Generating ${zjsfile}"
1897 logOutFile.append(msg+"\n")
1898 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1899 def logErrFOS = logOutFOS
1902 classpath = files(["${jalviewDir}/tools/closure_compiler.jar"])
1903 args = [ "--js", jsfile, "--js_output_file", zjsfile ]
1906 msg = "\nRunning '"+commandLine.join(' ')+"'\n"
1908 logOutFile.append(msg+"\n")
1910 if (logOutConsole) {
1911 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1912 new org.apache.tools.ant.util.TeeOutputStream(
1916 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1917 new org.apache.tools.ant.util.TeeOutputStream(
1922 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1925 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1932 logOutFile.append(msg+"\n")
1936 task jalviewjsBuildAllCores {
1938 description "Build the core js lib closures listed in the classlists dir"
1939 dependsOn jalviewjsTranspile
1940 dependsOn jalviewjsTransferUnzipSwingJs
1942 def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}"
1943 def swingJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_j2s_subdir}"
1944 def libJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${jalviewjs_j2s_subdir}"
1945 def jsDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_js_subdir}"
1946 def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core"
1947 def prefixFile = "${jsDir}/core/coretop2.js"
1948 def suffixFile = "${jsDir}/core/corebottom2.js"
1950 inputs.file prefixFile
1951 inputs.file suffixFile
1953 def classlistFiles = []
1954 // add the classlists found int the jalviewjs_classlists_dir
1955 fileTree(dir: "${jalviewDir}/${jalviewjs_classlists_dir}", include: "*.txt").each {
1957 def name = file.getName() - ".txt"
1964 // _jmol and _jalview cores. Add any other peculiar classlist.txt files here
1965 //classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jmol}"), 'name': "_jvjmol" ]
1966 classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jalview}"), 'name': jalviewjsJalviewCoreName ]
1968 jalviewjsCoreClasslists = []
1970 classlistFiles.each {
1973 def file = hash['file']
1974 if (! file.exists()) {
1975 //println("...classlist file '"+file.getPath()+"' does not exist, skipping")
1976 return false // this is a "continue" in groovy .each closure
1978 def name = hash['name']
1980 name = file.getName() - ".txt"
1988 def list = fileTree(dir: j2sDir, includes: filelist)
1990 def jsfile = "${outputDir}/core${name}.js"
1991 def zjsfile = "${outputDir}/core${name}.z.js"
1993 jalviewjsCoreClasslists += [
2002 outputs.file(jsfile)
2003 outputs.file(zjsfile)
2006 // _stevesoft core. add any cores without a classlist here (and the inputs and outputs)
2007 def stevesoftClasslistName = "_stevesoft"
2008 def stevesoftClasslist = [
2009 'jsfile': "${outputDir}/core${stevesoftClasslistName}.js",
2010 'zjsfile': "${outputDir}/core${stevesoftClasslistName}.z.js",
2011 'list': fileTree(dir: j2sDir, include: "com/stevesoft/pat/**/*.js"),
2012 'name': stevesoftClasslistName
2014 jalviewjsCoreClasslists += stevesoftClasslist
2015 inputs.files(stevesoftClasslist['list'])
2016 outputs.file(stevesoftClasslist['jsfile'])
2017 outputs.file(stevesoftClasslist['zjsfile'])
2020 def allClasslistName = "_all"
2021 def allJsFiles = fileTree(dir: j2sDir, include: "**/*.js")
2022 allJsFiles += fileTree(
2026 // these exlusions are files that the closure-compiler produces errors for. Should fix them
2027 "**/org/jmol/jvxl/readers/IsoIntersectFileReader.js",
2028 "**/org/jmol/export/JSExporter.js"
2031 allJsFiles += fileTree(
2035 // these exlusions are files that the closure-compiler produces errors for. Should fix them
2036 "**/sun/misc/Unsafe.js",
2037 "**/swingjs/jquery/jquery-editable-select.js",
2038 "**/swingjs/jquery/j2sComboBox.js",
2039 "**/sun/misc/FloatingDecimal.js"
2042 def allClasslist = [
2043 'jsfile': "${outputDir}/core${allClasslistName}.js",
2044 'zjsfile': "${outputDir}/core${allClasslistName}.z.js",
2046 'name': allClasslistName
2048 jalviewjsCoreClasslists += allClasslist
2049 inputs.files(allClasslist['list'])
2050 outputs.file(allClasslist['jsfile'])
2051 outputs.file(allClasslist['zjsfile'])
2054 def logOutFile = file("${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_closure_stdout}")
2055 logOutFile.getParentFile().mkdirs()
2056 logOutFile.createNewFile()
2057 logOutFile.write(getDate("yyyy-MM-dd HH:mm:ss")+" jalviewjsBuildAllCores\n----\n")
2059 jalviewjsCoreClasslists.each {
2060 jalviewjsCallCore(it.name, it.list, prefixFile, suffixFile, it.jsfile, it.zjsfile, logOutFile, jalviewjs_j2s_to_console.equals("true"))
2067 def jalviewjsPublishCoreTemplate(String coreName, String templateName, File inputFile, String outputFile) {
2070 into file(outputFile).getParentFile()
2071 rename { filename ->
2072 if (filename.equals(inputFile.getName())) {
2073 return file(outputFile).getName()
2077 filter(ReplaceTokens,
2081 'MAIN': '"'+mainClass+'"',
2083 'NAME': jalviewjsJalviewTemplateName+" [core ${coreName}]",
2084 'COREKEY': jalviewjs_core_key,
2085 'CORENAME': coreName
2092 task jalviewjsPublishCoreTemplates {
2093 dependsOn jalviewjsBuildAllCores
2094 def inputFileName = "${jalviewDir}/${j2s_coretemplate_html}"
2095 def inputFile = file(inputFileName)
2096 def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2098 def outputFiles = []
2099 jalviewjsCoreClasslists.each { cl ->
2100 def outputFile = "${outputDir}/${jalviewjsJalviewTemplateName}_${cl.name}.html"
2101 cl['outputfile'] = outputFile
2102 outputFiles += outputFile
2106 jalviewjsCoreClasslists.each { cl ->
2107 jalviewjsPublishCoreTemplate(cl.name, jalviewjsJalviewTemplateName, inputFile, cl.outputfile)
2110 inputs.file(inputFile)
2111 outputs.files(outputFiles)
2115 task jalviewjsSyncCore (type: Sync) {
2116 dependsOn jalviewjsBuildAllCores
2117 dependsOn jalviewjsPublishCoreTemplates
2118 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
2119 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
2123 def outputFiles = []
2124 rename { filename ->
2125 outputFiles += "${outputDir}/${filename}"
2131 outputs.files outputFiles
2132 inputs.files inputFiles
2136 // this Copy version of TransferSiteJs will delete anything else in the target dir
2137 task jalviewjsCopyTransferSiteJs(type: Copy) {
2138 dependsOn jalviewjsTranspile
2139 from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2140 into "${jalviewDir}/${jalviewjsSiteDir}"
2144 // this Sync version of TransferSite is used by buildship to keep the website automatically up to date when a file changes
2145 task jalviewjsSyncTransferSiteJs(type: Sync) {
2146 from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2148 into "${jalviewDir}/${jalviewjsSiteDir}"
2155 jalviewjsSyncAllLibs.mustRunAfter jalviewjsCopyTransferSiteJs
2156 jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSiteJs
2157 jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSiteJs
2158 jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSiteJs
2160 jalviewjsSyncAllLibs.mustRunAfter jalviewjsSyncTransferSiteJs
2161 jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSiteJs
2162 jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSiteJs
2163 jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSiteJs
2166 task jalviewjsPrepareSite {
2168 description "Prepares the website folder including unzipping files and copying resources"
2169 dependsOn jalviewjsSyncAllLibs
2170 dependsOn jalviewjsSyncResources
2171 dependsOn jalviewjsSyncSiteResources
2172 dependsOn jalviewjsSyncBuildProperties
2173 dependsOn jalviewjsSyncCore
2177 task jalviewjsBuildSite {
2179 description "Builds the whole website including transpiled code"
2180 dependsOn jalviewjsCopyTransferSiteJs
2181 dependsOn jalviewjsPrepareSite
2185 task cleanJalviewjsTransferSite {
2187 delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
2188 delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
2189 delete "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
2190 delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
2195 task cleanJalviewjsSite {
2196 dependsOn cleanJalviewjsTransferSite
2198 delete "${jalviewDir}/${jalviewjsSiteDir}"
2203 task jalviewjsSiteTar(type: Tar) {
2205 description "Creates a tar.gz file for the website"
2206 dependsOn jalviewjsBuildSite
2207 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
2209 archiveFileName = outputFilename
2210 } catch (Exception e) {
2211 archiveName = outputFilename
2214 compression Compression.GZIP
2216 from "${jalviewDir}/${jalviewjsSiteDir}"
2217 into jalviewjs_site_dir // this is inside the tar file
2219 inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
2223 task jalviewjsServer {
2225 def filename = "jalviewjsTest.html"
2226 description "Starts a webserver on localhost to test the website. See ${filename} to access local site on most recently used port."
2227 def htmlFile = "${jalviewDirAbsolutePath}/${filename}"
2230 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
2231 def port = Integer.valueOf(jalviewjs_server_port)
2236 while(port < start+1000 && !running) {
2238 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
2239 jalviewjsServer = factory.start(doc_root, port)
2241 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
2242 println("SERVER STARTED with document root ${doc_root}.")
2243 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
2244 println("For debug: "+url+"?j2sdebug")
2245 println("For verbose: "+url+"?j2sverbose")
2246 } catch (Exception e) {
2251 <p><a href="${url}">JalviewJS Test. <${url}></a></p>
2252 <p><a href="${url}?j2sdebug">JalviewJS Test with debug. <${url}?j2sdebug></a></p>
2253 <p><a href="${url}?j2sverbose">JalviewJS Test with verbose. <${url}?j2sdebug></a></p>
2255 jalviewjsCoreClasslists.each { cl ->
2256 def urlcore = jalviewjsServer.getResourceUrl(file(cl.outputfile).getName())
2258 <p><a href="${urlcore}">${jalviewjsJalviewTemplateName} [core ${cl.name}]. <${urlcore}></a></p>
2260 println("For core ${cl.name}: "+urlcore)
2263 file(htmlFile).text = htmlText
2266 outputs.file(htmlFile)
2267 outputs.upToDateWhen({false})
2271 task cleanJalviewjsAll {
2273 description "Delete all configuration and build artifacts to do with JalviewJS build"
2274 dependsOn cleanJalviewjsSite
2275 dependsOn jalviewjsEclipsePaths
2278 delete "${jalviewDir}/${jalviewjsBuildDir}"
2279 delete "${jalviewDir}/${eclipse_bin_dir}"
2280 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
2281 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
2283 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
2286 outputs.upToDateWhen( { false } )
2290 task jalviewjsIDE_checkJ2sPlugin {
2291 group "00 JalviewJS in Eclipse"
2292 description "Compare the swingjs/net.sf.j2s.core.jar file with the Eclipse IDE's plugin version (found in the 'dropins' dir)"
2295 def j2sPlugin = string("${jalviewDir}/${jalviewjs_j2s_plugin}")
2296 def j2sPluginFile = file(j2sPlugin)
2297 def copyPlugin = jalviewjs_eclipseIDE_auto_copy_j2s_plugin == "true"
2298 def eclipseHome = System.properties["eclipse.home.location"]
2300 if (eclipseHome == null || ! IN_ECLIPSE) {
2301 throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.")
2303 def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}"
2304 def eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
2305 if (!eclipseJ2sPluginFile.exists()) {
2306 def msg = "Eclipse J2S Plugin is not installed"
2309 throw new GradleException(msg)
2314 def digest = MessageDigest.getInstance("MD5")
2316 digest.update(j2sPluginFile.text.bytes)
2317 def j2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2319 digest.update(eclipseJ2sPluginFile.text.bytes)
2320 def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
2322 if (j2sPluginMd5 != eclipseJ2sPluginMd5) {
2323 def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'"
2326 throw new StopExecutionException(msg)
2332 def msg = "WARNING! Auto-copying this commit's j2s plugin version '${j2sPlugin}' to Eclipse J2S Plugin '${eclipseJ2sPlugin}'\n May require an Eclipse restart"
2336 eclipseJ2sPluginFile.getParentFile().mkdirs()
2337 into eclipseJ2sPluginFile.getParent()
2340 def msg = "Eclipse J2S Plugin is the same as '${j2sPlugin}'"
2347 task jalviewjsIDE_j2sFile {
2348 group "00 JalviewJS in Eclipse"
2349 description "Creates the .j2s file"
2350 dependsOn jalviewjsCreateJ2sSettings
2354 task jalviewjsIDE_SyncCore {
2355 group "00 JalviewJS in Eclipse"
2356 description "Build the core js lib closures listed in the classlists dir and publish core html from template"
2357 dependsOn jalviewjsSyncCore
2361 task jalviewjsIDE_SyncSiteAll {
2362 dependsOn jalviewjsSyncAllLibs
2363 dependsOn jalviewjsSyncResources
2364 dependsOn jalviewjsSyncSiteResources
2365 dependsOn jalviewjsSyncBuildProperties
2369 cleanJalviewjsTransferSite.mustRunAfter jalviewjsIDE_SyncSiteAll
2372 task jalviewjsIDE_PrepareSite {
2373 group "00 JalviewJS in Eclipse"
2374 description "Sync libs and resources to site dir, but not closure cores"
2376 dependsOn jalviewjsIDE_SyncSiteAll
2377 dependsOn cleanJalviewjsTransferSite
2381 task jalviewjsIDE_AssembleSite {
2382 group "00 JalviewJS in Eclipse"
2383 description "Assembles unzipped supporting zipfiles, resources, site resources and closure cores into the Eclipse transpiled site"
2384 dependsOn jalviewjsPrepareSite
2388 task jalviewjsIDE_SiteClean {
2389 group "00 JalviewJS in Eclipse"
2390 description "Deletes the Eclipse transpiled site"
2391 dependsOn cleanJalviewjsSite
2395 task jalviewjsIDE_Server {
2396 group "00 JalviewJS in Eclipse"
2397 description "Starts a webserver on localhost to test the website"
2398 dependsOn jalviewjsServer
2402 // buildship runs this at import or gradle refresh
2403 task eclipseSynchronizationTask {
2404 //dependsOn eclipseSetup
2405 dependsOn createBuildProperties
2407 dependsOn jalviewjsIDE_j2sFile
2408 dependsOn jalviewjsIDE_checkJ2sPlugin
2409 dependsOn jalviewjsIDE_PrepareSite
2414 // buildship runs this at build time or project refresh
2415 task eclipseAutoBuildTask {
2416 //dependsOn jalviewjsIDE_checkJ2sPlugin
2417 //dependsOn jalviewjsIDE_PrepareSite
2429 description "Build the site"
2430 dependsOn jalviewjsBuildSite