Merge branch 'Jalview-JS/develop' into Jalview-JS/develop_with_gradle_build
[jalview.git] / build.gradle
index d259e13..c9b1332 100644 (file)
@@ -1306,10 +1306,9 @@ def eclipseVersion
 def eclipseDebug = false
 def eclipseVersionSuffix = ""
 task jalviewjsEclipsePaths {
-  def eclipseRoot
   def eclipseProduct
 
-  eclipseRoot = jalviewjs_eclipse_root
+  def eclipseRoot = jalviewjs_eclipse_root
   if (eclipseRoot.startsWith("~")) {
     eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
   }
@@ -1364,8 +1363,16 @@ task jalviewjsEclipsePaths {
   }
 }
 
-task jalviewjsEclipseCopyDropins {
+task eclipseSetup {
+  dependsOn eclipseProject
+  dependsOn eclipseClasspath
+  dependsOn eclipseJdt
+}
+
+/* using the Copy task below
+task OLDjalviewjsEclipseCopyDropins {
   dependsOn jalviewjsEclipsePaths
+  dependsOn jalviewjsCleanEclipse
   def inputFiles = fileTree(dir: utilsDropinsDir, include: "*.jar")
   def outputDir = eclipseDropinsDir
 
@@ -1383,14 +1390,43 @@ task jalviewjsEclipseCopyDropins {
     }
   }
 }
+*/
 
 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
-task NEWjalviewjsEclipseCopyDropins(type: Copy) {
+task jalviewjsEclipseCopyDropins(type: Copy) {
   dependsOn jalviewjsEclipsePaths
+
   from utilsDropinsDir
   into eclipseDropinsDir
 }
 
+// this eclipse -clean doesn't actually work
+task jalviewjsCleanEclipse(type: Exec) {
+  dependsOn eclipseSetup
+  dependsOn jalviewjsEclipsePaths
+  dependsOn jalviewjsEclipseCopyDropins
+
+  executable(eclipseBinary)
+  args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
+  if (eclipseDebug) {
+    args += "-debug"
+  }
+  args += "-l"
+
+  def inputString = """exit
+y
+"""
+  def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
+  standardInput = inputByteStream
+
+  doFirst {
+    println("CLEAN ECLIPSE_DEBUG=${eclipseDebug}")
+  }
+}
+/* not really working yet
+jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
+*/
+
 task jalviewjsUnzipFiles {
   dependsOn jalviewjsSitePath
 
@@ -1473,9 +1509,7 @@ task jalviewjsCopySiteResources (type: Copy) {
 }
 
 task jalviewjsProjectImport(type: Exec) {
-  dependsOn eclipseProject
-  dependsOn eclipseClasspath
-  dependsOn eclipseJdt
+  dependsOn eclipseSetup
   dependsOn jalviewjsEclipsePaths
   dependsOn jalviewjsEclipseSetup
 
@@ -1514,13 +1548,21 @@ task jalviewjsTranspile(type: Exec) {
   def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
   def logOutFile = file(logOutFileName)
   logOutFile.createNewFile()
-  def logOutFOS = new FileOutputStream(logOutFile, false)
+  logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
+BINARY: ${eclipseBinary}
+VERSION: ${eclipseVersion}
+WORKSPACE: ${eclipseWorkspace}
+DEBUG: ${eclipseDebug}
+----
+"""
+  def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
   //def logErrFileName = "${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
   //def logErrFile = file(logFileName)
   //logErrFile.createNewFile()
   //def logErrFOS = new FileErrputStream(logErrFile, false)
   // combine stdout and stderr
   def logErrFOS = logOutFOS
+
   if (jalviewjs_j2s_to_console.equals("true")) {
     standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
       new org.apache.tools.ant.util.TeeOutputStream(