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 println("Using a "+CHANNEL+" profile. appbase="+getdown_app_base)
157 getdownAppDir = getdownWebsiteDir + '/' + getdown_app_dir
158 //getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
159 getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
160 getdownInstallDir = getdownWebsiteDir + '/' + getdown_install_dir
161 getdownFilesDir = jalviewDir + '/' + getdown_files_dir + '/' + JAVA_VERSION + '/'
162 getdownFilesInstallDir = getdownFilesDir+"/"+getdown_install_dir
163 /* compile without modules -- using classpath libraries
164 modules_compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
165 modules_runtimeClasspath = modules_compileClasspath
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 == "src" || entry.path == "test")) {
336 removeTheseToo += entry
338 alreadyAddedSrcPath.putAt(entry.path, true)
342 cp.entries.removeAll(removeTheseToo)
344 if (file(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
690 print ("Setting target compatibility to "+targetCompatibility+"\n")
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("$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("$classes").include("**/*.jar").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("$jalviewDir/$libDistDir").include("**/*.jar").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 line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
917 getdownTextString += line
920 into project.ext.getdownAppDir
924 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
926 if (JAVA_VERSION.equals("11")) {
927 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
928 j11libFiles.sort().each{f ->
929 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
930 getdownTextString += line
933 into project.ext.getdownJ11libDir
939 // 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.
940 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
941 getdownTextString += "resource = " + getdown_launcher_new + "\n"
942 getdownTextString += "class = " + mainClass + "\n"
944 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
945 getdown_txt.write(getdownTextString)
947 def launch_jvl = file(project.ext.getdownWebsiteDir + "/" + getdown_launch_jvl)
948 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
952 rename(file(getdownLauncher).getName(), getdown_launcher_new)
953 into project.ext.getdownWebsiteDir
958 if (file(getdownLauncher).getName() != getdown_launcher) {
959 rename(file(getdownLauncher).getName(), getdown_launcher)
961 into project.ext.getdownWebsiteDir
964 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
968 from getdownWebsiteDir+"/"+getdown_build_properties
969 if (file(getdownLauncher).getName() != getdown_launcher) {
970 rename(file(getdownLauncher).getName(), getdown_launcher)
972 into getdownInstallDir
976 from getdownInstallDir
977 into getdownFilesInstallDir
985 from getdownWebsiteDir+"/"+getdown_build_properties
986 if (file(getdownLauncher).getName() != getdown_launcher) {
987 rename(file(getdownLauncher).getName(), getdown_launcher)
993 from getdownResourceDir
994 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
999 inputs.dir(jalviewDir + '/' + packageDir)
1001 outputs.dir(project.ext.getdownWebsiteDir)
1002 outputs.dir(project.ext.getdownFilesDir)
1005 task getdownDigest(type: JavaExec) {
1006 group = "distribution"
1007 description = "Digest the getdown website folder"
1008 dependsOn getdownWebsite
1010 classpath = files(getdownWebsiteDir + '/' + getdown_launcher)
1012 main = "com.threerings.getdown.tools.Digester"
1013 args project.ext.getdownWebsiteDir
1014 inputs.dir(project.ext.getdownWebsiteDir)
1015 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
1019 group = "distribution"
1020 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1021 dependsOn getdownDigest
1023 if (reportRsyncCommand) {
1024 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith("/")?"":"/")
1025 def toDir = getdown_rsync_dest + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
1026 println "LIKELY RSYNC COMMAND:"
1027 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1028 if (RUNRSYNC == "true") {
1030 commandLine "mkdir", "-p", toDir
1033 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1042 delete project.ext.getdownWebsiteDir
1043 delete project.ext.getdownFilesDir
1048 def install4jHomeDir = "/opt/install4j"
1049 def hostname = "hostname".execute().text.trim()
1050 if (hostname.equals("jv-bamboo")) {
1051 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1052 } else if (OperatingSystem.current().isMacOsX()) {
1053 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1054 if (! file(install4jHomeDir).exists()) {
1055 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1057 } else if (OperatingSystem.current().isLinux()) {
1058 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1060 installDir = file(install4jHomeDir)
1061 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1062 if (install4jFaster.equals("true")) {
1070 def windowsJavaVMDir
1071 def windowsJavaVMTgz
1072 def install4jDir = "$jalviewDir/$install4jResourceDir"
1073 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
1074 install4jConf = "$install4jDir/$install4jConfFile"
1076 task copyInstall4jTemplate(type: Copy) {
1077 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
1078 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
1079 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
1080 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
1081 from (install4jDir) {
1082 include install4jTemplate
1083 rename (install4jTemplate, install4jConfFile)
1084 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1085 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1087 'JAVA_VERSION': JAVA_VERSION,
1088 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1089 'VERSION': JALVIEW_VERSION,
1090 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1091 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1092 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1093 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1094 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1095 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1096 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1097 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1098 'GETDOWN_DIST_DIR': getdown_app_dir,
1099 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1100 'GETDOWN_INSTALL_DIR': getdown_install_dir
1103 if (OSX_KEYPASS=="") {
1104 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1105 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1109 outputs.files(install4jConf)
1112 // include file associations in installer
1113 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
1117 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1118 replace: installerFileAssociationsXml,
1122 // include uninstaller applescript app files in dmg
1123 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1127 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1128 replace: installerDMGUninstallerXml,
1135 task installers(type: com.install4j.gradle.Install4jTask) {
1136 group = "distribution"
1137 description = "Create the install4j installers"
1139 dependsOn copyInstall4jTemplate
1140 projectFile = file(install4jConf)
1141 println("Using projectFile "+projectFile)
1142 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1143 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
1144 buildSelected = true
1147 macKeystorePassword=OSX_KEYPASS
1151 inputs.dir(project.ext.getdownWebsiteDir)
1152 inputs.file(install4jConf)
1153 inputs.dir(macosJavaVMDir)
1154 inputs.dir(windowsJavaVMDir)
1155 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")
1161 delete install4jConf
1165 task sourceDist (type: Tar) {
1167 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1168 def outputFileName = project.name + "_" + VERSION_UNDERSCORES + ".tar.gz"
1169 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1171 archiveFileName = outputFileName
1172 } catch (Exception e) {
1173 archiveName = outputFileName
1176 compression Compression.GZIP
1180 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1185 ,"**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales"
1187 ,"utils/InstallAnywhere"]
1188 def PROCESS_FILES=[ "AUTHORS",
1196 "THIRDPARTYLIBS","TESTNG",
1198 "gradle.properties",
1209 exclude (EXCLUDE_FILES)
1210 include (PROCESS_FILES)
1211 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1214 exclude (EXCLUDE_FILES)
1215 exclude (PROCESS_FILES)
1216 exclude ("appletlib")
1217 exclude ("**/*locales")
1218 exclude ("*locales/**")
1219 exclude ("utils/InstallAnywhere")
1221 exclude (getdown_files_dir)
1222 exclude (getdown_website_dir)
1224 // exluding these as not using jars as modules yet
1225 exclude ("$j11modDir/**/*.jar")
1227 // from (jalviewDir) {
1228 // // explicit includes for stuff that seemed to not get included
1229 // include(fileTree("test/**/*."))
1230 // exclude(EXCLUDE_FILES)
1231 // exclude(PROCESS_FILES)
1237 dependsOn pubhtmlhelp
1239 inputs.dir("$classes/$helpDir")
1240 outputs.dir("$helpOutputDir")
1243 def jalviewjsBuildDir
1244 def jalviewjsSiteDir
1245 def jalviewjsTransferSiteDir
1246 task jalviewjsSitePath {
1247 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1248 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1249 if (jalviewjs_site_dir.startsWith("/")) {
1250 jalviewjsSiteDir = jalviewjs_site_dir
1252 jalviewjsSiteDir = jalviewjsBuildDir + "/" + jalviewjs_site_dir
1254 jalviewjsTransferSiteDir = jalviewjsBuildDir + "/tmp/site"
1257 def eclipseWorkspace
1258 task jalviewjsSetEclipseWorkspace {
1259 def propKey = "jalviewjs_eclipse_workspace"
1260 def propsFileName = "${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1261 def props = new Properties()
1264 if (project.hasProperty(propKey)) {
1265 propVal = project.getProperty(propKey)
1266 eclipseWsDir = propVal
1268 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && file(propsFileName).exists()) {
1269 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${propsFileName}")
1272 if (props.getProperty(propKey, null) != null) {
1273 eclipseWsDir = props.getProperty(propKey)
1277 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1278 def tempDir = File.createTempDir()
1279 eclipseWsDir = tempDir.getAbsolutePath()
1280 props.setProperty(propKey, eclipseWsDir)
1281 def propsFile = file(propsFileName)
1282 propsFile.parentFile.mkdirs()
1283 propsFile.createNewFile() // doesn't affect existing file
1284 def outs = new FileOutputStream(propsFile, false)
1285 props.store(outs, null)
1289 eclipseWorkspace = file(eclipseWsDir)
1291 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1293 inputs.property(propKey, propVal)
1294 outputs.file(propsFileName)
1298 task jalviewjsUnzipFiles {
1299 dependsOn jalviewjsSitePath
1301 def zipFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_libjs_dir).include("*.zip")
1302 zipFiles += jalviewjs_utils_dir+"/"+jalviewjs_swingjs_zip
1305 zipFiles.each { file_zip ->
1307 from zipTree(file_zip)
1308 into jalviewjsSiteDir
1313 inputs.files zipFiles
1314 outputs.dir jalviewjsSiteDir
1317 def eclipseDropinsDir
1321 task jalviewjsEclipsePaths {
1324 eclipseRoot = jalviewjs_eclipse_root
1325 if (eclipseRoot.startsWith("~")) {
1326 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1328 if (OperatingSystem.current().isMacOsX()) {
1329 eclipseRoot += "/Eclipse.app"
1330 eclipseDropinsDir = eclipseRoot+"/Contents/Eclipse/dropins"
1331 eclipseBinary = eclipseRoot+"/Contents/MacOS/eclipse"
1332 eclipseProduct = eclipseRoot+"/Contents/Eclipse/.eclipseproduct"
1333 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1334 if (file(eclipseRoot+"/eclipse").isDirectory() && file(eclipseRoot+"/eclipse/.eclipseproduct").exists()) {
1335 eclipseRoot += "/eclipse"
1337 eclipseDropinsDir = eclipseRoot+"/dropins"
1338 eclipseBinary = eclipseRoot+"/eclipse"
1339 eclipseProduct = eclipseRoot+"/.eclipseproduct"
1340 } else { // linux or unix
1341 if (file(eclipseRoot+"/eclipse").isDirectory() && file(eclipseRoot+"/eclipse/.eclipseproduct").exists()) {
1342 eclipseRoot += "/eclipse"
1344 eclipseDropinsDir = eclipseRoot+"/dropins"
1345 eclipseBinary = eclipseRoot+"/eclipse"
1346 eclipseProduct = eclipseRoot+"/.eclipseproduct"
1349 def fis = new FileInputStream(eclipseProduct)
1350 def props = new Properties()
1352 eclipseVersion = props.getProperty("version")
1354 println("ECLIPSE_VERSION=${eclipseVersion}")
1355 String[] v = eclipseVersion.split("\\.")
1356 def v0 = Integer.valueOf(v[0])
1357 def v1 = Integer.valueOf(v[1])
1358 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1359 fromDropinsDir = "eclipse/dropins_4.12"
1361 fromDropinsDir = "eclipse/dropins_4.13"
1365 task OLDjalviewjsEclipseCopyDropins {
1366 dependsOn jalviewjsEclipsePaths
1367 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+fromDropinsDir, include: "*.jar")
1368 def outputDir = eclipseDropinsDir
1370 inputs.files inputFiles
1371 inputFiles.each { file ->
1372 outputs.file(outputDir+"/"+file.name)
1376 def outputFiles = []
1377 inputFiles.each { file ->
1386 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1387 task jalviewjsEclipseCopyDropins(type: Copy) {
1389 into eclipseDropinsDir
1392 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1393 dependsOn jalviewjsSitePath
1394 outputFile (jalviewDir+"/"+jalviewjs_j2s_settings)
1395 def props = project.properties.sort { it.key }
1396 def siteDirProperty = "j2s.site.directory"
1397 def setSiteDir = false
1398 props.each { prop, val ->
1399 if (prop.startsWith("j2s.") && val != null) {
1400 if (prop == siteDirProperty) {
1401 if (!(val.startsWith("/") || val.startsWith("file://") )) {
1402 val = jalviewjsTransferSiteDir+"/"+val
1409 property(siteDirProperty,jalviewjsTransferSiteDir)
1412 inputs.properties(props.findAll( { k, v -> k.startsWith("j2s.") } ))
1413 outputs.file(outputFile)
1416 task jalviewjsEclipseSetup {
1417 dependsOn jalviewjsEclipseCopyDropins
1418 dependsOn jalviewjsSetEclipseWorkspace
1419 dependsOn jalviewjsCreateJ2sSettings
1422 task jalviewjsCopyResources (type: Copy) {
1423 dependsOn jalviewjsSitePath
1424 def inputFiles = fileTree(dir: jalviewjs_resource_dir)
1425 def outputDir = jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir
1429 def outputFiles = []
1430 rename { filename ->
1431 outputFiles += outputDir+"/"+filename
1434 outputs.files outputFiles
1435 inputs.files inputFiles
1438 task jalviewjsCopySiteResources (type: Copy) {
1439 dependsOn jalviewjsSitePath
1440 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_site_resource_dir)
1441 def outputDir = jalviewjsSiteDir
1445 def outputFiles = []
1446 rename { filename ->
1447 outputFiles += outputDir+"/"+filename
1450 outputs.files outputFiles
1451 inputs.files inputFiles
1454 task cleanJalviewjsAll {
1456 description "Delete all configuration and build artifacts to do with JalviewJS build"
1457 dependsOn cleanJalviewjsSite
1460 delete jalviewjsBuildDir
1461 delete jalviewDir+"/"+eclipse_bin_dir
1462 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1463 delete jalviewDir+"/"+jalviewjs_j2s_settings
1467 task jalviewjsProjectImport(type: Exec) {
1468 // work out how to do this!
1469 dependsOn eclipseProject
1470 dependsOn eclipseClasspath
1471 dependsOn eclipseJdt
1472 dependsOn jalviewjsEclipsePaths
1473 dependsOn jalviewjsEclipseSetup
1474 executable(eclipseBinary)
1475 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1477 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1478 inputs.file(jalviewDir+"/.project")
1479 outputs.dir(projdir)
1480 outputs.upToDateWhen { file(projdir).exists() }
1483 task jalviewjsTranspile(type: Exec) {
1484 dependsOn jalviewjsEclipseSetup
1485 dependsOn jalviewjsProjectImport
1486 dependsOn jalviewjsEclipsePaths
1487 executable(eclipseBinary)
1488 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-"+jalviewjs_eclipseBuildArg, eclipse_project_name ])
1493 stdout = new ByteArrayOutputStream()
1494 stderr = new ByteArrayOutputStream()
1496 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1497 def logOutFile = file(logOutFileName)
1498 logOutFile.createNewFile()
1499 def logOutFOS = new FileOutputStream(logOutFile, false)
1500 //def logErrFileName = "${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1501 //def logErrFile = file(logFileName)
1502 //logErrFile.createNewFile()
1503 //def logErrFOS = new FileErrputStream(logErrFile, false)
1504 // combine stdout and stderr
1505 def logErrFOS = logOutFOS
1506 if (jalviewjs_j2s_to_console.equals("true")) {
1507 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1508 new org.apache.tools.ant.util.TeeOutputStream(
1512 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1513 new org.apache.tools.ant.util.TeeOutputStream(
1518 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1521 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1527 if (stdout.toString().contains("Error processing ")) {
1528 // j2s did not complete transpile
1529 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1533 inputs.dir(sourceDir)
1534 outputs.dir(eclipse_bin_dir+"/main")
1535 outputs.dir(jalviewjsTransferSiteDir)
1536 outputs.upToDateWhen { file("${jalviewjsTransferSiteDir}${jalviewjs_server_resource}").exists() }
1540 task jalviewjsCopyTransferSite(type: Copy) {
1541 dependsOn jalviewjsTranspile
1542 from jalviewjsTransferSiteDir
1543 into jalviewjsSiteDir
1546 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1547 jalviewjsCopyResources.mustRunAfter jalviewjsCopyTransferSite
1548 jalviewjsCopySiteResources.mustRunAfter jalviewjsCopyTransferSite
1550 task jalviewjsPrepareSite {
1552 description "Prepares the website folder including unzipping files and copying resources"
1553 dependsOn jalviewjsSitePath
1554 dependsOn jalviewjsUnzipFiles
1555 dependsOn jalviewjsCopyResources
1556 dependsOn jalviewjsCopySiteResources
1559 task jalviewjsBuildSite {
1561 description "Builds the whole website including transpiled code"
1562 dependsOn jalviewjsCopyTransferSite
1563 dependsOn jalviewjsPrepareSite
1566 task cleanJalviewjsSite {
1568 delete jalviewjsTransferSiteDir
1569 delete jalviewjsSiteDir
1573 task jalviewjsSiteTar(type: Tar) {
1575 description "Creates a tar.gz file for the website"
1576 dependsOn jalviewjsBuildSite
1577 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1579 archiveFileName = outputFilename
1580 } catch (Exception e) {
1581 archiveName = outputFilename
1584 compression Compression.GZIP
1586 from jalviewjsSiteDir
1587 into jalviewjs_site_dir // this is inside the tar file
1589 inputs.dir(jalviewjsSiteDir)
1592 task jalviewjsServer {
1594 description "Starts a webserver on localhost to test the website"
1595 dependsOn jalviewjsSitePath
1596 def htmlFile = "${jalviewDirAbsolutePath}/jalviewjsTest.html"
1599 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1600 def port = Integer.valueOf(jalviewjs_server_port)
1604 while(port < start+1000 && !running) {
1606 def doc_root = new File(jalviewDirAbsolutePath +"/"+ jalviewjsSiteDir)
1607 def jalviewjsServer = factory.start(doc_root, port)
1609 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1610 println("SERVER STARTED with document root ${doc_root}.")
1611 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1612 println("For debug: "+url+"?j2sdebug")
1614 file(htmlFile).text = """
1615 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1616 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1619 } catch (Exception e) {
1626 outputs.file(htmlFile)
1631 description "Build the site"
1632 dependsOn jalviewjsBuildSite
1636 task jalviewjsIDECopyTransferSite(type: Copy) {
1637 from jalviewjsTransferSiteDir
1638 into jalviewjsSiteDir
1641 task jalviewjsIDEj2s {
1642 group "JalviewJS in Eclipse"
1643 description "Creates the .j2s file"
1644 dependsOn jalviewjsCreateJ2sSettings
1647 task jalviewjsIDEBuildSite {
1648 group "JalviewJS in Eclipse"
1649 description "Copies the Eclipse transpiled site and unzips supporting zipfiles"
1650 dependsOn jalviewjsIDECopyTransferSite
1651 dependsOn jalviewjsPrepareSite
1654 task jalviewjsIDESiteClean {
1655 group "JalviewJS in Eclipse"
1656 description "Deletes the Eclipse transpiled site"
1657 dependsOn cleanJalviewjsSite
1660 task jalviewjsIDEServer {
1661 group "JalviewJS in Eclipse"
1662 description "Starts a webserver on localhost to test the website"
1663 dependsOn jalviewjsServer