println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
}
- inputs.property(propKey, eclipseWsDir)
+ //inputs.property(propKey, eclipseWsDir) // eclipseWsDir only gets set once this task runs, so will be out-of-date
outputs.file(propsFileName)
+ outputs.upToDateWhen { eclipseWorkspace.exists() }
}
dependsOn jalviewjsEclipsePaths
dependsOn jalviewjsEclipseSetup
- 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/org.eclipse.jdt.core"
+ def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview"
executable(eclipseBinary)
args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
if (eclipseDebug) {
args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
inputs.file("${jalviewDir}/.project")
- outputs.upToDateWhen { file(projdir).exists() }
+ outputs.upToDateWhen {
+ file(projdir).exists()
+ }
}
task jalviewjsTranspile(type: Exec) {
stdout = new ByteArrayOutputStream()
stderr = new ByteArrayOutputStream()
- def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
+ def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}"
def logOutFile = file(logOutFileName)
logOutFile.createNewFile()
logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
doLast {
if (stdout.toString().contains("Error processing ")) {
// j2s did not complete transpile
- throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
+ throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
}
}
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) {
+// this Copy version of TransferSiteJs will delete anything else in the target dir
+task jalviewjsCopyTransferSiteJs(type: Copy) {
dependsOn jalviewjsTranspile
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) {
+task jalviewjsSyncTransferSiteJs(type: Sync) {
from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
include "**/*.*"
into "${jalviewDir}/${jalviewjsSiteDir}"
}
}
-jalviewjsSyncLib.mustRunAfter jalviewjsCopyTransferSite
-jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSite
-jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSite
-jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSite
+jalviewjsSyncLib.mustRunAfter jalviewjsCopyTransferSiteJs
+jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSiteJs
+jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSiteJs
+jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSiteJs
-jalviewjsSyncLib.mustRunAfter jalviewjsSyncTransferSite
-jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSite
-jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSite
-jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSite
+jalviewjsSyncLib.mustRunAfter jalviewjsSyncTransferSiteJs
+jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSiteJs
+jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSiteJs
+jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSiteJs
task jalviewjsPrepareSite {
group "JalviewJS"
dependsOn jalviewjsSyncResources
dependsOn jalviewjsSyncSiteResources
dependsOn jalviewjsSyncBuildProperties
+ dependsOn jalviewjsSyncCore
}
task jalviewjsBuildSite {
group "JalviewJS"
description "Builds the whole website including transpiled code"
- dependsOn jalviewjsCopyTransferSite
+ dependsOn jalviewjsCopyTransferSiteJs
dependsOn jalviewjsPrepareSite
}
task cleanJalviewjsSite {
doFirst {
delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
+ delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
+ delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
delete "${jalviewDir}/${jalviewjsSiteDir}"
}
}
}
-task jalviewjsIDE_CopyTransferSite(type: Copy) {
+task jalviewjsIDE_CopyTransferSiteJs(type: Copy) {
from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
into "${jalviewDir}/${jalviewjsSiteDir}"
}
-task jalviewjsIDE_j2s {
+task jalviewjsIDE_j2sFile {
group "00 JalviewJS in Eclipse"
description "Creates the .j2s file"
dependsOn jalviewjsCreateJ2sSettings
task jalviewjsIDE_AssembleSite {
group "00 JalviewJS in Eclipse"
description "Assembles the Eclipse transpiled site and unzips supporting zipfiles"
- dependsOn jalviewjsIDE_CopyTransferSite
+ dependsOn jalviewjsIDE_CopyTransferSiteJs
dependsOn jalviewjsPrepareSite
}
// buildship runs this at import
task eclipseSynchronizationTask {
dependsOn eclipseSetup
- dependsOn jalviewjsIDE_j2s
+ dependsOn jalviewjsIDE_j2sFile
}
// buildship runs this at build time
task eclipseAutoBuildTask {
- dependsOn jalviewjsSyncTransferSite
+ dependsOn jalviewjsSyncTransferSiteJs
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")
+
+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 )
t.replaceAll("Class__","Clazz._")
coreFile.append( t )
} else {
- println("...file ${line} does not exist, skipping")
+ msg = "...file "+f.getPath()+" does not exist, skipping"
+ println(msg)
+ logOutFile.append(msg+"\n")
}
}
coreFile.append( coreBottom.text )
- def coreZFileName = "core${name}.z.js"
- def coreZFilePath = "${outputDir}/${coreZFileName}"
- def coreZFile = file(coreZFilePath)
- println("...Generating ${coreZFilePath}")
+ 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", coreFileName, "--js_output_file", coreZFileName ]
- workingDir = outputDir
- }
+ args = [ "--js", jsfile, "--js_output_file", zjsfile ]
- return [ coreFile, coreZFile ]
-}
+ msg = "\nRunning '"+commandLine.join(' ')+"'\n"
+ println(msg)
+ logOutFile.append(msg+"\n")
-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}")
+ 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)
+ }
}
- */
-
- return jalviewjsCallCore(name, list, jsDir, outputDir)
-// publish-core-template ... here?
+ msg = "--"
+ println(msg)
+ logOutFile.append(msg+"\n")
}
+
+
task jalviewjsBuildAllCores {
group "JalviewJS"
description "Build the core js lib closures"
dependsOn jalviewjsTransferUnzipLib
dependsOn jalviewjsTranspile
+ def j2sDir = "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}"
+ def jsDir = "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${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 classlists = []
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")
+ def filelist = []
+ file.eachLine {
+ line ->
+ filelist += line
+ }
+ def list = fileTree(dir: j2sDir, includes: filelist)
+
+ def coreFileName = "core${name}.js"
+ def jsfile = "${outputDir}/${coreFileName}"
+ def coreZFileName = "core${name}.z.js"
+ def zjsfile = "${outputDir}/${coreZFileName}"
+
+ classlists += [
+ 'jsfile': jsfile,
+ 'zjsfile': zjsfile,
+ 'list': list
+ ]
+
+ inputs.file(file)
+ inputs.files(list)
+ outputs.file(jsfile)
+ outputs.file(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")+" jalviewjsBuildAllCores\n----\n")
+
+ classlists.each {
+ jalviewjsCallCore(it.list, prefixFile, suffixFile, it.jsfile, it.zjsfile, logOutFile, jalviewjs_j2s_to_console.equals("true"))
+ }
}
+
}