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
512 delete sourceSets.main.java.outputDir
516 delete sourceSets.test.java.outputDir
517 delete cloverInstrDir
520 // format is a string like date.format("dd MMMM yyyy")
521 def getDate(format) {
522 def date = new Date()
523 return date.format(format)
527 def hashStdOut = new ByteArrayOutputStream()
529 commandLine "git", "rev-parse", "--short", "HEAD"
530 standardOutput = hashStdOut
534 def branchStdOut = new ByteArrayOutputStream()
536 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
537 standardOutput = branchStdOut
541 project.ext.gitHash = hashStdOut.toString().trim()
542 project.ext.gitBranch = branchStdOut.toString().trim()
544 outputs.upToDateWhen { false }
547 task createBuildProperties(type: WriteProperties) {
549 inputs.dir("$jalviewDir/$sourceDir")
550 inputs.dir("$classes")
551 inputs.dir("$jalviewDir/$resourceDir")
552 outputFile (buildProperties)
553 // taking time specific comment out to allow better incremental builds
554 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
555 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
556 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
557 property "VERSION", JALVIEW_VERSION
558 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
559 outputs.file(outputFile)
562 def buildingHTML = "$jalviewDir/$docDir/building.html"
563 task deleteBuildingHTML(type: Delete) {
567 task convertBuildingMD(type: Exec) {
568 dependsOn deleteBuildingHTML
569 def buildingMD = "$jalviewDir/$docDir/building.md"
570 def css = "$jalviewDir/$docDir/github.css"
573 pandoc_exec.split(",").each {
574 if (file(it.trim()).exists()) {
580 def hostname = "hostname".execute().text.trim()
581 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
582 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
586 if (pandoc != null && file(pandoc).exists()) {
587 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
589 println("Cannot find pandoc. Skipping convert building.md to HTML")
590 throw new StopExecutionException()
596 inputs.file(buildingMD)
598 outputs.file(buildingHTML)
604 task syncDocs(type: Sync) {
605 dependsOn convertBuildingMD
606 def syncDir = "$classes/$docDir"
607 from fileTree("$jalviewDir/$docDir")
612 def helpFile = "$classes/$helpDir/help.jhm"
614 task copyHelp(type: Copy) {
615 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
616 def outputDir = "$classes/$helpDir"
621 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
631 outputs.files(helpFile)
632 outputs.dir(outputDir)
635 task syncLib(type: Sync) {
636 def syncDir = "$classes/$libDistDir"
637 from fileTree("$jalviewDir/$libDistDir")
641 task syncResources(type: Sync) {
642 from "$jalviewDir/$resourceDir"
652 dependsOn syncResources
658 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
661 dependsOn compileJava
663 dependsOn cloverInstr
667 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
671 includeGroups testngGroups
673 useDefaultListeners=true
676 workingDir = jalviewDir
677 //systemProperties 'clover.jar' System.properties.clover.jar
678 sourceCompatibility = compile_source_compatibility
679 targetCompatibility = compile_target_compatibility
680 jvmArgs += additional_compiler_args
681 print ("Setting target compatibility to "+targetCompatibility+"\n")
684 task buildIndices(type: JavaExec) {
686 classpath = sourceSets.main.compileClasspath
687 main = "com.sun.java.help.search.Indexer"
688 workingDir = "$classes/$helpDir"
691 inputs.dir("$workingDir/$argDir")
693 outputs.dir("$classes/doc")
694 outputs.dir("$classes/help")
695 outputs.file("$workingDir/JavaHelpSearch/DOCS")
696 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
697 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
698 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
699 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
700 outputs.file("$workingDir/JavaHelpSearch/TMAP")
703 task compileLinkCheck(type: JavaCompile) {
705 classpath = files("$jalviewDir/$utilsDir")
706 destinationDir = file("$jalviewDir/$utilsDir")
707 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
709 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
710 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
711 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
712 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
715 def helplinkscheckertouchfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.touch")
716 task linkCheck(type: JavaExec) {
717 dependsOn prepare, compileLinkCheck
718 classpath = files("$jalviewDir/$utilsDir")
719 main = "HelpLinksChecker"
720 workingDir = jalviewDir
721 def help = "$classes/$helpDir"
722 args = [ "$classes/$helpDir", "-nointernet" ]
725 helplinkscheckertouchfile.createNewFile()
728 inputs.dir("$classes/$helpDir")
729 outputs.file(helplinkscheckertouchfile)
732 // import the pubhtmlhelp target
733 ant.properties.basedir = "$jalviewDir"
734 ant.properties.helpBuildDir = jalviewDirAbsolutePath+"/$classes/$helpDir"
735 ant.importBuild "$utilsDir/publishHelp.xml"
738 task cleanPackageDir(type: Delete) {
739 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
744 dependsOn buildIndices
745 dependsOn createBuildProperties
748 attributes "Main-Class": mainClass,
749 "Permissions": "all-permissions",
750 "Application-Name": "Jalview Desktop",
751 "Codebase": application_codebase
754 destinationDir = file("$jalviewDir/$packageDir")
755 archiveName = rootProject.name+".jar"
763 inputs.dir("$classes")
764 outputs.file("$jalviewDir/$packageDir/$archiveName")
767 task copyJars(type: Copy) {
768 from fileTree("$classes").include("**/*.jar").include("*.jar").files
769 into "$jalviewDir/$packageDir"
772 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
773 task syncJars(type: Sync) {
774 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
775 into "$jalviewDir/$packageDir"
777 include jar.archiveName
783 description = "Put all required libraries in dist"
784 // order of "cleanPackageDir", "copyJars", "jar" important!
785 jar.mustRunAfter cleanPackageDir
786 syncJars.mustRunAfter cleanPackageDir
787 dependsOn cleanPackageDir
790 outputs.dir("$jalviewDir/$packageDir")
794 dependsOn cleanPackageDir
800 group = "distribution"
804 from ("$jalviewDir/$libDistDir") {
808 attributes 'Implementation-Version': JALVIEW_VERSION
810 mainClassName = shadowJarMainClass
812 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
816 task getdownWebsite() {
817 group = "distribution"
818 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
823 // clean the getdown website and files dir before creating getdown folders
824 delete project.ext.getdownWebsiteDir
825 delete project.ext.getdownFilesDir
827 def getdownWebsiteResourceFilenames = []
828 def getdownTextString = ""
829 def getdownResourceDir = project.ext.getdownResourceDir
830 def getdownAppDir = project.ext.getdownAppDir
831 def getdownResourceFilenames = []
836 rename(buildPropertiesFile, getdown_build_properties)
837 into project.ext.getdownAppDir
839 getdownWebsiteResourceFilenames += getdown_app_dir+"/"+getdown_build_properties
841 // go through properties looking for getdown_txt_...
842 def props = project.properties.sort { it.key }
843 if (getdown_alt_java_min_version.length() > 0) {
844 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
846 if (getdown_alt_java_max_version.length() > 0) {
847 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
849 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
851 props.put("getdown_txt_appbase", getdown_app_base)
852 props.each{ prop, val ->
853 if (prop.startsWith("getdown_txt_") && val != null) {
854 if (prop.startsWith("getdown_txt_multi_")) {
855 def key = prop.substring(18)
856 val.split(",").each{ v ->
857 def line = key + " = " + v + "\n"
858 getdownTextString += line
861 // file values rationalised
862 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
864 if (val.indexOf('/') == 0) {
867 } else if (val.indexOf('/') > 0) {
868 // relative path (relative to jalviewDir)
869 r = file( jalviewDir + '/' + val )
872 val = getdown_resource_dir + '/' + r.getName()
873 getdownWebsiteResourceFilenames += val
874 getdownResourceFilenames += r.getPath()
877 if (! prop.startsWith("getdown_txt_resource")) {
878 def line = prop.substring(12) + " = " + val + "\n"
879 getdownTextString += line
885 getdownWebsiteResourceFilenames.each{ filename ->
886 getdownTextString += "resource = "+filename+"\n"
888 getdownResourceFilenames.each{ filename ->
891 into project.ext.getdownResourceDir
896 fileTree(file(packageDir)).each{ f ->
897 if (f.isDirectory()) {
898 def files = fileTree(dir: f, include: ["*"]).getFiles()
900 } else if (f.exists()) {
904 codeFiles.sort().each{f ->
905 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
906 getdownTextString += line
909 into project.ext.getdownAppDir
913 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
915 if (JAVA_VERSION.equals("11")) {
916 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
917 j11libFiles.sort().each{f ->
918 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
919 getdownTextString += line
922 into project.ext.getdownJ11libDir
928 // 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.
929 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
930 getdownTextString += "resource = " + getdown_launcher_new + "\n"
931 getdownTextString += "class = " + mainClass + "\n"
933 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
934 getdown_txt.write(getdownTextString)
936 def launch_jvl = file(project.ext.getdownWebsiteDir + "/" + getdown_launch_jvl)
937 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
941 rename(file(getdownLauncher).getName(), getdown_launcher_new)
942 into project.ext.getdownWebsiteDir
947 if (file(getdownLauncher).getName() != getdown_launcher) {
948 rename(file(getdownLauncher).getName(), getdown_launcher)
950 into project.ext.getdownWebsiteDir
953 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
957 from getdownWebsiteDir+"/"+getdown_build_properties
958 if (file(getdownLauncher).getName() != getdown_launcher) {
959 rename(file(getdownLauncher).getName(), getdown_launcher)
961 into getdownInstallDir
965 from getdownInstallDir
966 into getdownFilesInstallDir
974 from getdownWebsiteDir+"/"+getdown_build_properties
975 if (file(getdownLauncher).getName() != getdown_launcher) {
976 rename(file(getdownLauncher).getName(), getdown_launcher)
982 from getdownResourceDir
983 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
988 inputs.dir(jalviewDir + '/' + packageDir)
990 outputs.dir(project.ext.getdownWebsiteDir)
991 outputs.dir(project.ext.getdownFilesDir)
994 task getdownDigest(type: JavaExec) {
995 group = "distribution"
996 description = "Digest the getdown website folder"
997 dependsOn getdownWebsite
999 classpath = files(getdownWebsiteDir + '/' + getdown_launcher)
1001 main = "com.threerings.getdown.tools.Digester"
1002 args project.ext.getdownWebsiteDir
1003 inputs.dir(project.ext.getdownWebsiteDir)
1004 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
1008 group = "distribution"
1009 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1010 dependsOn getdownDigest
1012 if (reportRsyncCommand) {
1013 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith("/")?"":"/")
1014 def toDir = getdown_rsync_dest + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
1015 println "LIKELY RSYNC COMMAND:"
1016 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1017 if (RUNRSYNC == "true") {
1019 commandLine "mkdir", "-p", toDir
1022 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1030 delete project.ext.getdownWebsiteDir
1031 delete project.ext.getdownFilesDir
1035 def install4jHomeDir = "/opt/install4j"
1036 def hostname = "hostname".execute().text.trim()
1037 if (hostname.equals("jv-bamboo")) {
1038 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1039 } else if (OperatingSystem.current().isMacOsX()) {
1040 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1041 if (! file(install4jHomeDir).exists()) {
1042 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1044 } else if (OperatingSystem.current().isLinux()) {
1045 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1047 installDir = file(install4jHomeDir)
1048 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1049 if (install4jFaster.equals("true")) {
1057 def windowsJavaVMDir
1058 def windowsJavaVMTgz
1059 def install4jDir = "$jalviewDir/$install4jResourceDir"
1060 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
1061 install4jConf = "$install4jDir/$install4jConfFile"
1063 task copyInstall4jTemplate(type: Copy) {
1064 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
1065 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
1066 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
1067 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
1068 from (install4jDir) {
1069 include install4jTemplate
1070 rename (install4jTemplate, install4jConfFile)
1071 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1072 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1074 'JAVA_VERSION': JAVA_VERSION,
1075 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1076 'VERSION': JALVIEW_VERSION,
1077 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1078 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1079 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1080 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1081 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1082 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1083 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1084 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1085 'GETDOWN_DIST_DIR': getdown_app_dir,
1086 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1087 'GETDOWN_INSTALL_DIR': getdown_install_dir
1090 if (OSX_KEYPASS=="") {
1091 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1092 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1096 outputs.files(install4jConf)
1099 // include file associations in installer
1100 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
1104 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1105 replace: installerFileAssociationsXml,
1109 // include uninstaller applescript app files in dmg
1110 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1114 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1115 replace: installerDMGUninstallerXml,
1122 task installers(type: com.install4j.gradle.Install4jTask) {
1123 group = "distribution"
1124 description = "Create the install4j installers"
1126 dependsOn copyInstall4jTemplate
1127 projectFile = file(install4jConf)
1128 println("Using projectFile "+projectFile)
1129 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1130 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
1131 buildSelected = true
1134 macKeystorePassword=OSX_KEYPASS
1138 inputs.dir(project.ext.getdownWebsiteDir)
1139 inputs.file(install4jConf)
1140 inputs.dir(macosJavaVMDir)
1141 inputs.dir(windowsJavaVMDir)
1142 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")
1147 delete install4jConf
1150 task sourceDist (type: Tar) {
1152 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1153 def outputFileName = project.name + "_" + VERSION_UNDERSCORES + ".tar.gz"
1154 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1156 archiveFileName = outputFileName
1157 } catch (Exception e) {
1158 archiveName = outputFileName
1161 compression Compression.GZIP
1165 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1170 ,"**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales"
1172 ,"utils/InstallAnywhere"]
1173 def PROCESS_FILES=[ "AUTHORS",
1181 "THIRDPARTYLIBS","TESTNG",
1183 "gradle.properties",
1194 exclude (EXCLUDE_FILES)
1195 include (PROCESS_FILES)
1196 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1199 exclude (EXCLUDE_FILES)
1200 exclude (PROCESS_FILES)
1201 exclude ("appletlib")
1202 exclude ("**/*locales")
1203 exclude ("*locales/**")
1204 exclude ("utils/InstallAnywhere")
1206 exclude (getdown_files_dir)
1207 exclude (getdown_website_dir)
1209 // exluding these as not using jars as modules yet
1210 exclude ("$j11modDir/**/*.jar")
1212 // from (jalviewDir) {
1213 // // explicit includes for stuff that seemed to not get included
1214 // include(fileTree("test/**/*."))
1215 // exclude(EXCLUDE_FILES)
1216 // exclude(PROCESS_FILES)
1222 dependsOn pubhtmlhelp
1224 inputs.dir("$classes/$helpDir")
1225 outputs.dir("$helpOutputDir")
1228 def jalviewjsBuildDir
1229 def jalviewjsSiteDir
1230 def jalviewjsTransferSiteDir
1231 task jalviewjsSitePath {
1232 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1233 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1234 if (jalviewjs_site_dir.startsWith("/")) {
1235 jalviewjsSiteDir = jalviewjs_site_dir
1237 jalviewjsSiteDir = jalviewjsBuildDir + "/" + jalviewjs_site_dir
1239 jalviewjsTransferSiteDir = jalviewjsBuildDir + "/tmp/site"
1242 def eclipseWorkspace
1243 task jalviewjsSetEclipseWorkspace {
1244 def propKey = "jalviewjs_eclipse_workspace"
1245 def propsFileName = "${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1246 def props = new Properties()
1249 if (project.hasProperty(propKey)) {
1250 propVal = project.getProperty(propKey)
1251 eclipseWsDir = propVal
1253 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && file(propsFileName).exists()) {
1254 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${propsFileName}")
1257 if (props.getProperty(propKey, null) != null) {
1258 eclipseWsDir = props.getProperty(propKey)
1262 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1263 def tempDir = File.createTempDir()
1264 eclipseWsDir = tempDir.getAbsolutePath()
1265 props.setProperty(propKey, eclipseWsDir)
1266 def propsFile = file(propsFileName)
1267 propsFile.parentFile.mkdirs()
1268 propsFile.createNewFile() // doesn't affect existing file
1269 def outs = new FileOutputStream(propsFile, false)
1270 props.store(outs, null)
1274 eclipseWorkspace = file(eclipseWsDir)
1276 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1278 inputs.property(propKey, propVal)
1279 outputs.file(propsFileName)
1283 task jalviewjsUnzipFiles {
1284 dependsOn jalviewjsSitePath
1286 def zipFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_libjs_dir).include("*.zip")
1287 zipFiles += jalviewjs_utils_dir+"/"+jalviewjs_swingjs_zip
1290 zipFiles.each { file_zip ->
1292 from zipTree(file_zip)
1293 into jalviewjsSiteDir
1298 inputs.files zipFiles
1299 outputs.dir jalviewjsSiteDir
1302 def eclipseDropinsDir
1306 task jalviewjsEclipsePaths {
1309 eclipseRoot = jalviewjs_eclipse_root
1310 if (eclipseRoot.startsWith("~")) {
1311 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1313 if (OperatingSystem.current().isMacOsX()) {
1314 eclipseRoot += "/Eclipse.app"
1315 eclipseDropinsDir = eclipseRoot+"/Contents/Eclipse/dropins"
1316 eclipseBinary = eclipseRoot+"/Contents/MacOS/eclipse"
1317 eclipseProduct = eclipseRoot+"/Contents/Eclipse/.eclipseproduct"
1318 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1319 if (file(eclipseRoot+"/eclipse").isDirectory() && file(eclipseRoot+"/eclipse/.eclipseproduct").exists()) {
1320 eclipseRoot += "/eclipse"
1322 eclipseDropinsDir = eclipseRoot+"/dropins"
1323 eclipseBinary = eclipseRoot+"/eclipse"
1324 eclipseProduct = eclipseRoot+"/.eclipseproduct"
1325 } else { // linux or unix
1326 if (file(eclipseRoot+"/eclipse").isDirectory() && file(eclipseRoot+"/eclipse/.eclipseproduct").exists()) {
1327 eclipseRoot += "/eclipse"
1329 eclipseDropinsDir = eclipseRoot+"/dropins"
1330 eclipseBinary = eclipseRoot+"/eclipse"
1331 eclipseProduct = eclipseRoot+"/.eclipseproduct"
1334 def fis = new FileInputStream(eclipseProduct)
1335 def props = new Properties()
1337 eclipseVersion = props.getProperty("version")
1339 println("ECLIPSE_VERSION=${eclipseVersion}")
1340 String[] v = eclipseVersion.split("\\.")
1341 def v0 = Integer.valueOf(v[0])
1342 def v1 = Integer.valueOf(v[1])
1343 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1344 fromDropinsDir = "eclipse/dropins_4.12"
1346 fromDropinsDir = "eclipse/dropins_4.13"
1350 task jalviewjsEclipseCopyDropins {
1351 dependsOn jalviewjsEclipsePaths
1352 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+fromDropinsDir, include: "*.jar")
1353 def outputDir = eclipseDropinsDir
1355 inputs.files inputFiles
1356 inputFiles.each { file ->
1357 outputs.file(outputDir+"/"+file.name)
1361 def outputFiles = []
1362 inputFiles.each { file ->
1371 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1372 dependsOn jalviewjsSitePath
1373 outputFile (jalviewDir+"/"+jalviewjs_j2s_settings)
1374 def props = project.properties.sort { it.key }
1375 def siteDirProperty = "j2s.site.directory"
1376 def setSiteDir = false
1377 props.each { prop, val ->
1378 if (prop.startsWith("j2s.") && val != null) {
1379 if (prop == siteDirProperty) {
1380 if (!(val.startsWith("/") || val.startsWith("file://") )) {
1381 val = jalviewjsTransferSiteDir+"/"+val
1388 property(siteDirProperty,jalviewjsTransferSiteDir)
1391 outputs.file(outputFile)
1394 task jalviewjsEclipseSetup {
1395 dependsOn jalviewjsEclipseCopyDropins
1396 dependsOn jalviewjsSetEclipseWorkspace
1397 dependsOn jalviewjsCreateJ2sSettings
1400 task jalviewjsCopyResources (type: Copy) {
1401 dependsOn jalviewjsSitePath
1402 def inputFiles = fileTree(dir: jalviewjs_resource_dir)
1403 def outputDir = jalviewjsSiteDir+"/"+jalviewjs_j2s_subdir
1407 def outputFiles = []
1408 rename { filename ->
1409 outputFiles += outputDir+"/"+filename
1412 outputs.files outputFiles
1413 inputs.files inputFiles
1416 task jalviewjsCopySiteResources (type: Copy) {
1417 dependsOn jalviewjsSitePath
1418 def inputFiles = fileTree(dir: jalviewjs_utils_dir+"/"+jalviewjs_site_resource_dir)
1419 def outputDir = jalviewjsSiteDir
1423 def outputFiles = []
1424 rename { filename ->
1425 outputFiles += outputDir+"/"+filename
1428 outputs.files outputFiles
1429 inputs.files inputFiles
1432 task jalviewjsTotalClean {
1434 description "Delete everything to do with JalviewJS build"
1435 //delete jalviewjsBuildDir
1436 delete jalviewDir+"/"+eclipse_bin_dir
1437 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1438 delete jalviewDir+"/"+jalviewjs_j2s_settings
1441 task jalviewjsProjectImport(type: Exec) {
1442 // work out how to do this!
1443 dependsOn eclipseProject
1444 dependsOn eclipseClasspath
1445 dependsOn eclipseJdt
1446 dependsOn jalviewjsEclipsePaths
1447 dependsOn jalviewjsEclipseSetup
1448 executable(eclipseBinary)
1449 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1451 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1452 inputs.file(jalviewDir+"/.project")
1453 outputs.dir(projdir)
1454 outputs.upToDateWhen { file(projdir).exists() }
1457 task jalviewjsTranspile(type: Exec) {
1458 dependsOn jalviewjsEclipseSetup
1459 dependsOn jalviewjsProjectImport
1460 dependsOn jalviewjsEclipsePaths
1461 executable(eclipseBinary)
1462 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-"+jalviewjs_eclipseBuildArg, eclipse_project_name ])
1467 stdout = new ByteArrayOutputStream()
1468 stderr = new ByteArrayOutputStream()
1470 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1471 def logOutFile = file(logOutFileName)
1472 logOutFile.createNewFile()
1473 def logOutFOS = new FileOutputStream(logOutFile, false)
1474 //def logErrFileName = "${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1475 //def logErrFile = file(logFileName)
1476 //logErrFile.createNewFile()
1477 //def logErrFOS = new FileErrputStream(logErrFile, false)
1478 // combine stdout and stderr
1479 def logErrFOS = logOutFOS
1480 if (jalviewjs_j2s_to_console.equals("true")) {
1481 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1482 new org.apache.tools.ant.util.TeeOutputStream(
1486 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1487 new org.apache.tools.ant.util.TeeOutputStream(
1492 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1495 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1501 if (stdout.toString().contains("Error processing ")) {
1502 // j2s did not complete transpile
1503 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1507 inputs.dir(sourceDir)
1508 outputs.dir(eclipse_bin_dir+"/main")
1509 outputs.dir(jalviewjsTransferSiteDir)
1513 task jalviewjsCopyTransferSite(type: Copy) {
1514 dependsOn jalviewjsTranspile
1515 from jalviewjsTransferSiteDir
1516 into jalviewjsSiteDir
1519 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1520 jalviewjsCopyResources.mustRunAfter jalviewjsCopyTransferSite
1521 jalviewjsCopySiteResources.mustRunAfter jalviewjsCopyTransferSite
1523 task jalviewjsPrepareSite {
1525 description "Prepares the website folder including unzipping files and copying resources"
1526 dependsOn jalviewjsSitePath
1527 dependsOn jalviewjsUnzipFiles
1528 dependsOn jalviewjsCopyResources
1529 dependsOn jalviewjsCopySiteResources
1532 task jalviewjsBuildSite {
1534 description "Builds the whole website including transpiled code"
1535 dependsOn jalviewjsCopyTransferSite
1536 dependsOn jalviewjsPrepareSite
1539 task jalviewjsSiteClean {
1540 //delete jalviewjsTransferSiteDir
1541 //delete jalviewjsSiteDir
1544 task jalviewjsSiteTar(type: Tar) {
1546 description "Creates a tar.gz file for the website"
1547 dependsOn jalviewjsBuildSite
1548 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1550 archiveFileName = outputFilename
1551 } catch (Exception e) {
1552 archiveName = outputFilename
1555 compression Compression.GZIP
1557 from jalviewjsSiteDir
1558 into jalviewjs_site_dir // this is inside the tar file
1560 inputs.dir(jalviewjsSiteDir)
1563 task jalviewjsServer {
1565 description "Starts a webserver on localhost to test the website"
1566 dependsOn jalviewjsSitePath
1567 def htmlFile = "${jalviewDirAbsolutePath}/jalviewjsTest.html"
1570 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1571 def port = Integer.valueOf(jalviewjs_server_port)
1575 while(port < start+1000 && !running) {
1577 def doc_root = new File(jalviewDirAbsolutePath +"/"+ jalviewjsSiteDir)
1578 def jalviewjsServer = factory.start(doc_root, port)
1580 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1581 println("SERVER STARTED with document root ${doc_root}.")
1582 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1583 println("For debug: "+url+"?j2sdebug")
1585 file(htmlFile).text = """
1586 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1587 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1590 } catch (Exception e) {
1597 outputs.file(htmlFile)
1602 description "Build the site"
1603 dependsOn jalviewjsBuildSite
1607 task jalviewjsIDECopyTransferSite(type: Copy) {
1608 from jalviewjsTransferSiteDir
1609 into jalviewjsSiteDir
1612 task jalviewjsIDEj2s {
1613 group "JalviewJS in Eclipse"
1614 description "Creates the .j2s file"
1615 dependsOn jalviewjsCreateJ2sSettings
1618 task jalviewjsIDEBuildSite {
1619 group "JalviewJS in Eclipse"
1620 description "Copies the Eclipse transpiled site and unzips supporting zipfiles"
1621 dependsOn jalviewjsIDECopyTransferSite
1622 dependsOn jalviewjsPrepareSite
1625 task jalviewjsIDESiteClean {
1626 group "JalviewJS in Eclipse"
1627 description "Deletes the Eclipse transpiled site"
1628 dependsOn jalviewjsSiteClean
1631 task jalviewjsIDEServer {
1632 group "JalviewJS in Eclipse"
1633 description "Starts a webserver on localhost to test the website"
1634 dependsOn jalviewjsServer