def jalviewjsBuildDir
def jalviewjsSiteDir
-def jalviewjsTransferSiteJSDir
+def jalviewjsTransferSiteJsDir
def jalviewjsTransferSiteLibDir
+def jalviewjsTransferSiteCoreDir
task jalviewjsSitePath {
def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
jalviewjsSiteDir = "${jalviewjsBuildDir}/${jalviewjs_site_dir}"
- jalviewjsTransferSiteJSDir = "${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js"
+ jalviewjsTransferSiteJsDir = "${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js"
jalviewjsTransferSiteLibDir = "${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib"
+ jalviewjsTransferSiteCoreDir = "${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core"
}
def eclipseWorkspace
if (val != null) {
if (prop == siteDirProperty) {
if (!(val.startsWith('/') || val.startsWith("file://") )) {
- val = "${jalviewDir}/${jalviewjsTransferSiteJSDir}/${val}"
+ val = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${val}"
}
setSiteDir = true
}
property(prop,val)
}
if (!setSiteDir) { // default site location, don't override specifically set property
- property(siteDirProperty,"${jalviewDir}/${jalviewjsTransferSiteJSDir}")
+ property(siteDirProperty,"${jalviewDir}/${jalviewjsTransferSiteJsDir}")
}
}
inputs.properties(j2s_props)
inputs.files inputFiles
}
+task jalviewjsSyncCore (type: Sync) {
+ dependsOn jalviewjsSitePath
+ dependsOn "jalviewjsBuildAllCores"
+ def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjsTransferSiteCoreDir}")
+ def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
+
+ from inputFiles
+ into outputDir
+ def outputFiles = []
+ rename { filename ->
+ outputFiles += "${outputDir}/${filename}"
+ null
+ }
+ preserve {
+ include "**"
+ }
+ outputs.files outputFiles
+ inputs.files inputFiles
+}
+
task jalviewjsSyncResources (type: Sync) {
dependsOn jalviewjsSitePath
def inputFiles = fileTree(dir: "${jalviewDir}/${resourceDir}")
}
inputs.dir("${jalviewDir}/${sourceDir}")
- outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJSDir}")
- outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJSDir}${jalviewjs_server_resource}").exists() } )
+ outputs.dir("${jalviewDir}/${jalviewjsTransferSiteJsDir}")
+ outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
}
// this Copy version of TransferSite will delete anything else in the target dir
task jalviewjsCopyTransferSite(type: Copy) {
dependsOn jalviewjsTranspile
- from "${jalviewDir}/${jalviewjsTransferSiteJSDir}"
+ from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
into "${jalviewDir}/${jalviewjsSiteDir}"
}
// this Sync version of TransferSite is used by buildship to keep the website automatically up to date when a file changes
task jalviewjsSyncTransferSite(type: Sync) {
- from "${jalviewDir}/${jalviewjsTransferSiteJSDir}"
+ from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
include "**/*.*"
into "${jalviewDir}/${jalviewjsSiteDir}"
preserve {
task cleanJalviewjsSite {
doFirst {
- delete "${jalviewDir}/${jalviewjsTransferSiteJSDir}"
+ delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
delete "${jalviewDir}/${jalviewjsSiteDir}"
}
}
task jalviewjsIDE_CopyTransferSite(type: Copy) {
- from "${jalviewDir}/${jalviewjsTransferSiteJSDir}"
+ from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
into "${jalviewDir}/${jalviewjsSiteDir}"
}
dependsOn jalviewjsSyncTransferSite
dependsOn jalviewjsPrepareSite
}
+
+
+
+
+
+
+
+
+// closure
+def jalviewjsCallCore(String name, FileCollection list, String jsDir, String outputDir) {
+ def coreFileName = "core${name}.js"
+ def coreFilePath = "${outputDir}/${coreFileName}"
+ def coreFile = file(coreFilePath)
+ println("...Generating ${coreFilePath}")
+
+ def coreTop = file("${jsDir}/core/coretop2.js")
+ def coreBottom = file("${jsDir}/core/corebottom2.js")
+ coreFile.getParentFile().mkdirs()
+ coreFile.createNewFile()
+ coreFile.write( coreTop.text )
+ list.each {
+ f ->
+ if (f.exists()) {
+ def t = f.text
+ t.replaceAll("Clazz\\.","Clazz_")
+ t.replaceAll("Class__","Clazz._")
+ coreFile.append( t )
+ } else {
+ println("...file ${line} does not exist, skipping")
+ }
+ }
+ coreFile.append( coreBottom.text )
+
+ def coreZFileName = "core${name}.z.js"
+ def coreZFilePath = "${outputDir}/${coreZFileName}"
+ def coreZFile = file(coreZFilePath)
+ println("...Generating ${coreZFilePath}")
+
+ javaexec {
+ classpath = files(["${jalviewDir}/tools/closure_compiler.jar"])
+ args = [ "--js", coreFileName, "--js_output_file", coreZFileName ]
+ workingDir = outputDir
+ }
+
+ return [ coreFile, coreZFile ]
+}
+
+def jalviewjsToJs(String name, String classlist, String jsDir, String j2sDir, String outputDir) {
+ def filelist = []
+ file(classlist).eachLine {
+ line ->
+ filelist += line
+ }
+ def list = fileTree(dir: j2sDir, includes: filelist)
+ /*
+ def list = files()
+ file(classlist).eachLine {
+ line ->
+ list += file("${j2sDir}/${line}")
+ }
+ */
+
+ return jalviewjsCallCore(name, list, jsDir, outputDir)
+// publish-core-template ... here?
+}
+
+task jalviewjsBuildAllCores {
+ group "JalviewJS"
+ description "Build the core js lib closures"
+
+ dependsOn jalviewjsSitePath
+ dependsOn jalviewjsTransferUnzipLib
+ dependsOn jalviewjsTranspile
+
+ fileTree(dir: "${jalviewDir}/${jalviewjs_classlists_dir}", include: "*.txt").each {
+ file ->
+ def name = file.getName() - ".txt"
+
+ jalviewjsToJs(name, file.getAbsolutePath(), "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${jalviewjs_js_subdir}", "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}", "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core")
+ }
+}