JAL-3210 Changed eclipse workspace dir to be a system temp dir [held in build/jalview...
[jalview.git] / build.gradle
index 314306f..03dacfb 100644 (file)
@@ -1262,17 +1262,6 @@ task helppages  {
   outputs.dir("$helpOutputDir")
 }
 
-def eclipseWorkspace
-task jalviewjsSetEclipseWorkspace {
-  def eclipseWsDir = jalviewjs_eclipse_workspace
-  eclipseWorkspace = file(eclipseWsDir)
-  if (!eclipseWorkspace.exists()) {
-    eclipseWorkspace = file("${buildDir}/../tmp/eclipse-workspace")
-    //eclipseWorkspace.deleteOnExit()
-  }
-  println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
-}
-
 def jalviewjsBuildDir
 def jalviewjsSiteDir
 def jalviewjsTransferSiteDir
@@ -1287,6 +1276,39 @@ task jalviewjsSitePath {
   jalviewjsTransferSiteDir = jalviewjsBuildDir + "/tmp/site"
 }
 
+def eclipseWorkspace
+task jalviewjsSetEclipseWorkspace {
+  def propKey = "jalviewjs_eclipse_workspace"
+  def propsFile = "${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
+  def props = new Properties()
+  def eclipseWsDir
+  def propVal = null
+  if (project.hasProperty(propKey)) {
+    propVal = project.getProperty(propKey)
+    eclipseWsDir = propVal
+  }
+  if ((eclipseWsDir == null || !file(eclipseWsDir).exists()) && file(propsFile).exists()) {
+    def ins = new FileInputStream(propsFile)
+    props.load(ins)
+    ins.close()
+    eclipseWsDir = props.getProperty(propKey)
+  }
+  if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
+    def tempDir = File.createTempDir()
+    eclipseWsDir = tempDir.getAbsolutePath()
+    props.setProperty(propKey, eclipseWsDir)
+    def outs = new FileOutputStream(propsFile)
+    props.store(outs, null)
+    outs.close()
+  }
+
+  eclipseWorkspace = file(eclipseWsDir)
+    
+  println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
+
+  inputs.property(propKey, propVal)
+  outputs.file(propsFile)
+}
 
 
 task jalviewjsUnzipFiles {