- dependsOn jalviewjsNoTranspileSyncTransferSiteJs
- dependsOn jalviewjsNoTranspilePrepareSite
-}
-
-
-
-
-
-
-
-
-// closure
-
-def jalviewjsCallCore(FileCollection list, String prefixFile, String suffixFile, String jsfile, String zjsfile, File logOutFile, Boolean logOutConsole) {
-
- def stdout = new ByteArrayOutputStream()
- def stderr = new ByteArrayOutputStream()
-
- def coreFile = file(jsfile)
- def msg = ""
- msg = "Generating ${jsfile}"
- println(msg)
- logOutFile.createNewFile()
- logOutFile.append(msg+"\n")
-
- def coreTop = file(prefixFile)
- def coreBottom = file(suffixFile)
- 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 {
- msg = "...file '"+f.getPath()+"' does not exist, skipping"
- println(msg)
- logOutFile.append(msg+"\n")
- }
- }
- coreFile.append( coreBottom.text )
-
- msg = "Generating ${zjsfile}"
- println(msg)
- logOutFile.append(msg+"\n")
- def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
- def logErrFOS = logOutFOS
-
- javaexec {
- classpath = files(["${jalviewDir}/tools/closure_compiler.jar"])
- args = [ "--js", jsfile, "--js_output_file", zjsfile ]
-
- msg = "\nRunning '"+commandLine.join(' ')+"'\n"
- println(msg)
- logOutFile.append(msg+"\n")
-
- if (logOutConsole) {
- standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
- new org.apache.tools.ant.util.TeeOutputStream(
- logOutFOS,
- stdout),
- standardOutput)
- errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
- new org.apache.tools.ant.util.TeeOutputStream(
- logErrFOS,
- stderr),
- errorOutput)
- } else {
- standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
- logOutFOS,
- stdout)
- errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
- logErrFOS,
- stderr)
- }
- }
- msg = "--"
- println(msg)
- logOutFile.append(msg+"\n")
-}
-
-
-task jalviewjsNoTranspileBuildAllCores {
- dependsOn jalviewjsSitePath
- dependsOn jalviewjsTransferUnzipSwingJs
-
- def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}"
- def jsDir = "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}/${jalviewjs_js_subdir}"
- def outputDir = "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core"
- def prefixFile = "${jsDir}/core/coretop2.js"
- def suffixFile = "${jsDir}/core/corebottom2.js"
-
- inputs.file prefixFile
- inputs.file suffixFile
-
- def classlistFiles = []
- // add the classlists found int the jalviewjs_classlists_dir
- fileTree(dir: "${jalviewDir}/${jalviewjs_classlists_dir}", include: "*.txt").each {
- file ->
- def name = file.getName() - ".txt"
- classlistFiles += [
- 'file': file,
- 'name': name
- ]
- }
-
- // _jmol and _jalview cores. Add any other peculiar classlist.txt files here
- classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jmol}"), 'name': "_jvjmol" ]
- classlistFiles += [ 'file': file("${jalviewDir}/${jalviewjs_classlist_jalview}"), 'name': "_jalview" ]
-
- def classlists = []
-
- classlistFiles.each {
- hash ->
-
- def file = hash['file']
- if (! file.exists()) {
- println("...classlist file '"+file.getPath()+"' does not exist, skipping")
- return false // this is a "continue" in groovy .each closure
- }
- def name = hash['name']
- if (name == null) {
- name = file.getName() - ".txt"
- }
-
- def filelist = []
- file.eachLine {
- line ->
- filelist += line
- }
- def list = fileTree(dir: j2sDir, includes: filelist)
-
- def jsfile = "${outputDir}/core${name}.js"
- def zjsfile = "${outputDir}/core${name}.z.js"
-
- classlists += [
- 'jsfile': jsfile,
- 'zjsfile': zjsfile,
- 'list': list
- ]
-
- inputs.file(file)
- inputs.files(list)
- outputs.file(jsfile)
- outputs.file(zjsfile)
- }
-
- // _stevesoft core. add any cores without a classlist here (and the inputs and outputs)
- def stevesoftClasslist = [
- 'jsfile': "${outputDir}/core_stevesoft.js",
- 'zjsfile': "${outputDir}/core_stevesoft.z.js",
- 'list': fileTree(dir: j2sDir, include: "com/stevesoft/pat/**/*.js")
- ]
- classlists += stevesoftClasslist
- inputs.files(stevesoftClasslist['list'])
- outputs.file(stevesoftClasslist['jsfile'])
- outputs.file(stevesoftClasslist['zjsfile'])
-
- doFirst {
- def logOutFile = file("${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_closure_stdout}")
- logOutFile.getParentFile().mkdirs()
- logOutFile.createNewFile()
- logOutFile.write(getDate("yyyy-MM-dd HH:mm:ss")+" jalviewjsNoTranspileBuildAllCores\n----\n")
-
- classlists.each {
- jalviewjsCallCore(it.list, prefixFile, suffixFile, it.jsfile, it.zjsfile, logOutFile, jalviewjs_j2s_to_console.equals("true"))
- }
- }
-
-}
-
-
-jalviewjsNoTranspileBuildAllCores.mustRunAfter jalviewjsTranspile
-
-
-task jalviewjsBuildAllCores {
- group "JalviewJS"
- description "Build the core js lib closures listed in the classlists dir"
- dependsOn jalviewjsTranspile
- dependsOn jalviewjsNoTranspileBuildAllCores
-}
-
-
-task jalviewjsIDE_BuildAllCores {
- group "00 JalviewJS in Eclipse"
- description "Build the core js lib closures listed in the classlists dir"
- dependsOn jalviewjsNoTranspileBuildAllCores
-}
-
-
-task jalviewjsPublishCoreTemplate {
- dependsOn jalviewjsBuildAllCores