JAL-3210 next attempts to use goomph (a gradle eclipse-as-disposable-build-artifact...
[jalview.git] / build.gradle
index 184e71e..5ceb4fa 100644 (file)
@@ -3,10 +3,12 @@ import org.gradle.internal.os.OperatingSystem
 import org.gradle.plugins.ide.eclipse.model.*
 import groovy.transform.ExternalizeMethods
 
+
 plugins {
   id 'java'
   id 'application'
   id 'eclipse'
+  id 'com.diffplug.gradle.oomph.ide' version '3.18.0'
 }
 
 repositories {
@@ -34,6 +36,8 @@ ext {
 
   gitHash = ""
   gitBranch = ""
+
+  jalviewjsServer = ""
 }
 
 def JAVA_INTEGER_VERSION
@@ -297,6 +301,14 @@ task jalviewjsSetTempEclipseWorkspace {
   println("ECLIPSE WORKSPACE: "+tempEclipseWorkspace.getPath())
 }
 
+oomphIde {
+  repoEclipseLatest()
+  jdt {
+  }
+  repo    'http://download.eclipse.org/buildship/updates/e45/milestones/3.x/'
+       feature 'org.eclipse.buildship'
+}
+
 task jalviewjsEclipseSetup {
   dependsOn jalviewjsEclipseCopyDropins
   dependsOn jalviewjsEclipseCopyPlugins
@@ -346,10 +358,12 @@ task jalviewjsCopySiteResources (type: Copy) {
 }
 
 task cleanJalviewjs {
+  /*
   delete jalviewDir+"/"+jalviewjs_site_dir
   delete jalviewDir+"/"+eclipse_bin_dir
   delete file(tempEclipseWorkspace.getAbsolutePath()+"/.metadata")
   delete jalviewDir+"/"+jalviewjs_j2s_settings
+  */
 }
 
 task jalviewjsProjectImport(type: Exec) {
@@ -407,24 +421,48 @@ task jalviewjs {
   dependsOn jalviewjsBuildSite
 }
 
-task jalviewjsServer {
-  //dependsOn jalviewjsBuildSite
-
+def jalviewjsServer = null
+task jalviewjsServerStart {
   doLast {
-    SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
-    def port = Integer.valueOf(jalviewjs_server_port)
-    def add = 0
-    def running = false
-    while(add < 1000) {
-      try {
-        HttpFileServer server = factory.start(new File(jalviewDirAbsolutePath+"/"+jalviewjs_site_dir), port)
-        running = true
-      } catch (Exception e) {
-        port++;
-        add++;
+
+    if (jalviewjsServer != null) {
+      println("SERVER ALREADY RUNNING. Go to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run  gradle jalviewjsServerStop  to stop.")
+    } else {
+
+      SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
+      def port = Integer.valueOf(jalviewjs_server_port)
+      def start = port
+      def running = false
+      while(port < start+1000 && !running) {
+        try {
+          jalviewjsServer = factory.start(new File(jalviewDirAbsolutePath+"/"+jalviewjs_site_dir), port)
+          running = true
+          println("SERVER STARTED. Go to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run  gradle jalviewjsServerStop  to stop.")
+          //println("Ctrl-c to stop.");java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000);
+        } catch (Exception e) {
+          port++;
+        }
       }
+
     }
-    println("SERVER STARTED on http://localhost:"+port+"/ . Ctrc+C to kill it")
-    java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000);
+
   }
+
 }
+
+/* server persists in gradle daemon but reference is not accessible across builds
+task jalviewjsServerStop {
+  doLast {
+
+    if (jalviewjsServer != null) {
+
+      println("SERVER ON PORT "+jalviewjsServer.getPort()+" STOPPING. Run  gradle jalviewjsServerStart  to start again.")
+      jalviewjsServer.stop()
+
+    } else {
+      println("SERVER NOT RUNNING. Run  gradle jalviewjsServerStart  to start.")
+    }
+
+  }
+}
+*/