JAL-4235 JAL-3599 Try and report Eclipse Product Version for jalviewjsTranspile....
authorBen Soares <b.soares@dundee.ac.uk>
Tue, 18 Jul 2023 10:53:26 +0000 (11:53 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Tue, 18 Jul 2023 10:53:26 +0000 (11:53 +0100)
build.gradle
gradle.properties

index 7ad6f99..2c6a8b5 100644 (file)
@@ -577,6 +577,7 @@ ext {
   eclipseWorkspace = null
   eclipseBinary = string("")
   eclipseVersion = string("")
+  eclipseProductVersion = string("")
   eclipseDebug = false
 
   jalviewjsChromiumUserDir = "${jalviewjsBuildDir}/${jalviewjs_chromium_user_dir}"
@@ -3235,7 +3236,8 @@ task jalviewjsSetEclipseWorkspace {
 
 
 task jalviewjsEclipsePaths {
-  def eclipseProduct
+  def eclipseProductFile
+  def eclipseSetupLog
 
   def eclipseRoot = jalviewjs_eclipse_root
   if (eclipseRoot.startsWith("~/")) {
@@ -3244,32 +3246,49 @@ task jalviewjsEclipsePaths {
   if (OperatingSystem.current().isMacOsX()) {
     eclipseRoot += "/Eclipse.app"
     eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
-    eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
+    eclipseProductFile = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
+    eclipseSetupLog = "${eclipseRoot}/Contents/Eclipse/configuration/org.eclipse.oomph.setup/setup.log"
   } else if (OperatingSystem.current().isWindows()) { // check these paths!!
     if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
       eclipseRoot += "/eclipse"
     }
     eclipseBinary = "${eclipseRoot}/eclipse.exe"
-    eclipseProduct = "${eclipseRoot}/.eclipseproduct"
+    eclipseProductFile = "${eclipseRoot}/.eclipseproduct"
+    eclipseSetupLog = "${eclipseRoot}/configuration/org.eclipse.oomph.setup/setup.log"
   } else { // linux or unix
     if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
       eclipseRoot += "/eclipse"
-println("eclipseDir exists")
     }
     eclipseBinary = "${eclipseRoot}/eclipse"
-    eclipseProduct = "${eclipseRoot}/.eclipseproduct"
+    eclipseProductFile = "${eclipseRoot}/.eclipseproduct"
+    eclipseSetupLog = "${eclipseRoot}/configuration/org.eclipse.oomph.setup/setup.log"
   }
 
-  eclipseVersion = "4.13" // default
+  eclipseVersion = "unknown" // default
   def assumedVersion = true
-  if (file(eclipseProduct).exists()) {
-    def fis = new FileInputStream(eclipseProduct)
+  if (file(eclipseProductFile).exists()) {
+    def fis = new FileInputStream(eclipseProductFile)
     def props = new Properties()
     props.load(fis)
     eclipseVersion = props.getProperty("version")
     fis.close()
     assumedVersion = false
   }
+  if (file(eclipseSetupLog).exists()) {
+    def productRegex = /(?m)^\[[^\]]+\]\s+Product\s+(org\.eclipse.\S*)/
+    int lineCount = 0
+    file(eclipseSetupLog).eachLine { String line ->
+      def matcher = line =~ productRegex
+      if (matcher.size() > 0) {
+        eclipseProductVersion = matcher[0][1]
+        return true
+      }
+      if (lineCount >= 100) {
+        return true
+      }
+      lineCount++
+    }
+  }
   
   def propKey = "eclipse_debug"
   eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
@@ -3285,6 +3304,9 @@ println("eclipseDir exists")
 
     if (!assumedVersion) {
       println("ECLIPSE VERSION=${eclipseVersion}")
+      if (eclipseProductVersion.length() != 0) {
+        println("ECLIPSE PRODUCT=${eclipseProductVersion}")
+      }
     }
   }
 }
@@ -3577,11 +3599,12 @@ task jalviewjsTranspile(type: Exec) {
     def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}"
     def logOutFile = file(logOutFileName)
     logOutFile.createNewFile()
-    logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
-BINARY: ${eclipseBinary}
-VERSION: ${eclipseVersion}
-WORKSPACE: ${eclipseWorkspace}
-DEBUG: ${eclipseDebug}
+    def info = """ROOT: ${jalviewjs_eclipse_root}
+ECLIPSE BINARY: ${eclipseBinary}
+ECLIPSE VERSION: ${eclipseVersion}
+ECLIPSE PRODUCT: ${eclipseProductVersion}
+ECLIPSE WORKSPACE: ${eclipseWorkspace}
+ECLIPSE DEBUG: ${eclipseDebug}
 ----
 """
     def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
@@ -3607,12 +3630,58 @@ DEBUG: ${eclipseDebug}
         logErrFOS,
         stderr)
     }
+    standardOutput.write(string(info).getBytes("UTF-8"))
   }
 
   doLast {
-    if (stdout.toString().contains("Error processing ")) {
+    def transpileError = false
+    def j2sIsActive = false
+    def j2sBuildStarting = false
+    def compilingLines = 0
+    def j2sBuildingJavascript = false
+    def j2sBuildingJavascriptRegex = /(?m)^J2S building JavaScript for (\d+) files/
+    def numFiles = 0
+    def transpilingLines = 0
+    stdout.toString().eachLine { String line ->
+      if (line.startsWith("J2S isActive true")) {
+        j2sIsActive = true
+      }
+      if (line.startsWith("J2S buildStarting")) {
+        j2sBuildStarting = true
+      }
+      if (line =~ / Compiling /) {
+        compilingLines++
+      }
+      if (!j2sBuildingJavascript) {
+        def matcher = line =~ j2sBuildingJavascriptRegex
+        if (matcher.size() > 0) {
+          numFiles = Integer.valueOf(matcher[0][1])
+          j2sBuildingJavascript = true
+        }
+      }
+      if (line.startsWith("J2S transpiling ")) {
+        transpilingLines++
+      }
+      if (line.contains("Error processing ")) {
+        transpileError = true
+      }
+    }
+    
+    println("J2S IS ACTIVE=${j2sIsActive}")
+    println("J2S BUILD STARTING=${j2sBuildStarting}")
+    println("J2S BUILDING JAVASCRIPT=${j2sBuildingJavascript}")
+    println("NUM FILES=${numFiles}")
+    println("COMPILING LINES=${compilingLines}")
+    println("TRANSPILING LINES=${transpilingLines}")
+    println("TRANSPILE ERROR=${transpileError}")
+    
+    if (!j2sIsActive
+        || transpileError
+        || (j2sBuildStarting && transpilingLines == 0)
+        || (transpilingLines < compilingLines)
+        || (transpilingLines != numFiles)
+        ) {
       // j2s did not complete transpile
-      //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
       if (jalviewjs_ignore_transpile_errors.equals("true")) {
         println("IGNORING TRANSPILE ERRORS")
         println("See eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
index 547304f..060bdfe 100644 (file)
@@ -228,7 +228,7 @@ jalviewjs_core_name = _jalview
 jalviewjs_name = JalviewJS
 jalviewjs_core_key = core
 #jalviewjs_core_key = preloadCore
-jalviewjs_ignore_transpile_errors = true
+jalviewjs_ignore_transpile_errors = false
 
 j2s.compiler.status = enable
 #j2s.site.directory = null ## site defined from buildDir+'/jalviewjs/'+jalviewjs_site_dir