eclipseWorkspace = null
eclipseBinary = string("")
eclipseVersion = string("")
+ eclipseProductVersion = string("")
eclipseDebug = false
jalviewjsChromiumUserDir = "${jalviewjsBuildDir}/${jalviewjs_chromium_user_dir}"
task jalviewjsEclipsePaths {
- def eclipseProduct
+ def eclipseProductFile
+ def eclipseSetupLog
def eclipseRoot = jalviewjs_eclipse_root
if (eclipseRoot.startsWith("~/")) {
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"))
if (!assumedVersion) {
println("ECLIPSE VERSION=${eclipseVersion}")
+ if (eclipseProductVersion.length() != 0) {
+ println("ECLIPSE PRODUCT=${eclipseProductVersion}")
+ }
}
}
}
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
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}'")