import java.util.concurrent.Future
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.TimeUnit
+import java.nio.file.Path
import groovy.transform.ExternalizeMethods
import groovy.util.XmlParser
import groovy.xml.XmlUtil
if (IN_ECLIPSE) {
jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
} else {
- jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
+ jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}/js")
}
- jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
- jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
- jalviewjsTransferSiteMergeDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_merge")
- jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
+ jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}/lib")
+ jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}/swingjs")
+ jalviewjsTransferSiteMergeDir = string("${jalviewjsBuildDir}/merge/${jalviewjs_site_dir}")
+ jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}/core")
jalviewjsJalviewCoreHtmlFile = string("")
jalviewjsJalviewCoreName = string(jalviewjs_core_name)
jalviewjsCoreClasslists = []
*/
-task jalviewjsTransferUnzipSwingJs {
- def file_zip = "${jalviewDir}/${jalviewjs_swingjs_zip}"
-
- doLast {
- copy {
- from zipTree(file_zip)
- into "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
- }
- }
-
- inputs.file file_zip
- outputs.dir "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
+task jalviewjsTransferUnzipSwingJs(type: Copy) {
+ from zipTree( "${jalviewDir}/${jalviewjs_swingjs_zip}" )
+ into "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
}
-task jalviewjsTransferUnzipLib {
+task jalviewjsTransferUnzipLib(type: Copy) {
def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip").sort()
- doLast {
- zipFiles.each { file_zip ->
- copy {
- from zipTree(file_zip)
- into "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
-
- // rename files in jsmol/j2s/... to swingjs/j2s/...
- if (file_zip.getName().startsWith("Jmol-j2s-site")) {
- eachFile { fcd ->
- // jsmol/... -> swingjs/...
- def relPathSegments = fcd.relativePath.getSegments()
- if (relPathSegments[0] == "jsmol") {
- def newRelPathSegments = relPathSegments
- newRelPathSegments[0] = "swingjs"
- fcd.relativePath = new RelativePath(true, newRelPathSegments)
- }
- }
+ zipFiles.each { file_zip ->
+ from zipTree(file_zip)
+
+ // rename files in jsmol/j2s/... to swingjs/j2s/...
+ if (file_zip.getName().startsWith("Jmol-j2s-site")) {
+ eachFile { fcd ->
+ // jsmol/... -> swingjs/...
+ def relPathSegments = fcd.relativePath.getSegments()
+ if (relPathSegments[0] == "jsmol") {
+ def newRelPathSegments = relPathSegments
+ newRelPathSegments[0] = "swingjs"
+ fcd.relativePath = new RelativePath(true, newRelPathSegments)
}
+ }
+ }
- // The following replace() is needed due to a mismatch in Jmol calls to
- // colorPtToFFRGB$javajs_util_T3d when only colorPtToFFRGB$javajs_util_T3 is defined
- // in the SwingJS.zip (github or the one distributed with JSmol)
- if (file_zip.getName().startsWith("Jmol-SwingJS")) {
- filter { line ->
- def l = ""
- while(!line.equals(l)) {
- line = line.replace('colorPtToFFRGB$javajs_util_T3d', 'colorPtToFFRGB$javajs_util_T3')
- l = line
- }
- return line
- }
+ // The following replace() is needed due to a mismatch in Jmol calls to
+ // colorPtToFFRGB$javajs_util_T3d when only colorPtToFFRGB$javajs_util_T3 is defined
+ // in the SwingJS.zip (github or the one distributed with JSmol)
+ if (file_zip.getName().startsWith("Jmol-SwingJS")) {
+ filter { line ->
+ def l = ""
+ while(!line.equals(l)) {
+ line = line.replace('colorPtToFFRGB$javajs_util_T3d', 'colorPtToFFRGB$javajs_util_T3')
+ l = line
}
+ return line
}
}
}
-
- inputs.files zipFiles
- outputs.dir "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
-}
-
-
-task jalviewjsTransferUnzipAllLibs {
- dependsOn jalviewjsTransferUnzipLib
- dependsOn jalviewjsTransferUnzipSwingJs
+ into "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
}
}
-task jalviewjsSyncAllLibs (type: Sync) {
- dependsOn jalviewjsTransferUnzipAllLibs
- def inputFiles = []
- inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteLibDir}")
- inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
+task jalviewjsSyncLibs (type: Sync) {
+ dependsOn jalviewjsTransferUnzipLib
+ dependsOn jalviewjsTransferUnzipSwingJs
+
+ def inputDir = file("${jalviewDir}/${jalviewjsTransferSiteLibDir}")
+ def inputFiles = fileTree(dir: inputDir)
def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
from inputFiles
into outputDir
def outputFiles = []
- rename { filename ->
- outputFiles += "${outputDir}/${filename}"
- null
+ inputFiles.each{ file ->
+ def rfile = inputDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputDir}/${rfile}")
+ outputFiles += "${ofile}"
}
preserve {
- include "**"
+ include "**/*"
+ }
+
+ duplicatesStrategy "EXCLUDE"
+
+ outputs.files outputFiles
+ inputs.files inputFiles
+}
+
+task jalviewjsSyncSwingJS (type: Sync) {
+ dependsOn jalviewjsTransferUnzipSwingJs
+ mustRunAfter jalviewjsSyncLibs
+
+ def inputDir = file("${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
+ def inputFiles = fileTree(dir: inputDir)
+ def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
+
+ from inputFiles
+ into outputDir
+ def outputFiles = []
+ inputFiles.each{ file ->
+ def rfile = inputDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputDir}/${rfile}")
+ outputFiles += "${ofile}"
+ }
+ preserve {
+ include "**/*"
}
- // should this be exclude really ? No, swingjs dir should be transferred last (and overwrite)
duplicatesStrategy "INCLUDE"
outputs.files outputFiles
inputs.files inputFiles
}
+task jalviewjsSyncAllLibs {
+ dependsOn jalviewjsSyncLibs
+ dependsOn jalviewjsSyncSwingJS
+}
+
task jalviewjsSyncResources (type: Sync) {
dependsOn buildResources
- def inputFiles = fileTree(dir: resourcesBuildDir)
+ def inputDir = file(resourcesBuildDir)
+ def inputFiles = fileTree(dir: inputDir)
def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
from inputFiles
into outputDir
def outputFiles = []
- rename { filename ->
- outputFiles += "${outputDir}/${filename}"
- null
+ inputFiles.each{ file ->
+ def rfile = inputDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputDir}/${rfile}")
+ outputFiles += "${ofile}"
}
preserve {
- include "**"
+ include "**/*"
}
outputs.files outputFiles
inputs.files inputFiles
task jalviewjsSyncSiteResources (type: Sync) {
- def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
+ def inputDir = file("${jalviewDir}/${jalviewjs_site_resource_dir}")
+ def inputFiles = fileTree(dir: inputDir)
def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
from inputFiles
into outputDir
def outputFiles = []
- rename { filename ->
- outputFiles += "${outputDir}/${filename}"
- null
+ inputFiles.each{ file ->
+ def rfile = inputDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputDir}/${rfile}")
+ outputFiles += "${ofile}"
}
preserve {
- include "**"
+ include "**/*"
}
+
outputs.files outputFiles
inputs.files inputFiles
}
task jalviewjsSyncBuildProperties (type: Sync) {
dependsOn createBuildProperties
- def inputFiles = [file(buildProperties)]
+
+ def f = file(buildProperties)
+ def inputDir = f.getParentFile()
+ def inputFiles = [f]
def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
from inputFiles
into outputDir
def outputFiles = []
- rename { filename ->
- outputFiles += "${outputDir}/${filename}"
- null
+ inputFiles.each{ file ->
+ def rfile = inputDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputDir}/${rfile}")
+ outputFiles += "${ofile}"
}
preserve {
- include "**"
+ include "**/*"
}
+
outputs.files outputFiles
inputs.files inputFiles
}
}
//def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
- def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview"
+ def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/${eclipse_project_name}"
+
executable(eclipseBinary)
args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
if (eclipseDebug) {
if (!IN_ECLIPSE) {
args += [ "-D${j2sHeadlessBuildProperty}=true" ]
args += [ "-D${jalviewjs_j2s_alt_file_property}=${jalviewjsJ2sAltSettingsFileName}" ]
+ inputs.file("${jalviewjsJ2sAltSettingsFileName}")
}
- inputs.file("${jalviewDir}/.project")
- outputs.upToDateWhen {
- file(projdir).exists()
- }
+ outputs.upToDateWhen({
+ if (IN_ECLIPSE) {
+ return true
+ }
+ def projDirExists = file(projdir).exists()
+ return projDirExists
+ })
}
task jalviewjsTranspile(type: Exec) {
- dependsOn jalviewjsEclipseSetup
dependsOn jalviewjsProjectImport
- dependsOn jalviewjsEclipsePaths
+
if (!IN_ECLIPSE) {
dependsOn jalviewjsEnableAltFileProperty
}
}
}
+ if (IN_ECLIPSE) {
+ inputs.file(jalviewjsJ2sSettingsFileName)
+ } else {
+ inputs.file(jalviewjsJ2sAltSettingsFileName)
+ }
inputs.dir("${jalviewDir}/${sourceDir}")
- outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
- outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
+
+ def inputJavaDir = file("${jalviewDir}/${sourceDir}")
+ def inputJavaFiles = fileTree(dir: inputJavaDir)
+ def outputJsDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
+ def outputJsFiles = []
+ inputJavaFiles.each{ file ->
+ def rfile = inputJavaDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputJsDir}/${rfile}")
+ def ofilenamejs = ofile.getPath()
+ if (ofilenamejs.endsWith(".java")) {
+ ofilenamejs = ofilenamejs.substring(0,ofilenamejs.length()-4)+"js"
+ }
+ outputJsFiles += "${ofilenamejs}"
+ }
+
+ outputs.files outputJsFiles
+ outputs.file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}")
}
-task jalviewjsTranserSiteMergeLibDirs (type: Sync) {
- dependsOn jalviewjsTransferUnzipAllLibs
+task jalviewjsTransferSiteMergeLibDir (type: Copy) {
+ dependsOn jalviewjsTransferUnzipLib
+
+ def outputDir = "${jalviewDir}/${jalviewjsTransferSiteMergeDir}"
+
+ // This takes the outputs of jalviewjsTransferUnzipLib
+ from jalviewjsTransferUnzipLib
+ into outputDir
+
+ includeEmptyDirs = false
+ exclude "**/*.html"
+ exclude "**/*.htm"
+
+ // should this be exclude really ? No, swingjs dir should be transferred last (and overwrite)
+ duplicatesStrategy "INCLUDE"
+}
+
+task jalviewjsTransferSiteMergeSwingJsDir (type: Copy) {
dependsOn jalviewjsTransferUnzipSwingJs
- dependsOn jalviewjsTranspile
- def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteLibDir}")
- // merge swingjs lib last
- inputFiles += fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}")
+ mustRunAfter jalviewjsTransferSiteMergeLibDir
def outputDir = "${jalviewDir}/${jalviewjsTransferSiteMergeDir}"
- from inputFiles
+ // This takes the outputs of jalviewjsTransferUnzipSwingJs
+ from jalviewjsTransferUnzipSwingJs
into outputDir
- def outputFiles = []
- rename { filename ->
- outputFiles += "${outputDir}/${filename}"
- null
- }
+ includeEmptyDirs = false
exclude "**/*.html"
exclude "**/*.htm"
// should this be exclude really ? No, swingjs dir should be transferred last (and overwrite)
duplicatesStrategy "INCLUDE"
-
- outputs.files outputFiles
- inputs.files inputFiles
}
-
-task jalviewjsTranserSiteMergeSwingDir (type: Sync) {
- dependsOn jalviewjsTransferUnzipAllLibs
- dependsOn jalviewjsTransferUnzipSwingJs
+task jalviewjsTransferSiteMergeSiteJsDir (type: Copy) {
dependsOn jalviewjsTranspile
- // merge jalview files very last
- def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteJsDir}")
+ mustRunAfter jalviewjsTransferSiteMergeLibDir
+ mustRunAfter jalviewjsTransferSiteMergeSwingJsDir
+ def inputDir = file("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
def outputDir = "${jalviewDir}/${jalviewjsTransferSiteMergeDir}"
-
- from inputFiles
into outputDir
- def outputFiles = []
- rename { filename ->
- outputFiles += "${outputDir}/${filename}"
- null
- }
- preserve {
- include "**"
+ from {
+ def inputFiles = fileTree(dir: inputDir)
+ return inputFiles
}
- // should this be exclude really ? No, jalview dir should be transferred last (and overwrite)
+ includeEmptyDirs = false
+ exclude "**/*.html"
+ exclude "**/*.htm"
+
+ // should this be exclude really ? No, swingjs dir should be transferred last (and overwrite)
duplicatesStrategy "INCLUDE"
- outputs.files outputFiles
- inputs.files inputFiles
+ // SiteJs files should take priority and write over existing files if different
+ // so we define the output files
+ outputs.upToDateWhen(
+ {
+ def transpiledFiles = jalviewjsTransferSiteMergeSiteJsDir.getOutputs().getFiles()
+ def inputFiles = fileTree(dir: inputDir)
+ if (inputFiles.size() < transpiledFiles.size()) {
+ return false
+ }
+ def retVal = ! inputFiles.any { file ->
+ def rfile = inputDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputDir}/${rfile}")
+ if (!ofile.exists() || ofile.lastModified() < file.lastModified()) {
+ return true // this is NOTted to false
+ }
+ }
+
+ return retVal
+ }
+ )
+
+ inputs.files jalviewjsTranspile
}
-task jalviewjsTranserSiteMergeDirs {
- dependsOn jalviewjsTranserSiteMergeLibDirs
- dependsOn jalviewjsTranserSiteMergeSwingDir
+task jalviewjsTransferSiteMergeDirs {
+ dependsOn jalviewjsTransferSiteMergeLibDir
+ dependsOn jalviewjsTransferSiteMergeSwingJsDir
+ dependsOn jalviewjsTransferSiteMergeSiteJsDir
}
main = "com.google.javascript.jscomp.CommandLineRunner"
jvmArgs = [ "-Dfile.encoding=UTF-8" ]
args = [ "--compilation_level", jalviewjs_closure_compiler_optimization_level, "--warning_level", "QUIET", "--charset", "UTF-8", "--js", jsfile, "--js_output_file", zjsfile ]
- maxHeapSize = "2g"
+ maxHeapSize = "4g"
msg = "\nRunning '"+commandLine.join(' ')+"'\n"
println(msg)
task jalviewjsBuildAllCores {
group "JalviewJS"
description "Build the core js lib closures listed in the classlists dir"
- dependsOn jalviewjsTranserSiteMergeDirs
+ dependsOn jalviewjsTransferSiteMergeDirs
def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteMergeDir}/${jalviewjs_j2s_subdir}"
def swingJ2sDir = "${jalviewDir}/${jalviewjsTransferSiteMergeDir}/${jalviewjs_j2s_subdir}"
outputs.file(zjsfile)
}
- // _all core
- def allClasslistName = "_all"
- def allJsFiles = fileTree(dir: j2sDir, include: "**/*.js")
- allJsFiles += fileTree(
- dir: libJ2sDir,
- include: "**/*.js",
- excludes: [
- // these exlusions are files that the closure-compiler produces errors for. Should fix them
- "**/org/jmol/jvxl/readers/IsoIntersectFileReader.js",
- "**/org/jmol/export/JSExporter.js"
- ]
- )
- allJsFiles += fileTree(
- dir: swingJ2sDir,
- include: "**/*.js",
- excludes: [
- // these exlusions are files that the closure-compiler produces errors for. Should fix them
- "**/sun/misc/Unsafe.js",
- "**/swingjs/jquery/jquery-editable-select.js",
- "**/swingjs/jquery/j2sComboBox.js",
- "**/sun/misc/FloatingDecimal.js"
- ]
- )
- def allClasslist = [
- 'jsfile': "${outputDir}/core${allClasslistName}.js",
- 'zjsfile': "${outputDir}/core${allClasslistName}.z.js",
- 'list': allJsFiles,
- 'name': allClasslistName
- ]
- // not including this version of "all" core at the moment
- //jalviewjsCoreClasslists += allClasslist
- inputs.files(allClasslist['list'])
- outputs.file(allClasslist['jsfile'])
- outputs.file(allClasslist['zjsfile'])
-
doFirst {
def logOutFile = file("${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_closure_stdout}")
logOutFile.getParentFile().mkdirs()
dependsOn jalviewjsBuildAllCores
dependsOn jalviewjsPublishCoreTemplates
- def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
+ def inputDir = file("${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
+ def inputFiles = fileTree(dir: inputDir)
def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
from inputFiles
into outputDir
def outputFiles = []
- rename { filename ->
- outputFiles += "${outputDir}/${filename}"
- null
+ inputFiles.each{ file ->
+ def rfile = inputDir.toPath().relativize(file.toPath())
+ def ofile = new File("${outputDir}/${rfile}")
+ outputFiles += "${ofile}"
}
preserve {
- include "**"
+ include "**/*"
}
+
outputs.files outputFiles
inputs.files inputFiles
}
// this Copy version of TransferSiteJs will delete anything else in the target dir
task jalviewjsCopyTransferSiteMergeDir(type: Copy) {
- dependsOn jalviewjsTranserSiteMergeDirs
+ dependsOn jalviewjsTransferSiteMergeDirs
from "${jalviewDir}/${jalviewjsTransferSiteMergeDir}"
into "${jalviewDir}/${jalviewjsSiteDir}"
include "**/*.*"
into "${jalviewDir}/${jalviewjsSiteDir}"
preserve {
- include "**"
+ include "**/*"
}
}