From db3936d2efd977012b614888cf5b186725a662af Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 8 Nov 2019 10:18:12 +0000 Subject: [PATCH] Revert "JAL-3210 Added jalviewjsBuildAllClosures. Improved incrementality of jalviewjsSetEclipseWorkspace and jalviewjsProjectImport and hence jalviewjsTranspile :)" This reverts commit 9fe5286cbcbbfdca0e9548e6ab1b6543871a8073. Seems to have broken development in Eclipse IDE. Reverting. --- build.gradle | 182 +++++++++++++++++------------------------------------ gradle.properties | 3 +- 2 files changed, 58 insertions(+), 127 deletions(-) diff --git a/build.gradle b/build.gradle index 52c0385..a88c42f 100644 --- a/build.gradle +++ b/build.gradle @@ -1331,9 +1331,8 @@ task jalviewjsSetEclipseWorkspace { 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() } } @@ -1620,8 +1619,7 @@ task jalviewjsProjectImport(type: Exec) { 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) { @@ -1630,9 +1628,7 @@ task jalviewjsProjectImport(type: Exec) { 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) { @@ -1653,7 +1649,7 @@ 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} @@ -1695,7 +1691,7 @@ DEBUG: ${eclipseDebug} 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}'") } } @@ -1704,15 +1700,15 @@ DEBUG: ${eclipseDebug} 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}" @@ -1721,15 +1717,15 @@ task jalviewjsSyncTransferSiteJs(type: Sync) { } } -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" @@ -1738,21 +1734,18 @@ task jalviewjsPrepareSite { 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}" } } @@ -1840,12 +1833,12 @@ task jalviewjs { } -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 @@ -1854,7 +1847,7 @@ task jalviewjsIDE_j2sFile { 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 } @@ -1873,12 +1866,12 @@ task jalviewjsIDE_Server { // 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 } @@ -1890,21 +1883,14 @@ task eclipseAutoBuildTask { // 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 ) @@ -1916,53 +1902,43 @@ def jalviewjsCallCore(FileCollection list, String prefixFile, String suffixFile, 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" @@ -1972,54 +1948,10 @@ task jalviewjsBuildAllCores { 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") } - } diff --git a/gradle.properties b/gradle.properties index 444d333..d602a9c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -195,10 +195,9 @@ j2s.template.html = utils/jalviewjs/template.html #output will be comma-separated: called method,caller class #j2s.prop.j2s.log.all.calls=true -jalviewjs_j2s_transpile_stdout = j2s-transpile.out +jalviewjs_j2s_stdout = j2s-transpile.out #jalviewjs_j2s_stderr = j2s-transpile.err # all going into out jalviewjs_j2s_to_console = true -jalviewjs_j2s_closure_stdout = j2s-closure.out testp=gradle.properties -- 1.7.10.2