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
6 import groovy.transform.ExternalizeMethods
10 classpath 'org.openclover:clover:4.3.1'
18 id 'com.github.johnrengelman.shadow' version '4.0.3'
19 id 'com.install4j.gradle' version '7.0.9'
22 // local build environment properties
23 def localProps = "${jalviewDir}/local.properties"
24 if (file(localProps).exists()) {
26 def p = new Properties()
27 def localPropsFIS = new FileInputStream(localProps)
32 def over = getProperty(key) != null
35 println("Overriding property '${key}' with local.properties value '${val}'")
38 } catch (Exception e) {
39 System.out.println("Exception reading local.properties")
53 compile 'org.apache.commons:commons-compress:1.18'
56 mainClassName = launcherClass
57 def cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
58 def classes = "${jalviewDir}/${classesDir}"
60 if (clover.equals("true")) {
62 classes = "${buildDir}/${cloverClassesDir}"
65 classes = "${jalviewDir}/${classesDir}"
68 // configure classpath/args for j8/j11 compilation
70 def jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
73 def compile_source_compatibility
74 def compile_target_compatibility
77 getdownWebsiteDir = "${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}"
79 reportRsyncCmd = false
81 buildProperties = buildPropertiesFile
82 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}"
86 // TODO: get bamboo build artifact URL for getdown artifacts
87 getdown_channel_base = bamboo_channelbase
88 getdown_channel_name = "${bamboo_planKey}/${JAVA_VERSION}"
89 getdown_app_base = "${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}"
90 getdown_app_dir = getdown_app_dir_alt
91 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
95 getdown_channel_name = CHANNEL.toLowerCase()
96 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
97 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
98 getdown_app_dir = getdown_app_dir_release
99 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
100 reportRsyncCommand = true
104 getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
105 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
106 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
107 getdown_app_dir = getdown_app_dir_alt
108 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
109 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
112 packageDir = "${ARCHIVEDIR}/${packageDir}"
113 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
116 reportRsyncCommand = true
120 getdown_channel_name = "archive/${JALVIEW_VERSION}"
121 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
122 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
123 getdown_app_dir = getdown_app_dir_alt
124 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
125 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
128 packageDir = "${ARCHIVEDIR}/${packageDir}"
129 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
132 reportRsyncCommand = true
133 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
137 getdown_channel_name = CHANNEL.toLowerCase()
138 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
139 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
140 getdown_app_dir = getdown_app_dir_alt
141 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
142 reportRsyncCommand = true
146 getdown_channel_name = CHANNEL.toLowerCase()
147 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
148 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
149 getdown_app_dir = getdown_app_dir_alt
150 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
151 reportRsyncCommand = true
154 case ~/^SCRATCH(|-[-\w]*)$/:
155 getdown_channel_name = CHANNEL
156 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
157 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
158 getdown_app_dir = getdown_app_dir_alt
159 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
160 reportRsyncCommand = true
164 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
165 getdown_app_dir = getdown_app_dir_alt
166 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
167 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
170 default: // something wrong specified
171 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
177 getdownAppDir = "${getdownWebsiteDir}/${getdown_app_dir}"
178 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
179 getdownResourceDir = "${getdownWebsiteDir}/${getdown_resource_dir}"
180 getdownInstallDir = "${getdownWebsiteDir}/${getdown_install_dir}"
181 getdownFilesDir = "${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/"
182 getdownFilesInstallDir = "${getdownFilesDir}/${getdown_install_dir}"
183 /* compile without modules -- using classpath libraries
184 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
185 modules_runtimeClasspath = modules_compileClasspath
190 println("Using a ${CHANNEL} profile.")
193 def JAVA_INTEGER_VERSION
194 def additional_compiler_args = []
195 // these are getdown.txt properties defined dependent on the JAVA_VERSION
196 def getdown_alt_java_min_version
197 def getdown_alt_java_max_version
198 // this property is assigned below and expanded to multiple lines in the getdown task
199 def getdown_alt_multi_java_location
200 // this property is for the Java library used in eclipse
201 def eclipse_java_runtime_name
202 if (JAVA_VERSION.equals("1.8")) {
203 JAVA_INTEGER_VERSION = "8"
206 libDistDir = j8libDir
207 compile_source_compatibility = 1.8
208 compile_target_compatibility = 1.8
209 getdown_alt_java_min_version = getdown_alt_java8_min_version
210 getdown_alt_java_max_version = getdown_alt_java8_max_version
211 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
212 eclipse_java_runtime_name = "JavaSE-1.8"
213 } else if (JAVA_VERSION.equals("11")) {
214 JAVA_INTEGER_VERSION = "11"
216 libDistDir = j11libDir
217 compile_source_compatibility = 11
218 compile_target_compatibility = 11
219 getdown_alt_java_min_version = getdown_alt_java11_min_version
220 getdown_alt_java_max_version = getdown_alt_java11_max_version
221 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
222 eclipse_java_runtime_name = "JavaSE-11"
223 /* compile without modules -- using classpath libraries
224 additional_compiler_args += [
225 '--module-path', ext.modules_compileClasspath.asPath,
226 '--add-modules', j11modules
229 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
230 JAVA_INTEGER_VERSION = JAVA_VERSION
232 libDistDir = j11libDir
233 compile_source_compatibility = JAVA_VERSION
234 compile_target_compatibility = JAVA_VERSION
235 getdown_alt_java_min_version = getdown_alt_java11_min_version
236 getdown_alt_java_max_version = getdown_alt_java11_max_version
237 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
238 eclipse_java_runtime_name = "JavaSE-11"
239 /* compile without modules -- using classpath libraries
240 additional_compiler_args += [
241 '--module-path', ext.modules_compileClasspath.asPath,
242 '--add-modules', j11modules
246 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
253 srcDirs "${jalviewDir}/${sourceDir}"
254 outputDir = file("${classes}")
258 srcDirs "${jalviewDir}/${resourceDir}"
261 jar.destinationDir = file("${jalviewDir}/${packageDir}")
263 compileClasspath = files(sourceSets.main.java.outputDir)
264 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
266 runtimeClasspath = compileClasspath
271 srcDirs = [ cloverInstrDir ]
272 outputDir = file("${buildDir}/${cloverClassesDir}")
276 srcDirs = sourceSets.main.resources.srcDirs
278 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
279 compileClasspath += files(sourceSets.main.java.outputDir)
280 compileClasspath += sourceSets.main.compileClasspath
281 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
282 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
284 runtimeClasspath = compileClasspath
289 srcDirs "${jalviewDir}/${testSourceDir}"
290 outputDir = file("${jalviewDir}/${testOutputDir}")
294 srcDirs = sourceSets.main.resources.srcDirs
297 compileClasspath = files( sourceSets.test.java.outputDir )
300 compileClasspath += sourceSets.clover.compileClasspath
302 compileClasspath += files(sourceSets.main.java.outputDir)
305 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
306 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
307 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
309 runtimeClasspath = compileClasspath
316 cloverCompile 'org.openclover:clover:4.3.1'
317 testCompile 'org.openclover:clover:4.3.1'
323 cloverRuntime.extendsFrom cloverCompile
328 name = eclipse_project_name
330 natures 'org.eclipse.jdt.core.javanature',
331 'org.eclipse.jdt.groovy.core.groovyNature',
332 'org.eclipse.buildship.core.gradleprojectnature'
334 buildCommand 'org.eclipse.jdt.core.javabuilder'
335 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
339 //defaultOutputDir = sourceSets.main.java.outputDir
342 if (it.isCanBeResolved()) {
347 minusConfigurations += removeThese
348 plusConfigurations = [ ]
352 def removeTheseToo = []
353 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
354 cp.entries.each { entry ->
355 if (entry.kind == 'src') {
356 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == sourceDir || entry.path == testSourceDir)) {
357 removeTheseToo += entry
359 alreadyAddedSrcPath.putAt(entry.path, true)
363 cp.entries.removeAll(removeTheseToo)
365 if (file("${jalviewDir}/${eclipse_bin_dir}/main").isDirectory()) {
366 cp.entries += new Output("${eclipse_bin_dir}/main")
368 if (file(helpParentDir).isDirectory()) {
369 cp.entries += new Library(fileReference(helpParentDir))
371 if (file(resourceDir).isDirectory()) {
372 cp.entries += new Library(fileReference(resourceDir))
375 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
377 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
378 //don't want to add outputDir as eclipse is using its own output dir in bin/main
379 if (it.isDirectory() || ! it.exists()) {
380 // don't add dirs to classpath
383 def itPath = it.toString()
384 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
385 // make relative path
386 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
388 if (alreadyAddedLibPath.get(itPath)) {
389 //println("Not adding duplicate entry "+itPath)
391 //println("Adding entry "+itPath)
392 cp.entries += new Library(fileReference(itPath))
393 alreadyAddedLibPath.put(itPath, true)
397 //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
398 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
399 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
400 if (it.isDirectory() || ! it.exists()) {
401 // don't add dirs to classpath
402 return false // groovy "break" in .each closure
404 def itPath = it.toString()
405 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
406 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
408 if (alreadyAddedLibPath.get(itPath)) {
411 def lib = new Library(fileReference(itPath))
412 lib.entryAttributes["test"] = "true"
414 alreadyAddedLibPath.put(itPath, true)
422 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
427 // for the IDE, use java 11 compatibility
428 sourceCompatibility = compile_source_compatibility
429 targetCompatibility = compile_target_compatibility
430 javaRuntimeName = eclipse_java_runtime_name
432 // add in jalview project specific properties/preferences into eclipse core preferences
434 withProperties { props ->
435 def jalview_prefs = new Properties()
436 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
437 jalview_prefs.load(ins)
439 jalview_prefs.forEach { t, v ->
440 if (props.getAt(t) == null) {
449 synchronizationTasks "eclipseSynchronizationTask"
450 autoBuildTasks "eclipseAutoBuildTask"
455 // only instrument source, we build test classes as normal
456 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
457 outputs.dir cloverInstrDir
460 delete cloverInstrDir
461 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
462 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
463 argsList.addAll(inputs.files.files.collect({ file ->
466 String[] args = argsList.toArray()
467 println("About to instrument "+args.length +" files")
468 com.atlassian.clover.CloverInstr.mainImpl(args)
474 group = "Verification"
475 description = "Createst the Clover report"
476 inputs.dir "${buildDir}/clover"
477 outputs.dir "${reportsDir}/clover"
479 file("${buildDir}/clover/clover.db").exists()
482 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
483 "-o", "${reportsDir}/clover"]
484 String[] args = argsList.toArray()
485 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
487 // and generate ${reportsDir}/clover/clover.xml
488 args = ["--initstring", "${buildDir}/clover/clover.db",
489 "-o", "${reportsDir}/clover/clover.xml"].toArray()
490 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
500 sourceCompatibility = compile_source_compatibility
501 targetCompatibility = compile_target_compatibility
502 options.compilerArgs = additional_compiler_args
503 print ("Setting target compatibility to "+targetCompatibility+"\n")
510 dependsOn compileCloverJava
511 classpath += configurations.cloverRuntime
513 classpath += sourceSets.main.runtimeClasspath
516 sourceCompatibility = compile_source_compatibility
517 targetCompatibility = compile_target_compatibility
518 options.compilerArgs = additional_compiler_args
519 print ("Setting target compatibility to "+targetCompatibility+"\n")
527 sourceCompatibility = compile_source_compatibility
528 targetCompatibility = compile_target_compatibility
529 options.compilerArgs += additional_compiler_args
530 print ("Setting target compatibility to "+targetCompatibility+"\n")
532 classpath += configurations.cloverRuntime
537 delete sourceSets.main.java.outputDir
543 delete sourceSets.test.java.outputDir
544 delete cloverInstrDir
548 // format is a string like date.format("dd MMMM yyyy")
549 def getDate(format) {
550 def date = new Date()
551 return date.format(format)
555 def hashStdOut = new ByteArrayOutputStream()
557 commandLine "git", "rev-parse", "--short", "HEAD"
558 standardOutput = hashStdOut
562 def branchStdOut = new ByteArrayOutputStream()
564 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
565 standardOutput = branchStdOut
569 project.ext.gitHash = hashStdOut.toString().trim()
570 project.ext.gitBranch = branchStdOut.toString().trim()
572 outputs.upToDateWhen { false }
575 task createBuildProperties(type: WriteProperties) {
577 inputs.dir("${jalviewDir}/${sourceDir}")
578 inputs.dir("${classes}")
579 inputs.dir("${jalviewDir}/${resourceDir}")
580 outputFile (buildProperties)
581 // taking time specific comment out to allow better incremental builds
582 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
583 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
584 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
585 property "VERSION", JALVIEW_VERSION
586 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
587 outputs.file(outputFile)
590 def buildingHTML = "${jalviewDir}/${docDir}/building.html"
591 task cleanBuildingHTML(type: Delete) {
597 task convertBuildingMD(type: Exec) {
598 dependsOn cleanBuildingHTML
599 def buildingMD = "${jalviewDir}/${docDir}/building.md"
600 def css = "${jalviewDir}/${docDir}/github.css"
603 pandoc_exec.split(",").each {
604 if (file(it.trim()).exists()) {
610 def hostname = "hostname".execute().text.trim()
611 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
612 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
616 if (pandoc != null && file(pandoc).exists()) {
617 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
619 println("Cannot find pandoc. Skipping convert building.md to HTML")
620 throw new StopExecutionException()
626 inputs.file(buildingMD)
628 outputs.file(buildingHTML)
637 task syncDocs(type: Sync) {
638 dependsOn convertBuildingMD
639 def syncDir = "${classes}/${docDir}"
640 from fileTree("${jalviewDir}/${docDir}")
645 def helpFile = "${classes}/${helpDir}/help.jhm"
647 task copyHelp(type: Copy) {
648 def inputDir = "${jalviewDir}/${helpParentDir}/${helpDir}"
649 def outputDir = "${classes}/${helpDir}"
654 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
664 outputs.files(helpFile)
665 outputs.dir(outputDir)
668 task syncLib(type: Sync) {
669 def syncDir = "${classes}/${libDistDir}"
670 from fileTree("${jalviewDir}/${libDistDir}")
674 task syncResources(type: Sync) {
675 from "${jalviewDir}/${resourceDir}"
684 dependsOn syncResources
690 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
693 dependsOn compileJava
695 dependsOn cloverInstr
699 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
703 includeGroups testngGroups
705 useDefaultListeners=true
708 workingDir = jalviewDir
709 //systemProperties 'clover.jar' System.properties.clover.jar
710 sourceCompatibility = compile_source_compatibility
711 targetCompatibility = compile_target_compatibility
712 jvmArgs += additional_compiler_args
716 task buildIndices(type: JavaExec) {
718 classpath = sourceSets.main.compileClasspath
719 main = "com.sun.java.help.search.Indexer"
720 workingDir = "${classes}/${helpDir}"
723 inputs.dir("${workingDir}/${argDir}")
725 outputs.dir("${classes}/doc")
726 outputs.dir("${classes}/help")
727 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
728 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
729 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
730 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
731 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
732 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
735 task compileLinkCheck(type: JavaCompile) {
737 classpath = files("${jalviewDir}/${utilsDir}")
738 destinationDir = file("${jalviewDir}/${utilsDir}")
739 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
741 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
742 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
743 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
744 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
747 task linkCheck(type: JavaExec) {
748 dependsOn prepare, compileLinkCheck
750 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
751 classpath = files("${jalviewDir}/${utilsDir}")
752 main = "HelpLinksChecker"
753 workingDir = jalviewDir
754 def help = "${classes}/${helpDir}"
755 args = [ "${classes}/${helpDir}", "-nointernet" ]
757 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
759 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
762 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
766 inputs.dir("${classes}/${helpDir}")
767 outputs.file(helpLinksCheckerOutFile)
770 // import the pubhtmlhelp target
771 ant.properties.basedir = "${jalviewDir}"
772 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes}/${helpDir}"
773 ant.importBuild "${utilsDir}/publishHelp.xml"
776 task cleanPackageDir(type: Delete) {
778 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
784 dependsOn buildIndices
785 dependsOn createBuildProperties
788 attributes "Main-Class": mainClass,
789 "Permissions": "all-permissions",
790 "Application-Name": "Jalview Desktop",
791 "Codebase": application_codebase
794 destinationDir = file("${jalviewDir}/${packageDir}")
795 archiveName = rootProject.name+".jar"
803 inputs.dir("${classes}")
804 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
807 task copyJars(type: Copy) {
808 from fileTree(dir: "${classes}", include: "**/*.jar").files
809 into "${jalviewDir}/${packageDir}"
812 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
813 task syncJars(type: Sync) {
814 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
815 into "${jalviewDir}/${packageDir}"
817 include jar.archiveName
823 description = "Put all required libraries in dist"
824 // order of "cleanPackageDir", "copyJars", "jar" important!
825 jar.mustRunAfter cleanPackageDir
826 syncJars.mustRunAfter cleanPackageDir
827 dependsOn cleanPackageDir
830 outputs.dir("${jalviewDir}/${packageDir}")
834 dependsOn cleanPackageDir
840 group = "distribution"
844 from ("${jalviewDir}/${libDistDir}") {
848 attributes 'Implementation-Version': JALVIEW_VERSION
850 mainClassName = shadowJarMainClass
852 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
856 task getdownWebsite() {
857 group = "distribution"
858 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
863 def getdownWebsiteResourceFilenames = []
864 def getdownTextString = ""
865 def getdownResourceDir = project.ext.getdownResourceDir
866 def getdownAppDir = project.ext.getdownAppDir
867 def getdownResourceFilenames = []
870 // clean the getdown website and files dir before creating getdown folders
871 delete project.ext.getdownWebsiteDir
872 delete project.ext.getdownFilesDir
876 rename(buildPropertiesFile, getdown_build_properties)
877 into project.ext.getdownAppDir
879 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
881 // go through properties looking for getdown_txt_...
882 def props = project.properties.sort { it.key }
883 if (getdown_alt_java_min_version.length() > 0) {
884 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
886 if (getdown_alt_java_max_version.length() > 0) {
887 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
889 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
891 props.put("getdown_txt_appbase", getdown_app_base)
892 props.each{ prop, val ->
893 if (prop.startsWith("getdown_txt_") && val != null) {
894 if (prop.startsWith("getdown_txt_multi_")) {
895 def key = prop.substring(18)
896 val.split(",").each{ v ->
897 def line = "${key} = ${v}\n"
898 getdownTextString += line
901 // file values rationalised
902 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
904 if (val.indexOf('/') == 0) {
907 } else if (val.indexOf('/') > 0) {
908 // relative path (relative to jalviewDir)
909 r = file( "${jalviewDir}/${val}" )
912 val = "${getdown_resource_dir}/" + r.getName()
913 getdownWebsiteResourceFilenames += val
914 getdownResourceFilenames += r.getPath()
917 if (! prop.startsWith("getdown_txt_resource")) {
918 def line = prop.substring(12) + " = ${val}\n"
919 getdownTextString += line
925 getdownWebsiteResourceFilenames.each{ filename ->
926 getdownTextString += "resource = ${filename}\n"
928 getdownResourceFilenames.each{ filename ->
931 into project.ext.getdownResourceDir
936 fileTree(file(packageDir)).each{ f ->
937 if (f.isDirectory()) {
938 def files = fileTree(dir: f, include: ["*"]).getFiles()
940 } else if (f.exists()) {
944 codeFiles.sort().each{f ->
945 def name = f.getName()
946 def line = "code = ${getdown_app_dir}/${name}\n"
947 getdownTextString += line
950 into project.ext.getdownAppDir
954 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
956 if (JAVA_VERSION.equals("11")) {
957 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
958 j11libFiles.sort().each{f ->
959 def name = f.getName()
960 def line = "code = ${getdown_j11lib_dir}/${name}\n"
961 getdownTextString += line
964 into project.ext.getdownJ11libDir
970 // 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.
971 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
972 getdownTextString += "resource = ${getdown_launcher_new}\n"
973 getdownTextString += "class = ${mainClass}\n"
975 def getdown_txt = file("${project.ext.getdownWebsiteDir}/getdown.txt")
976 getdown_txt.write(getdownTextString)
978 def launch_jvl = file("${project.ext.getdownWebsiteDir}/${getdown_launch_jvl}")
979 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
983 rename(file(getdownLauncher).getName(), getdown_launcher_new)
984 into project.ext.getdownWebsiteDir
989 if (file(getdownLauncher).getName() != getdown_launcher) {
990 rename(file(getdownLauncher).getName(), getdown_launcher)
992 into project.ext.getdownWebsiteDir
995 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
999 from "${getdownWebsiteDir}/${getdown_build_properties}"
1000 if (file(getdownLauncher).getName() != getdown_launcher) {
1001 rename(file(getdownLauncher).getName(), getdown_launcher)
1003 into getdownInstallDir
1007 from getdownInstallDir
1008 into getdownFilesInstallDir
1015 from getdownLauncher
1016 from "${getdownWebsiteDir}/${getdown_build_properties}"
1017 if (file(getdownLauncher).getName() != getdown_launcher) {
1018 rename(file(getdownLauncher).getName(), getdown_launcher)
1020 into getdownFilesDir
1024 from getdownResourceDir
1025 into "${project.ext.getdownFilesDir}/${getdown_resource_dir}"
1030 inputs.dir("${jalviewDir}/${packageDir}")
1032 outputs.dir(project.ext.getdownWebsiteDir)
1033 outputs.dir(project.ext.getdownFilesDir)
1036 task getdownDigest(type: JavaExec) {
1037 group = "distribution"
1038 description = "Digest the getdown website folder"
1039 dependsOn getdownWebsite
1041 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1043 main = "com.threerings.getdown.tools.Digester"
1044 args project.ext.getdownWebsiteDir
1045 inputs.dir(project.ext.getdownWebsiteDir)
1046 outputs.file("${project.ext.getdownWebsiteDir}/digest2.txt")
1050 group = "distribution"
1051 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1052 dependsOn getdownDigest
1054 if (reportRsyncCommand) {
1055 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1056 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1057 println "LIKELY RSYNC COMMAND:"
1058 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1059 if (RUNRSYNC == "true") {
1061 commandLine "mkdir", "-p", toDir
1064 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1073 delete project.ext.getdownWebsiteDir
1074 delete project.ext.getdownFilesDir
1079 def install4jHomeDir = "/opt/install4j"
1080 def hostname = "hostname".execute().text.trim()
1081 if (hostname.equals("jv-bamboo")) {
1082 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1083 } else if (OperatingSystem.current().isMacOsX()) {
1084 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1085 if (! file(install4jHomeDir).exists()) {
1086 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1088 } else if (OperatingSystem.current().isLinux()) {
1089 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1091 installDir = file(install4jHomeDir)
1092 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1093 if (install4jFaster.equals("true")) {
1101 def windowsJavaVMDir
1102 def windowsJavaVMTgz
1103 def install4jDir = "${jalviewDir}/${install4jResourceDir}"
1104 def install4jConfFile = "jalview-installers-java${JAVA_VERSION}.install4j"
1105 install4jConf = "${install4jDir}/${install4jConfFile}"
1107 task copyInstall4jTemplate(type: Copy) {
1108 macosJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre"
1109 macosJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz"
1110 windowsJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre"
1111 windowsJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz"
1112 from (install4jDir) {
1113 include install4jTemplate
1114 rename (install4jTemplate, install4jConfFile)
1115 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1116 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1118 'JAVA_VERSION': JAVA_VERSION,
1119 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1120 'VERSION': JALVIEW_VERSION,
1121 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1122 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1123 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1124 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1125 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1126 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1127 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1128 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1129 'GETDOWN_DIST_DIR': getdown_app_dir,
1130 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1131 'GETDOWN_INSTALL_DIR': getdown_install_dir
1134 if (OSX_KEYPASS=="") {
1135 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1136 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1140 outputs.files(install4jConf)
1143 // include file associations in installer
1144 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1148 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1149 replace: installerFileAssociationsXml,
1153 // include uninstaller applescript app files in dmg
1154 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1158 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1159 replace: installerDMGUninstallerXml,
1166 task installers(type: com.install4j.gradle.Install4jTask) {
1167 group = "distribution"
1168 description = "Create the install4j installers"
1170 dependsOn copyInstall4jTemplate
1171 projectFile = file(install4jConf)
1172 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1173 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1174 buildSelected = true
1177 macKeystorePassword=OSX_KEYPASS
1181 println("Using projectFile "+projectFile)
1184 inputs.dir(project.ext.getdownWebsiteDir)
1185 inputs.file(install4jConf)
1186 inputs.dir(macosJavaVMDir)
1187 inputs.dir(windowsJavaVMDir)
1188 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1193 delete install4jConf
1197 task sourceDist (type: Tar) {
1199 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1200 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1201 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1203 archiveFileName = outputFileName
1204 } catch (Exception e) {
1205 archiveName = outputFileName
1208 compression Compression.GZIP
1212 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1217 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1219 ,"utils/InstallAnywhere"]
1220 def PROCESS_FILES=[ "AUTHORS",
1228 "THIRDPARTYLIBS","TESTNG",
1230 "gradle.properties",
1241 exclude (EXCLUDE_FILES)
1242 include (PROCESS_FILES)
1243 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1246 exclude (EXCLUDE_FILES)
1247 exclude (PROCESS_FILES)
1248 exclude ("appletlib")
1249 exclude ("**/*locales")
1250 exclude ("*locales/**")
1251 exclude ("utils/InstallAnywhere")
1253 exclude (getdown_files_dir)
1254 exclude (getdown_website_dir)
1256 // exluding these as not using jars as modules yet
1257 exclude ("${j11modDir}/**/*.jar")
1259 // from (jalviewDir) {
1260 // // explicit includes for stuff that seemed to not get included
1261 // include(fileTree("test/**/*."))
1262 // exclude(EXCLUDE_FILES)
1263 // exclude(PROCESS_FILES)
1269 dependsOn pubhtmlhelp
1271 inputs.dir("${classes}/${helpDir}")
1272 outputs.dir("${helpOutputDir}")
1275 def jalviewjsBuildDir
1276 def jalviewjsSiteDir
1277 def jalviewjsTransferSiteDir
1278 task jalviewjsSitePath {
1279 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1280 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1281 jalviewjsSiteDir = "${jalviewjsBuildDir}/${jalviewjs_site_dir}"
1282 jalviewjsTransferSiteDir = "${jalviewjsBuildDir}/tmp/site"
1285 def eclipseWorkspace
1286 task jalviewjsSetEclipseWorkspace {
1287 def propKey = "jalviewjs_eclipse_workspace"
1289 if (project.hasProperty(propKey)) {
1290 propVal = project.getProperty(propKey)
1291 if (propVal.startsWith("~/")) {
1292 propVal = System.getProperty("user.home") + propVal.substring(1)
1295 def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1296 def propsFile = file(propsFileName)
1297 def eclipseWsDir = propVal
1298 def props = new Properties()
1300 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
1301 def ins = new FileInputStream(propsFileName)
1304 if (props.getProperty(propKey, null) != null) {
1305 eclipseWsDir = props.getProperty(propKey)
1309 def writeProps = false
1310 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1311 def tempDir = File.createTempDir()
1312 eclipseWsDir = tempDir.getAbsolutePath()
1315 eclipseWorkspace = file(eclipseWsDir)
1319 props.setProperty(propKey, eclipseWsDir)
1320 propsFile.parentFile.mkdirs()
1321 def bytes = new ByteArrayOutputStream()
1322 props.store(bytes, null)
1323 def propertiesString = bytes.toString()
1324 propsFile.text = propertiesString
1327 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1330 inputs.property(propKey, eclipseWsDir)
1331 outputs.file(propsFileName)
1337 def eclipseDebug = false
1338 def eclipseVersionSuffix = ""
1339 task jalviewjsEclipsePaths {
1342 def eclipseRoot = jalviewjs_eclipse_root
1343 if (eclipseRoot.startsWith("~/")) {
1344 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1346 if (OperatingSystem.current().isMacOsX()) {
1347 eclipseRoot += "/Eclipse.app"
1348 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1349 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1350 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1351 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1352 eclipseRoot += "/eclipse"
1354 eclipseBinary = "${eclipseRoot}/eclipse"
1355 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1356 } else { // linux or unix
1357 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1358 eclipseRoot += "/eclipse"
1360 eclipseBinary = "${eclipseRoot}/eclipse"
1361 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1364 eclipseVersion = "4.12" // default
1365 def assumedVersion = true
1366 if (file(eclipseProduct).exists()) {
1367 def fis = new FileInputStream(eclipseProduct)
1368 def props = new Properties()
1370 eclipseVersion = props.getProperty("version")
1372 assumedVersion = false
1375 String[] v = eclipseVersion.split("\\.")
1376 def v0 = Integer.valueOf(v[0])
1377 def v1 = Integer.valueOf(v[1])
1378 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1379 eclipseVersionSuffix = "_4.12"
1381 eclipseVersionSuffix = "_4.13"
1386 def propKey = "eclipse_debug"
1387 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1390 if (!assumedVersion) {
1391 println("ECLIPSE VERSION=${eclipseVersion}")
1397 dependsOn eclipseProject
1398 dependsOn eclipseClasspath
1399 dependsOn eclipseJdt
1402 /* using the Copy task below
1403 task OLDjalviewjsEclipseCopyDropins {
1404 dependsOn jalviewjsEclipsePaths
1405 dependsOn jalviewjsCleanEclipse
1406 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1407 inputFiles += file(jalviewjs_j2s_plugin)
1408 def outputDir = "${buildDir}/jalviewjs
1410 inputs.files inputFiles
1411 inputFiles.each { file ->
1412 outputs.file("${outputDir}/${file.name}")
1416 inputFiles.each { file ->
1426 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1427 task jalviewjsEclipseCopyDropins(type: Copy) {
1428 dependsOn jalviewjsEclipsePaths
1430 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1431 inputFiles += file("${jalviewDir}/${jalviewjs_j2s_plugin}")
1432 def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
1438 // this eclipse -clean doesn't actually work
1439 task jalviewjsCleanEclipse(type: Exec) {
1440 dependsOn eclipseSetup
1441 dependsOn jalviewjsEclipsePaths
1442 dependsOn jalviewjsEclipseCopyDropins
1444 executable(eclipseBinary)
1445 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
1451 def inputString = """exit
1454 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
1455 standardInput = inputByteStream
1457 /* not really working yet
1458 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
1461 task jalviewjsUnzipFiles {
1462 dependsOn jalviewjsSitePath
1464 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
1465 zipFiles += "${jalviewDir}/${jalviewjs_swingjs_zip}"
1468 zipFiles.each { file_zip ->
1470 from zipTree(file_zip)
1471 into "${jalviewDir}/${jalviewjsSiteDir}"
1476 inputs.files zipFiles
1477 outputs.dir "${jalviewDir}/${jalviewjsSiteDir}"
1480 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1482 description "Create the .j2s file from the j2s.* properties"
1484 dependsOn jalviewjsSitePath
1486 outputFile ("${jalviewDir}/${jalviewjs_j2s_settings}")
1487 def j2s_props = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1488 def siteDirProperty = "j2s.site.directory"
1489 def setSiteDir = false
1490 j2s_props.each { prop, val ->
1492 if (prop == siteDirProperty) {
1493 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1494 val = "${jalviewDir}/${jalviewjsTransferSiteDir}/${val}"
1500 if (!setSiteDir) { // default site location, don't override specifically set property
1501 property(siteDirProperty,"${jalviewDir}/${jalviewjsTransferSiteDir}")
1504 inputs.properties(j2s_props)
1505 outputs.file(outputFile)
1508 task jalviewjsEclipseSetup {
1509 dependsOn jalviewjsEclipseCopyDropins
1510 dependsOn jalviewjsSetEclipseWorkspace
1511 dependsOn jalviewjsCreateJ2sSettings
1514 task jalviewjsSyncResources (type: Sync) {
1515 dependsOn jalviewjsSitePath
1516 def inputFiles = fileTree(dir: "${jalviewDir}/${resourceDir}")
1517 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1521 def outputFiles = []
1522 rename { filename ->
1523 outputFiles += "${outputDir}/${filename}"
1529 outputs.files outputFiles
1530 inputs.files inputFiles
1533 task jalviewjsSyncSiteResources (type: Sync) {
1534 dependsOn jalviewjsSitePath
1535 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
1536 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1540 def outputFiles = []
1541 rename { filename ->
1542 outputFiles += "${outputDir}/${filename}"
1548 outputs.files outputFiles
1549 inputs.files inputFiles
1552 task jalviewjsProjectImport(type: Exec) {
1553 dependsOn eclipseSetup
1554 dependsOn jalviewjsEclipsePaths
1555 dependsOn jalviewjsEclipseSetup
1557 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1558 executable(eclipseBinary)
1559 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1563 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1565 inputs.file("${jalviewDir}/.project")
1566 outputs.upToDateWhen { file(projdir).exists() }
1569 task jalviewjsTranspile(type: Exec) {
1570 dependsOn jalviewjsEclipseSetup
1571 dependsOn jalviewjsProjectImport
1572 dependsOn jalviewjsEclipsePaths
1574 executable(eclipseBinary)
1575 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
1579 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1584 stdout = new ByteArrayOutputStream()
1585 stderr = new ByteArrayOutputStream()
1587 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1588 def logOutFile = file(logOutFileName)
1589 logOutFile.createNewFile()
1590 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
1591 BINARY: ${eclipseBinary}
1592 VERSION: ${eclipseVersion}
1593 WORKSPACE: ${eclipseWorkspace}
1594 DEBUG: ${eclipseDebug}
1597 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1598 //def logErrFileName = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1599 //def logErrFile = file(logFileName)
1600 //logErrFile.createNewFile()
1601 //def logErrFOS = new FileErrputStream(logErrFile, false)
1602 // combine stdout and stderr
1603 def logErrFOS = logOutFOS
1605 if (jalviewjs_j2s_to_console.equals("true")) {
1606 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1607 new org.apache.tools.ant.util.TeeOutputStream(
1611 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1612 new org.apache.tools.ant.util.TeeOutputStream(
1617 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1620 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1627 if (stdout.toString().contains("Error processing ")) {
1628 // j2s did not complete transpile
1629 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1633 inputs.dir("${jalviewDir}/${sourceDir}")
1634 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteDir}")
1635 outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteDir}${jalviewjs_server_resource}").exists() } )
1638 task jalviewjsCopyTransferSite(type: Copy) {
1639 dependsOn jalviewjsTranspile
1640 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1641 into "${jalviewDir}/${jalviewjsSiteDir}"
1644 // this Sync version is used by buildship to keep the website automatically up to date when a file changes
1645 task jalviewjsSyncTransferSite(type: Sync) {
1646 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1648 into "${jalviewDir}/${jalviewjsSiteDir}"
1654 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1655 jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSite
1656 jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSite
1658 jalviewjsUnzipFiles.mustRunAfter jalviewjsSyncTransferSite
1659 jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSite
1660 jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSite
1662 task jalviewjsPrepareSite {
1664 description "Prepares the website folder including unzipping files and copying resources"
1665 dependsOn jalviewjsSitePath
1666 dependsOn jalviewjsUnzipFiles
1667 dependsOn jalviewjsSyncResources
1668 dependsOn jalviewjsSyncSiteResources
1671 task jalviewjsBuildSite {
1673 description "Builds the whole website including transpiled code"
1674 dependsOn jalviewjsCopyTransferSite
1675 dependsOn jalviewjsPrepareSite
1678 task cleanJalviewjsSite {
1680 delete "${jalviewDir}/${jalviewjsTransferSiteDir}"
1681 delete "${jalviewDir}/${jalviewjsSiteDir}"
1685 task jalviewjsSiteTar(type: Tar) {
1687 description "Creates a tar.gz file for the website"
1688 dependsOn jalviewjsBuildSite
1689 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1691 archiveFileName = outputFilename
1692 } catch (Exception e) {
1693 archiveName = outputFilename
1696 compression Compression.GZIP
1698 from "${jalviewDir}/${jalviewjsSiteDir}"
1699 into jalviewjs_site_dir // this is inside the tar file
1701 inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
1704 task jalviewjsServer {
1706 def filename = "jalviewjsTest.html"
1707 description "Starts a webserver on localhost to test the website. See ${filename} to access local site on most recently used port."
1708 dependsOn jalviewjsSitePath
1709 def htmlFile = "${jalviewDirAbsolutePath}/${filename}"
1712 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1713 def port = Integer.valueOf(jalviewjs_server_port)
1717 while(port < start+1000 && !running) {
1719 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
1720 def jalviewjsServer = factory.start(doc_root, port)
1722 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1723 println("SERVER STARTED with document root ${doc_root}.")
1724 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1725 println("For debug: "+url+"?j2sdebug")
1727 file(htmlFile).text = """
1728 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1729 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1732 } catch (Exception e) {
1739 outputs.file(htmlFile)
1740 outputs.upToDateWhen({false})
1743 task cleanJalviewjsAll {
1745 description "Delete all configuration and build artifacts to do with JalviewJS build"
1746 dependsOn cleanJalviewjsSite
1747 dependsOn jalviewjsEclipsePaths
1750 delete "${jalviewDir}/${jalviewjsBuildDir}"
1751 delete "${jalviewDir}/${eclipse_bin_dir}"
1752 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
1753 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1755 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
1758 outputs.upToDateWhen( { false } )
1763 description "Build the site"
1764 dependsOn jalviewjsBuildSite
1768 task jalviewjsIDE_CopyTransferSite(type: Copy) {
1769 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1770 into "${jalviewDir}/${jalviewjsSiteDir}"
1773 task jalviewjsIDE_j2s {
1774 group "00 JalviewJS in Eclipse"
1775 description "Creates the .j2s file"
1776 dependsOn jalviewjsCreateJ2sSettings
1779 task jalviewjsIDE_AssembleSite {
1780 group "00 JalviewJS in Eclipse"
1781 description "Assembles the Eclipse transpiled site and unzips supporting zipfiles"
1782 dependsOn jalviewjsIDE_CopyTransferSite
1783 dependsOn jalviewjsPrepareSite
1786 task jalviewjsIDE_SiteClean {
1787 group "00 JalviewJS in Eclipse"
1788 description "Deletes the Eclipse transpiled site"
1789 dependsOn cleanJalviewjsSite
1792 task jalviewjsIDE_Server {
1793 group "00 JalviewJS in Eclipse"
1794 description "Starts a webserver on localhost to test the website"
1795 dependsOn jalviewjsServer
1798 // buildship runs this at import
1799 task eclipseSynchronizationTask {
1800 dependsOn eclipseSetup
1801 dependsOn jalviewjsIDE_j2s
1804 // buildship runs this at build time
1805 task eclipseAutoBuildTask {
1806 dependsOn jalviewjsSyncTransferSite
1807 dependsOn jalviewjsPrepareSite