println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
}
- //inputs.property(propKey, eclipseWsDir) // eclipseWsDir only gets set once this task runs, so will be out-of-date
+ inputs.property(propKey, eclipseWsDir)
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"
+ def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
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_transpile_stdout}"
+ def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_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_transpile_stdout}'")
+ throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
}
}
outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteJsDir}${jalviewjs_server_resource}").exists() } )
}
-// this Copy version of TransferSiteJs will delete anything else in the target dir
-task jalviewjsCopyTransferSiteJs(type: Copy) {
+// this Copy version of TransferSite will delete anything else in the target dir
+task jalviewjsCopyTransferSite(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 jalviewjsSyncTransferSiteJs(type: Sync) {
+task jalviewjsSyncTransferSite(type: Sync) {
from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
include "**/*.*"
into "${jalviewDir}/${jalviewjsSiteDir}"
}
}
-jalviewjsSyncLib.mustRunAfter jalviewjsCopyTransferSiteJs
-jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSiteJs
-jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSiteJs
-jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSiteJs
+jalviewjsSyncLib.mustRunAfter jalviewjsCopyTransferSite
+jalviewjsSyncResources.mustRunAfter jalviewjsCopyTransferSite
+jalviewjsSyncSiteResources.mustRunAfter jalviewjsCopyTransferSite
+jalviewjsSyncBuildProperties.mustRunAfter jalviewjsCopyTransferSite
-jalviewjsSyncLib.mustRunAfter jalviewjsSyncTransferSiteJs
-jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSiteJs
-jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSiteJs
-jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSiteJs
+jalviewjsSyncLib.mustRunAfter jalviewjsSyncTransferSite
+jalviewjsSyncResources.mustRunAfter jalviewjsSyncTransferSite
+jalviewjsSyncSiteResources.mustRunAfter jalviewjsSyncTransferSite
+jalviewjsSyncBuildProperties.mustRunAfter jalviewjsSyncTransferSite
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 jalviewjsCopyTransferSiteJs
+ dependsOn jalviewjsCopyTransferSite
dependsOn jalviewjsPrepareSite
}
task cleanJalviewjsSite {
doFirst {
delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
- delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
- delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
delete "${jalviewDir}/${jalviewjsSiteDir}"
}
}
}
-task jalviewjsIDE_CopyTransferSiteJs(type: Copy) {
+task jalviewjsIDE_CopyTransferSite(type: Copy) {
from "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
into "${jalviewDir}/${jalviewjsSiteDir}"
}
-task jalviewjsIDE_j2sFile {
+task jalviewjsIDE_j2s {
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_CopyTransferSiteJs
+ dependsOn jalviewjsIDE_CopyTransferSite
dependsOn jalviewjsPrepareSite
}
// buildship runs this at import
task eclipseSynchronizationTask {
dependsOn eclipseSetup
- dependsOn jalviewjsIDE_j2sFile
+ dependsOn jalviewjsIDE_j2s
}
// buildship runs this at build time
task eclipseAutoBuildTask {
- dependsOn jalviewjsSyncTransferSiteJs
+ dependsOn jalviewjsSyncTransferSite
dependsOn jalviewjsPrepareSite
}
// 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)
+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 )
t.replaceAll("Class__","Clazz._")
coreFile.append( t )
} else {
- msg = "...file "+f.getPath()+" does not exist, skipping"
- println(msg)
- logOutFile.append(msg+"\n")
+ println("...file ${line} does not exist, skipping")
}
}
coreFile.append( coreBottom.text )
- msg = "Generating ${zjsfile}"
- println(msg)
- logOutFile.append(msg+"\n")
- def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
- def logErrFOS = logOutFOS
+ 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", 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)
- }
+ args = [ "--js", coreFileName, "--js_output_file", coreZFileName ]
+ workingDir = outputDir
}
- msg = "--"
- println(msg)
- logOutFile.append(msg+"\n")
+
+ 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"
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"
- 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"))
- }
+ jalviewjsToJs(name, file.getAbsolutePath(), "${jalviewDir}/${jalviewjsTransferSiteLibDir}/${jalviewjs_js_subdir}", "${jalviewDir}/${jalviewjsTransferSiteJsDir}/${jalviewjs_j2s_subdir}", "${jalviewDir}/${jalviewjsTransferSiteCoreDir}/${jalviewjs_j2s_subdir}/core")
}
-
}