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'
32 compile 'org.apache.commons:commons-compress:1.18'
35 mainClassName = launcherClass
36 def cloverInstrDir = file("$buildDir/$cloverSourcesInstrDir")
37 def classes = "$jalviewDir/$classesDir"
39 if (clover.equals("true")) {
41 classes = "$buildDir/$cloverClassesDir"
44 classes = "$jalviewDir/$classesDir"
47 // configure classpath/args for j8/j11 compilation
49 def jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
52 def compile_source_compatibility
53 def compile_target_compatibility
56 getdownWebsiteDir = "${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}"
58 reportRsyncCmd = false
60 buildProperties = buildPropertiesFile
61 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}"
65 // TODO: get bamboo build artifact URL for getdown artifacts
66 getdown_channel_base = bamboo_channelbase
67 getdown_channel_name = "${bamboo_planKey}/${JAVA_VERSION}"
68 getdown_app_base = "${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}"
69 getdown_app_dir = getdown_app_dir_alt
70 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
74 getdown_channel_name = CHANNEL.toLowerCase()
75 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
76 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
77 getdown_app_dir = getdown_app_dir_release
78 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
79 reportRsyncCommand = true
83 getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
84 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
85 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
86 getdown_app_dir = getdown_app_dir_alt
87 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
88 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
91 packageDir = "${ARCHIVEDIR}/${packageDir}"
92 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
95 reportRsyncCommand = true
99 getdown_channel_name = "archive/${JALVIEW_VERSION}"
100 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
101 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
102 getdown_app_dir = getdown_app_dir_alt
103 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
104 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
107 packageDir = "${ARCHIVEDIR}/${packageDir}"
108 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
111 reportRsyncCommand = true
112 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
116 getdown_channel_name = CHANNEL.toLowerCase()
117 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
118 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
119 getdown_app_dir = getdown_app_dir_alt
120 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
121 reportRsyncCommand = true
125 getdown_channel_name = CHANNEL.toLowerCase()
126 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
127 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
128 getdown_app_dir = getdown_app_dir_alt
129 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
130 reportRsyncCommand = true
133 case ~/^SCRATCH(|-[-\w]*)$/:
134 getdown_channel_name = CHANNEL
135 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
136 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
137 getdown_app_dir = getdown_app_dir_alt
138 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
139 reportRsyncCommand = true
143 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
144 getdown_app_dir = getdown_app_dir_alt
145 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
146 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
149 default: // something wrong specified
150 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
156 getdownAppDir = "${getdownWebsiteDir}/${getdown_app_dir}"
157 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
158 getdownResourceDir = "${getdownWebsiteDir}/${getdown_resource_dir}"
159 getdownInstallDir = "${getdownWebsiteDir}/${getdown_install_dir}"
160 getdownFilesDir = "${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/"
161 getdownFilesInstallDir = "${getdownFilesDir}/${getdown_install_dir}"
162 /* compile without modules -- using classpath libraries
163 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
164 modules_runtimeClasspath = modules_compileClasspath
169 println("Using a ${CHANNEL} profile. appbase=${getdown_app_base}")
172 def JAVA_INTEGER_VERSION
173 def additional_compiler_args = []
174 // these are getdown.txt properties defined dependent on the JAVA_VERSION
175 def getdown_alt_java_min_version
176 def getdown_alt_java_max_version
177 // this property is assigned below and expanded to multiple lines in the getdown task
178 def getdown_alt_multi_java_location
179 // this property is for the Java library used in eclipse
180 def eclipse_java_runtime_name
181 if (JAVA_VERSION.equals("1.8")) {
182 JAVA_INTEGER_VERSION = "8"
185 libDistDir = j8libDir
186 compile_source_compatibility = 1.8
187 compile_target_compatibility = 1.8
188 getdown_alt_java_min_version = getdown_alt_java8_min_version
189 getdown_alt_java_max_version = getdown_alt_java8_max_version
190 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
191 eclipse_java_runtime_name = "JavaSE-1.8"
192 } else if (JAVA_VERSION.equals("11")) {
193 JAVA_INTEGER_VERSION = "11"
195 libDistDir = j11libDir
196 compile_source_compatibility = 11
197 compile_target_compatibility = 11
198 getdown_alt_java_min_version = getdown_alt_java11_min_version
199 getdown_alt_java_max_version = getdown_alt_java11_max_version
200 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
201 eclipse_java_runtime_name = "JavaSE-11"
202 /* compile without modules -- using classpath libraries
203 additional_compiler_args += [
204 '--module-path', ext.modules_compileClasspath.asPath,
205 '--add-modules', j11modules
208 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
209 JAVA_INTEGER_VERSION = JAVA_VERSION
211 libDistDir = j11libDir
212 compile_source_compatibility = JAVA_VERSION
213 compile_target_compatibility = JAVA_VERSION
214 getdown_alt_java_min_version = getdown_alt_java11_min_version
215 getdown_alt_java_max_version = getdown_alt_java11_max_version
216 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
217 eclipse_java_runtime_name = "JavaSE-11"
218 /* compile without modules -- using classpath libraries
219 additional_compiler_args += [
220 '--module-path', ext.modules_compileClasspath.asPath,
221 '--add-modules', j11modules
225 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
232 srcDirs "${jalviewDir}/${sourceDir}"
233 outputDir = file("${classes}")
237 srcDirs "${jalviewDir}/${resourceDir}"
240 jar.destinationDir = file("${jalviewDir}/${packageDir}")
242 compileClasspath = files(sourceSets.main.java.outputDir)
243 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
245 runtimeClasspath = compileClasspath
250 srcDirs = [ cloverInstrDir ]
251 outputDir = file("${buildDir}/${cloverClassesDir}")
255 srcDirs = sourceSets.main.resources.srcDirs
257 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
258 compileClasspath += files(sourceSets.main.java.outputDir)
259 compileClasspath += sourceSets.main.compileClasspath
260 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
261 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
263 runtimeClasspath = compileClasspath
268 srcDirs "${jalviewDir}/${testSourceDir}"
269 outputDir = file("${jalviewDir}/${testOutputDir}")
273 srcDirs = sourceSets.main.resources.srcDirs
276 compileClasspath = files( sourceSets.test.java.outputDir )
279 compileClasspath += sourceSets.clover.compileClasspath
281 compileClasspath += files(sourceSets.main.java.outputDir)
284 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
285 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
286 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
288 runtimeClasspath = compileClasspath
295 cloverCompile 'org.openclover:clover:4.3.1'
296 testCompile 'org.openclover:clover:4.3.1'
302 cloverRuntime.extendsFrom cloverCompile
307 name = eclipse_project_name
309 natures 'org.eclipse.jdt.core.javanature',
310 'org.eclipse.jdt.groovy.core.groovyNature',
311 'org.eclipse.buildship.core.gradleprojectnature'
313 buildCommand 'org.eclipse.jdt.core.javabuilder'
314 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
318 //defaultOutputDir = sourceSets.main.java.outputDir
321 if (it.isCanBeResolved()) {
326 minusConfigurations += removeThese
327 plusConfigurations = [ ]
331 def removeTheseToo = []
332 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
333 cp.entries.each { entry ->
334 if (entry.kind == 'src') {
335 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == sourceDir || entry.path == testSourceDir)) {
336 removeTheseToo += entry
338 alreadyAddedSrcPath.putAt(entry.path, true)
342 cp.entries.removeAll(removeTheseToo)
344 if (file("${jalviewDir}/${eclipse_bin_dir}/main").isDirectory()) {
345 cp.entries += new Output("${eclipse_bin_dir}/main")
347 if (file(helpParentDir).isDirectory()) {
348 cp.entries += new Library(fileReference(helpParentDir))
350 if (file(resourceDir).isDirectory()) {
351 cp.entries += new Library(fileReference(resourceDir))
354 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
356 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
357 //don't want to add outputDir as eclipse is using its own output dir in bin/main
358 if (it.isDirectory() || ! it.exists()) {
359 // don't add dirs to classpath
362 def itPath = it.toString()
363 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
364 // make relative path
365 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
367 if (alreadyAddedLibPath.get(itPath)) {
368 //println("Not adding duplicate entry "+itPath)
370 //println("Adding entry "+itPath)
371 cp.entries += new Library(fileReference(itPath))
372 alreadyAddedLibPath.put(itPath, true)
376 //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
377 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
378 //no longer 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
381 return false // groovy "break" in .each closure
383 def itPath = it.toString()
384 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
385 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
387 if (alreadyAddedLibPath.get(itPath)) {
390 def lib = new Library(fileReference(itPath))
391 lib.entryAttributes["test"] = "true"
393 alreadyAddedLibPath.put(itPath, true)
401 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
406 // for the IDE, use java 11 compatibility
407 sourceCompatibility = compile_source_compatibility
408 targetCompatibility = compile_target_compatibility
409 javaRuntimeName = eclipse_java_runtime_name
411 // add in jalview project specific properties/preferences into eclipse core preferences
413 withProperties { props ->
414 def jalview_prefs = new Properties()
415 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
416 jalview_prefs.load(ins)
418 jalview_prefs.forEach { t, v ->
419 if (props.getAt(t) == null) {
431 // only instrument source, we build test classes as normal
432 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
433 outputs.dir cloverInstrDir
436 delete cloverInstrDir
437 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
438 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
439 argsList.addAll(inputs.files.files.collect({ file ->
442 String[] args = argsList.toArray()
443 println("About to instrument "+args.length +" files")
444 com.atlassian.clover.CloverInstr.mainImpl(args)
450 group = "Verification"
451 description = "Createst the Clover report"
452 inputs.dir "${buildDir}/clover"
453 outputs.dir "${reportsDir}/clover"
455 file("${buildDir}/clover/clover.db").exists()
458 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
459 "-o", "${reportsDir}/clover"]
460 String[] args = argsList.toArray()
461 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
463 // and generate ${reportsDir}/clover/clover.xml
464 args = ["--initstring", "${buildDir}/clover/clover.db",
465 "-o", "${reportsDir}/clover/clover.xml"].toArray()
466 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
476 sourceCompatibility = compile_source_compatibility
477 targetCompatibility = compile_target_compatibility
478 options.compilerArgs = additional_compiler_args
479 print ("Setting target compatibility to "+targetCompatibility+"\n")
486 dependsOn compileCloverJava
487 classpath += configurations.cloverRuntime
489 classpath += sourceSets.main.runtimeClasspath
492 sourceCompatibility = compile_source_compatibility
493 targetCompatibility = compile_target_compatibility
494 options.compilerArgs = additional_compiler_args
495 print ("Setting target compatibility to "+targetCompatibility+"\n")
503 sourceCompatibility = compile_source_compatibility
504 targetCompatibility = compile_target_compatibility
505 options.compilerArgs += additional_compiler_args
506 print ("Setting target compatibility to "+targetCompatibility+"\n")
508 classpath += configurations.cloverRuntime
513 delete sourceSets.main.java.outputDir
519 delete sourceSets.test.java.outputDir
520 delete cloverInstrDir
524 // format is a string like date.format("dd MMMM yyyy")
525 def getDate(format) {
526 def date = new Date()
527 return date.format(format)
531 def hashStdOut = new ByteArrayOutputStream()
533 commandLine "git", "rev-parse", "--short", "HEAD"
534 standardOutput = hashStdOut
538 def branchStdOut = new ByteArrayOutputStream()
540 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
541 standardOutput = branchStdOut
545 project.ext.gitHash = hashStdOut.toString().trim()
546 project.ext.gitBranch = branchStdOut.toString().trim()
548 outputs.upToDateWhen { false }
551 task createBuildProperties(type: WriteProperties) {
553 inputs.dir("${jalviewDir}/${sourceDir}")
554 inputs.dir("${classes}")
555 inputs.dir("${jalviewDir}/${resourceDir}")
556 outputFile (buildProperties)
557 // taking time specific comment out to allow better incremental builds
558 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
559 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
560 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
561 property "VERSION", JALVIEW_VERSION
562 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
563 outputs.file(outputFile)
566 def buildingHTML = "${jalviewDir}/${docDir}/building.html"
567 task cleanBuildingHTML(type: Delete) {
573 task convertBuildingMD(type: Exec) {
574 dependsOn cleanBuildingHTML
575 def buildingMD = "${jalviewDir}/${docDir}/building.md"
576 def css = "${jalviewDir}/${docDir}/github.css"
579 pandoc_exec.split(",").each {
580 if (file(it.trim()).exists()) {
586 def hostname = "hostname".execute().text.trim()
587 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
588 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
592 if (pandoc != null && file(pandoc).exists()) {
593 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
595 println("Cannot find pandoc. Skipping convert building.md to HTML")
596 throw new StopExecutionException()
602 inputs.file(buildingMD)
604 outputs.file(buildingHTML)
613 task syncDocs(type: Sync) {
614 dependsOn convertBuildingMD
615 def syncDir = "${classes}/${docDir}"
616 from fileTree("${jalviewDir}/${docDir}")
621 def helpFile = "${classes}/${helpDir}/help.jhm"
623 task copyHelp(type: Copy) {
624 def inputDir = "${jalviewDir}/${helpParentDir}/${helpDir}"
625 def outputDir = "${classes}/${helpDir}"
630 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
640 outputs.files(helpFile)
641 outputs.dir(outputDir)
644 task syncLib(type: Sync) {
645 def syncDir = "${classes}/${libDistDir}"
646 from fileTree("${jalviewDir}/${libDistDir}")
650 task syncResources(type: Sync) {
651 from "${jalviewDir}/${resourceDir}"
661 dependsOn syncResources
667 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
670 dependsOn compileJava
672 dependsOn cloverInstr
676 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
680 includeGroups testngGroups
682 useDefaultListeners=true
685 workingDir = jalviewDir
686 //systemProperties 'clover.jar' System.properties.clover.jar
687 sourceCompatibility = compile_source_compatibility
688 targetCompatibility = compile_target_compatibility
689 jvmArgs += additional_compiler_args
693 task buildIndices(type: JavaExec) {
695 classpath = sourceSets.main.compileClasspath
696 main = "com.sun.java.help.search.Indexer"
697 workingDir = "${classes}/${helpDir}"
700 inputs.dir("${workingDir}/${argDir}")
702 outputs.dir("${classes}/doc")
703 outputs.dir("${classes}/help")
704 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
705 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
706 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
707 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
708 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
709 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
712 task compileLinkCheck(type: JavaCompile) {
714 classpath = files("${jalviewDir}/${utilsDir}")
715 destinationDir = file("${jalviewDir}/${utilsDir}")
716 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
718 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
719 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
720 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
721 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
724 def helplinkscheckertouchfile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.touch")
725 task linkCheck(type: JavaExec) {
726 dependsOn prepare, compileLinkCheck
727 classpath = files("${jalviewDir}/${utilsDir}")
728 main = "HelpLinksChecker"
729 workingDir = jalviewDir
730 def help = "${classes}/${helpDir}"
731 args = [ "${classes}/${helpDir}", "-nointernet" ]
734 helplinkscheckertouchfile.createNewFile()
737 inputs.dir("${classes}/${helpDir}")
738 outputs.file(helplinkscheckertouchfile)
741 // import the pubhtmlhelp target
742 ant.properties.basedir = "${jalviewDir}"
743 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes}/${helpDir}"
744 ant.importBuild "${utilsDir}/publishHelp.xml"
747 task cleanPackageDir(type: Delete) {
749 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
755 dependsOn buildIndices
756 dependsOn createBuildProperties
759 attributes "Main-Class": mainClass,
760 "Permissions": "all-permissions",
761 "Application-Name": "Jalview Desktop",
762 "Codebase": application_codebase
765 destinationDir = file("${jalviewDir}/${packageDir}")
766 archiveName = rootProject.name+".jar"
774 inputs.dir("${classes}")
775 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
778 task copyJars(type: Copy) {
779 from fileTree(dir: "${classes}", include: "**/*.jar").files
780 into "${jalviewDir}/${packageDir}"
783 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
784 task syncJars(type: Sync) {
785 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
786 into "${jalviewDir}/${packageDir}"
788 include jar.archiveName
794 description = "Put all required libraries in dist"
795 // order of "cleanPackageDir", "copyJars", "jar" important!
796 jar.mustRunAfter cleanPackageDir
797 syncJars.mustRunAfter cleanPackageDir
798 dependsOn cleanPackageDir
801 outputs.dir("${jalviewDir}/${packageDir}")
805 dependsOn cleanPackageDir
811 group = "distribution"
815 from ("${jalviewDir}/${libDistDir}") {
819 attributes 'Implementation-Version': JALVIEW_VERSION
821 mainClassName = shadowJarMainClass
823 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
827 task getdownWebsite() {
828 group = "distribution"
829 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
834 def getdownWebsiteResourceFilenames = []
835 def getdownTextString = ""
836 def getdownResourceDir = project.ext.getdownResourceDir
837 def getdownAppDir = project.ext.getdownAppDir
838 def getdownResourceFilenames = []
841 // clean the getdown website and files dir before creating getdown folders
842 delete project.ext.getdownWebsiteDir
843 delete project.ext.getdownFilesDir
847 rename(buildPropertiesFile, getdown_build_properties)
848 into project.ext.getdownAppDir
850 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
852 // go through properties looking for getdown_txt_...
853 def props = project.properties.sort { it.key }
854 if (getdown_alt_java_min_version.length() > 0) {
855 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
857 if (getdown_alt_java_max_version.length() > 0) {
858 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
860 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
862 props.put("getdown_txt_appbase", getdown_app_base)
863 props.each{ prop, val ->
864 if (prop.startsWith("getdown_txt_") && val != null) {
865 if (prop.startsWith("getdown_txt_multi_")) {
866 def key = prop.substring(18)
867 val.split(",").each{ v ->
868 def line = "${key} = ${v}\n"
869 getdownTextString += line
872 // file values rationalised
873 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
875 if (val.indexOf('/') == 0) {
878 } else if (val.indexOf('/') > 0) {
879 // relative path (relative to jalviewDir)
880 r = file( "${jalviewDir}/${val}" )
883 val = "${getdown_resource_dir}/" + r.getName()
884 getdownWebsiteResourceFilenames += val
885 getdownResourceFilenames += r.getPath()
888 if (! prop.startsWith("getdown_txt_resource")) {
889 def line = prop.substring(12) + " = ${val}\n"
890 getdownTextString += line
896 getdownWebsiteResourceFilenames.each{ filename ->
897 getdownTextString += "resource = ${filename}\n"
899 getdownResourceFilenames.each{ filename ->
902 into project.ext.getdownResourceDir
907 fileTree(file(packageDir)).each{ f ->
908 if (f.isDirectory()) {
909 def files = fileTree(dir: f, include: ["*"]).getFiles()
911 } else if (f.exists()) {
915 codeFiles.sort().each{f ->
916 def name = f.getName()
917 def line = "code = ${getdown_app_dir}/${name}\n"
918 getdownTextString += line
921 into project.ext.getdownAppDir
925 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
927 if (JAVA_VERSION.equals("11")) {
928 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
929 j11libFiles.sort().each{f ->
930 def name = f.getName()
931 def line = "code = ${getdown_j11lib_dir}/${name}\n"
932 getdownTextString += line
935 into project.ext.getdownJ11libDir
941 // 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.
942 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
943 getdownTextString += "resource = ${getdown_launcher_new}\n"
944 getdownTextString += "class = ${mainClass}\n"
946 def getdown_txt = file("${project.ext.getdownWebsiteDir}/getdown.txt")
947 getdown_txt.write(getdownTextString)
949 def launch_jvl = file("${project.ext.getdownWebsiteDir}/${getdown_launch_jvl}")
950 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
954 rename(file(getdownLauncher).getName(), getdown_launcher_new)
955 into project.ext.getdownWebsiteDir
960 if (file(getdownLauncher).getName() != getdown_launcher) {
961 rename(file(getdownLauncher).getName(), getdown_launcher)
963 into project.ext.getdownWebsiteDir
966 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
970 from "${getdownWebsiteDir}/${getdown_build_properties}"
971 if (file(getdownLauncher).getName() != getdown_launcher) {
972 rename(file(getdownLauncher).getName(), getdown_launcher)
974 into getdownInstallDir
978 from getdownInstallDir
979 into getdownFilesInstallDir
987 from "${getdownWebsiteDir}/${getdown_build_properties}"
988 if (file(getdownLauncher).getName() != getdown_launcher) {
989 rename(file(getdownLauncher).getName(), getdown_launcher)
995 from getdownResourceDir
996 into "${project.ext.getdownFilesDir}/${getdown_resource_dir}"
1001 inputs.dir("${jalviewDir}/${packageDir}")
1003 outputs.dir(project.ext.getdownWebsiteDir)
1004 outputs.dir(project.ext.getdownFilesDir)
1007 task getdownDigest(type: JavaExec) {
1008 group = "distribution"
1009 description = "Digest the getdown website folder"
1010 dependsOn getdownWebsite
1012 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1014 main = "com.threerings.getdown.tools.Digester"
1015 args project.ext.getdownWebsiteDir
1016 inputs.dir(project.ext.getdownWebsiteDir)
1017 outputs.file("${project.ext.getdownWebsiteDir}/digest2.txt")
1021 group = "distribution"
1022 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1023 dependsOn getdownDigest
1025 if (reportRsyncCommand) {
1026 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1027 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1028 println "LIKELY RSYNC COMMAND:"
1029 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1030 if (RUNRSYNC == "true") {
1032 commandLine "mkdir", "-p", toDir
1035 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1044 delete project.ext.getdownWebsiteDir
1045 delete project.ext.getdownFilesDir
1050 def install4jHomeDir = "/opt/install4j"
1051 def hostname = "hostname".execute().text.trim()
1052 if (hostname.equals("jv-bamboo")) {
1053 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1054 } else if (OperatingSystem.current().isMacOsX()) {
1055 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1056 if (! file(install4jHomeDir).exists()) {
1057 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1059 } else if (OperatingSystem.current().isLinux()) {
1060 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1062 installDir = file(install4jHomeDir)
1063 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1064 if (install4jFaster.equals("true")) {
1072 def windowsJavaVMDir
1073 def windowsJavaVMTgz
1074 def install4jDir = "${jalviewDir}/${install4jResourceDir}"
1075 def install4jConfFile = "jalview-installers-java${JAVA_VERSION}.install4j"
1076 install4jConf = "${install4jDir}/${install4jConfFile}"
1078 task copyInstall4jTemplate(type: Copy) {
1079 macosJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre"
1080 macosJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz"
1081 windowsJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre"
1082 windowsJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz"
1083 from (install4jDir) {
1084 include install4jTemplate
1085 rename (install4jTemplate, install4jConfFile)
1086 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1087 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1089 'JAVA_VERSION': JAVA_VERSION,
1090 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1091 'VERSION': JALVIEW_VERSION,
1092 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1093 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1094 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1095 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1096 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1097 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1098 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1099 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1100 'GETDOWN_DIST_DIR': getdown_app_dir,
1101 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1102 'GETDOWN_INSTALL_DIR': getdown_install_dir
1105 if (OSX_KEYPASS=="") {
1106 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1107 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1111 outputs.files(install4jConf)
1114 // include file associations in installer
1115 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1119 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1120 replace: installerFileAssociationsXml,
1124 // include uninstaller applescript app files in dmg
1125 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1129 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1130 replace: installerDMGUninstallerXml,
1137 task installers(type: com.install4j.gradle.Install4jTask) {
1138 group = "distribution"
1139 description = "Create the install4j installers"
1141 dependsOn copyInstall4jTemplate
1142 projectFile = file(install4jConf)
1143 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1144 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1145 buildSelected = true
1148 macKeystorePassword=OSX_KEYPASS
1152 println("Using projectFile "+projectFile)
1155 inputs.dir(project.ext.getdownWebsiteDir)
1156 inputs.file(install4jConf)
1157 inputs.dir(macosJavaVMDir)
1158 inputs.dir(windowsJavaVMDir)
1159 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1164 delete install4jConf
1168 task sourceDist (type: Tar) {
1170 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1171 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1172 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1174 archiveFileName = outputFileName
1175 } catch (Exception e) {
1176 archiveName = outputFileName
1179 compression Compression.GZIP
1183 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1188 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1190 ,"utils/InstallAnywhere"]
1191 def PROCESS_FILES=[ "AUTHORS",
1199 "THIRDPARTYLIBS","TESTNG",
1201 "gradle.properties",
1212 exclude (EXCLUDE_FILES)
1213 include (PROCESS_FILES)
1214 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1217 exclude (EXCLUDE_FILES)
1218 exclude (PROCESS_FILES)
1219 exclude ("appletlib")
1220 exclude ("**/*locales")
1221 exclude ("*locales/**")
1222 exclude ("utils/InstallAnywhere")
1224 exclude (getdown_files_dir)
1225 exclude (getdown_website_dir)
1227 // exluding these as not using jars as modules yet
1228 exclude ("${j11modDir}/**/*.jar")
1230 // from (jalviewDir) {
1231 // // explicit includes for stuff that seemed to not get included
1232 // include(fileTree("test/**/*."))
1233 // exclude(EXCLUDE_FILES)
1234 // exclude(PROCESS_FILES)
1240 dependsOn pubhtmlhelp
1242 inputs.dir("${classes}/${helpDir}")
1243 outputs.dir("${helpOutputDir}")
1246 def jalviewjsBuildDir
1247 def jalviewjsSiteDir
1248 def jalviewjsTransferSiteDir
1249 task jalviewjsSitePath {
1250 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1251 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1252 if (jalviewjs_site_dir.startsWith('/')) {
1253 jalviewjsSiteDir = jalviewjs_site_dir
1255 jalviewjsSiteDir = "${jalviewjsBuildDir}/${jalviewjs_site_dir}"
1257 jalviewjsTransferSiteDir = "${jalviewjsBuildDir}/tmp/site"
1260 def eclipseWorkspace
1261 task jalviewjsSetEclipseWorkspace {
1262 def propKey = "jalviewjs_eclipse_workspace"
1264 if (project.hasProperty(propKey)) {
1265 propVal = project.getProperty(propKey)
1267 def propsFileName = "${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1268 def eclipseWsDir = propVal
1269 def props = new Properties()
1271 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && file(propsFileName).exists()) {
1272 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${propsFileName}")
1275 if (props.getProperty(propKey, null) != null) {
1276 eclipseWsDir = props.getProperty(propKey)
1280 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1281 def tempDir = File.createTempDir()
1282 eclipseWsDir = tempDir.getAbsolutePath()
1283 props.setProperty(propKey, eclipseWsDir)
1284 def propsFile = file(propsFileName)
1285 propsFile.parentFile.mkdirs()
1286 propsFile.createNewFile() // doesn't affect existing file
1287 def outs = new FileOutputStream(propsFile, false)
1288 props.store(outs, null)
1292 eclipseWorkspace = file(eclipseWsDir)
1295 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1297 inputs.property(propKey, eclipseWsDir)
1298 outputs.file(propsFileName)
1302 def eclipseDropinsDir
1306 def eclipseDebug = false
1307 def eclipseVersionSuffix = ""
1308 task jalviewjsEclipsePaths {
1312 eclipseRoot = jalviewjs_eclipse_root
1313 if (eclipseRoot.startsWith("~")) {
1314 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1316 if (OperatingSystem.current().isMacOsX()) {
1317 eclipseRoot += "/Eclipse.app"
1318 eclipseDropinsDir = "${eclipseRoot}/Contents/Eclipse/dropins"
1319 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1320 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1321 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1322 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1323 eclipseRoot += "/eclipse"
1325 eclipseDropinsDir = "${eclipseRoot}/dropins"
1326 eclipseBinary = "${eclipseRoot}/eclipse"
1327 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1328 } else { // linux or unix
1329 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1330 eclipseRoot += "/eclipse"
1332 eclipseDropinsDir = "${eclipseRoot}/dropins"
1333 eclipseBinary = "${eclipseRoot}/eclipse"
1334 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1337 eclipseVersion = "4.12" // default
1338 def assumedVersion = true
1339 if (file(eclipseProduct).exists()) {
1340 def fis = new FileInputStream(eclipseProduct)
1341 def props = new Properties()
1343 eclipseVersion = props.getProperty("version")
1345 assumedVersion = false
1347 String[] v = eclipseVersion.split("\\.")
1348 def v0 = Integer.valueOf(v[0])
1349 def v1 = Integer.valueOf(v[1])
1350 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1351 eclipseVersionSuffix = "_4.12"
1353 eclipseVersionSuffix = "_4.13"
1356 utilsDropinsDir = "${jalviewjs_utils_dir}/${jalviewjs_eclipse_dropins_dir}${eclipseVersionSuffix}"
1357 def propKey = "eclipse_debug"
1358 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1361 if (!assumedVersion) {
1362 println("ECLIPSE_VERSION=${eclipseVersion}")
1367 task jalviewjsEclipseCopyDropins {
1368 dependsOn jalviewjsEclipsePaths
1369 def inputFiles = fileTree(dir: utilsDropinsDir, include: "*.jar")
1370 def outputDir = eclipseDropinsDir
1372 inputs.files inputFiles
1373 inputFiles.each { file ->
1374 outputs.file("${outputDir}/${file.name}")
1378 inputFiles.each { file ->
1387 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1388 task NEWjalviewjsEclipseCopyDropins(type: Copy) {
1389 dependsOn jalviewjsEclipsePaths
1390 from utilsDropinsDir
1391 into eclipseDropinsDir
1394 task jalviewjsUnzipFiles {
1395 dependsOn jalviewjsSitePath
1397 def zipFiles = fileTree(dir: "${jalviewjs_utils_dir}/${jalviewjs_libjs_dir}", include: "*.zip")
1398 zipFiles += "${jalviewjs_utils_dir}/${jalviewjs_swingjs_zip}${eclipseVersionSuffix}"
1401 zipFiles.each { file_zip ->
1403 from zipTree(file_zip)
1404 into jalviewjsSiteDir
1409 inputs.files zipFiles
1410 outputs.dir jalviewjsSiteDir
1413 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1414 dependsOn jalviewjsSitePath
1415 outputFile ("${jalviewDir}/${jalviewjs_j2s_settings}")
1416 def j2s_props = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1417 def siteDirProperty = "j2s.site.directory"
1418 def setSiteDir = false
1419 j2s_props.each { prop, val ->
1421 if (prop == siteDirProperty) {
1422 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1423 val = "${jalviewjsTransferSiteDir}/${val}"
1429 if (!setSiteDir) { // default site location, don't override specifically set property
1430 property(siteDirProperty,jalviewjsTransferSiteDir)
1433 inputs.properties(j2s_props)
1434 outputs.file(outputFile)
1437 task jalviewjsEclipseSetup {
1438 dependsOn jalviewjsEclipseCopyDropins
1439 dependsOn jalviewjsSetEclipseWorkspace
1440 dependsOn jalviewjsCreateJ2sSettings
1443 task jalviewjsCopyResources (type: Copy) {
1444 dependsOn jalviewjsSitePath
1445 def inputFiles = fileTree(dir: jalviewjs_resource_dir)
1446 def outputDir = "${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1450 def outputFiles = []
1451 rename { filename ->
1452 outputFiles += "${outputDir}/${filename}"
1455 outputs.files outputFiles
1456 inputs.files inputFiles
1459 task jalviewjsCopySiteResources (type: Copy) {
1460 dependsOn jalviewjsSitePath
1461 def inputFiles = fileTree(dir: "${jalviewjs_utils_dir}/${jalviewjs_site_resource_dir}")
1462 def outputDir = jalviewjsSiteDir
1466 def outputFiles = []
1467 rename { filename ->
1468 outputFiles += "${outputDir}/${filename}"
1471 outputs.files outputFiles
1472 inputs.files inputFiles
1475 task jalviewjsProjectImport(type: Exec) {
1476 dependsOn eclipseProject
1477 dependsOn eclipseClasspath
1478 dependsOn eclipseJdt
1479 dependsOn jalviewjsEclipsePaths
1480 dependsOn jalviewjsEclipseSetup
1482 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1483 executable(eclipseBinary)
1484 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1490 println("IMPORT ECLIPSE_DEBUG=${eclipseDebug}")
1493 inputs.file("${jalviewDir}/.project")
1494 outputs.dir(projdir)
1495 outputs.upToDateWhen { file(projdir).exists() }
1498 task jalviewjsTranspile(type: Exec) {
1499 dependsOn jalviewjsEclipseSetup
1500 dependsOn jalviewjsProjectImport
1501 dependsOn jalviewjsEclipsePaths
1503 executable(eclipseBinary)
1504 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipseBuildArg}", eclipse_project_name ])
1511 stdout = new ByteArrayOutputStream()
1512 stderr = new ByteArrayOutputStream()
1514 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1515 def logOutFile = file(logOutFileName)
1516 logOutFile.createNewFile()
1517 def logOutFOS = new FileOutputStream(logOutFile, false)
1518 //def logErrFileName = "${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1519 //def logErrFile = file(logFileName)
1520 //logErrFile.createNewFile()
1521 //def logErrFOS = new FileErrputStream(logErrFile, false)
1522 // combine stdout and stderr
1523 def logErrFOS = logOutFOS
1524 if (jalviewjs_j2s_to_console.equals("true")) {
1525 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1526 new org.apache.tools.ant.util.TeeOutputStream(
1530 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1531 new org.apache.tools.ant.util.TeeOutputStream(
1536 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1539 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1545 if (stdout.toString().contains("Error processing ")) {
1546 // j2s did not complete transpile
1547 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1552 println("TRANSPILE ECLIPSE_DEBUG=${eclipseDebug}")
1555 inputs.dir(sourceDir)
1556 outputs.dir("${eclipse_bin_dir}/main")
1557 outputs.dir(jalviewjsTransferSiteDir)
1558 outputs.upToDateWhen { file("${jalviewjsTransferSiteDir}${jalviewjs_server_resource}").exists() }
1562 task jalviewjsCopyTransferSite(type: Copy) {
1563 dependsOn jalviewjsTranspile
1564 from jalviewjsTransferSiteDir
1565 into jalviewjsSiteDir
1568 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1569 jalviewjsCopyResources.mustRunAfter jalviewjsCopyTransferSite
1570 jalviewjsCopySiteResources.mustRunAfter jalviewjsCopyTransferSite
1572 task jalviewjsPrepareSite {
1574 description "Prepares the website folder including unzipping files and copying resources"
1575 dependsOn jalviewjsSitePath
1576 dependsOn jalviewjsUnzipFiles
1577 dependsOn jalviewjsCopyResources
1578 dependsOn jalviewjsCopySiteResources
1581 task jalviewjsBuildSite {
1583 description "Builds the whole website including transpiled code"
1584 dependsOn jalviewjsCopyTransferSite
1585 dependsOn jalviewjsPrepareSite
1588 task cleanJalviewjsSite {
1590 delete jalviewjsTransferSiteDir
1591 delete jalviewjsSiteDir
1595 task jalviewjsSiteTar(type: Tar) {
1597 description "Creates a tar.gz file for the website"
1598 dependsOn jalviewjsBuildSite
1599 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1601 archiveFileName = outputFilename
1602 } catch (Exception e) {
1603 archiveName = outputFilename
1606 compression Compression.GZIP
1608 from jalviewjsSiteDir
1609 into jalviewjs_site_dir // this is inside the tar file
1611 inputs.dir(jalviewjsSiteDir)
1614 task jalviewjsServer {
1616 description "Starts a webserver on localhost to test the website"
1617 dependsOn jalviewjsSitePath
1618 def htmlFile = "${jalviewDirAbsolutePath}/jalviewjsTest.html"
1621 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1622 def port = Integer.valueOf(jalviewjs_server_port)
1626 while(port < start+1000 && !running) {
1628 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
1629 def jalviewjsServer = factory.start(doc_root, port)
1631 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1632 println("SERVER STARTED with document root ${doc_root}.")
1633 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1634 println("For debug: "+url+"?j2sdebug")
1636 file(htmlFile).text = """
1637 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1638 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1641 } catch (Exception e) {
1648 outputs.file(htmlFile)
1651 task cleanJalviewjsAll {
1653 description "Delete all configuration and build artifacts to do with JalviewJS build"
1654 dependsOn cleanJalviewjsSite
1655 dependsOn jalviewjsEclipsePaths
1658 delete jalviewjsBuildDir
1659 delete "${jalviewDir}/${eclipse_bin_dir}"
1660 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
1661 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1663 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
1669 description "Build the site"
1670 dependsOn jalviewjsBuildSite
1674 task jalviewjsIDECopyTransferSite(type: Copy) {
1675 from jalviewjsTransferSiteDir
1676 into jalviewjsSiteDir
1679 task jalviewjsIDEj2s {
1680 group "JalviewJS in Eclipse"
1681 description "Creates the .j2s file"
1682 dependsOn jalviewjsCreateJ2sSettings
1685 task jalviewjsIDEBuildSite {
1686 group "JalviewJS in Eclipse"
1687 description "Copies the Eclipse transpiled site and unzips supporting zipfiles"
1688 dependsOn jalviewjsIDECopyTransferSite
1689 dependsOn jalviewjsPrepareSite
1692 task jalviewjsIDESiteClean {
1693 group "JalviewJS in Eclipse"
1694 description "Deletes the Eclipse transpiled site"
1695 dependsOn cleanJalviewjsSite
1698 task jalviewjsIDEServer {
1699 group "JalviewJS in Eclipse"
1700 description "Starts a webserver on localhost to test the website"
1701 dependsOn jalviewjsServer