JAL-3210 add more memory to javaexec running closure compiler
[jalview.git] / build.gradle
index 2612fdb..7cdadc1 100644 (file)
@@ -2,6 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
 import org.gradle.internal.os.OperatingSystem
 import org.gradle.plugins.ide.eclipse.model.Output
 import org.gradle.plugins.ide.eclipse.model.Library
+import java.security.MessageDigest
 
 import groovy.transform.ExternalizeMethods
 
@@ -82,10 +83,11 @@ ext {
   } else {
     println("HEADLESS BUILD")
   }
-  /*
+  /* *-/
   System.properties.sort { it.key }.each {
     key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
   }
+  /-* *-/
   if (false && IN_ECLIPSE) {
     jalviewDir = jalviewDirAbsolutePath
   }
@@ -702,7 +704,7 @@ task convertBuildingMD(type: Exec) {
         commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
     } else {
         println("Cannot find pandoc. Skipping convert building.md to HTML")
-        throw new StopExecutionException()
+        throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
     }
   }
 
@@ -1421,16 +1423,17 @@ task jalviewjsSetEclipseWorkspace {
   def eclipseWsDir = propVal
   def props = new Properties()
 
+  def writeProps = true
   if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
     def ins = new FileInputStream(propsFileName)
     props.load(ins)
     ins.close()
     if (props.getProperty(propKey, null) != null) {
       eclipseWsDir = props.getProperty(propKey)
+      writeProps = false
     }
   }
 
-  def writeProps = false
   if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
     def tempDir = File.createTempDir()
     eclipseWsDir = tempDir.getAbsolutePath()
@@ -1876,6 +1879,7 @@ def jalviewjsCallCore(String name, FileCollection list, String prefixFile, Strin
   javaexec {
     classpath = files(["${jalviewDir}/tools/closure_compiler.jar"])
     args = [ "--js", jsfile, "--js_output_file", zjsfile ]
+    maxHeapSize = "2g"
 
     msg = "\nRunning '"+commandLine.join(' ')+"'\n"
     println(msg)
@@ -2254,6 +2258,43 @@ task cleanJalviewjsAll {
 }
 
 
+task jalviewjsIDE_checkJ2sPlugin {
+  group "00 JalviewJS in Eclipse"
+  description "Compare the swingjs/net.sf.j2s.core.jar file with the Eclipse pluing version"
+
+  doFirst {
+    def j2sPlugin = string("${jalviewDir}/${jalviewjs_j2s_plugin}")
+    def j2sPluginFile = file(j2sPlugin)
+    def eclipseHome = System.properties["eclipse.home.location"]
+    if (eclipseHome == null || ! IN_ECLIPSE) {
+      throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.")
+    }
+    def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}"
+    def eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
+    if (!eclipseJ2sPluginFile.exists()) {
+      def msg = "Eclipse J2S Plugin is not installed"
+      println(msg)
+      throw new GradleException(msg)
+    }
+
+    def digest = MessageDigest.getInstance("MD5")
+
+    digest.update(j2sPluginFile.text.bytes)
+    def j2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
+
+    digest.update(eclipseJ2sPluginFile.text.bytes)
+    def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
+     
+    if (j2sPluginMd5 != eclipseJ2sPluginMd5) {
+      def msg = "Eclipse J2S Plugin is different to '${j2sPlugin}'"
+      println(msg)
+      throw new GradleException(msg)
+    }
+
+    println("Eclipse J2S Plugin is same as '${j2sPlugin}'")
+  }
+}
+
 
 task jalviewjsIDE_j2sFile {
   group "00 JalviewJS in Eclipse"