JAL-3210 Some tidying and now using swingjs/*
[jalview.git] / build.gradle
index bf27433..815c6d2 100644 (file)
@@ -53,6 +53,22 @@ def compile_source_compatibility
 def compile_target_compatibility
 
 ext {
+  // local build environment properties
+  def localProps = "${jalviewDir}/local.properties"
+  if (file(localProps).exists()) {
+    def p = new Properties()
+    def localPropsFIS = new FileInputStream(localProps)
+    p.load(localPropsFIS)
+    localPropsFIS.close()
+    p.each {
+      key, val -> 
+      def over = project.properties.get(key) != null
+      project.properties.put(key, val)
+      if (over) {
+        println("Overriding property '${key}' with local.properties value")
+      }
+    }
+  }
   getdownWebsiteDir = "${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}"
   getdownDir = ""
   reportRsyncCmd = false
@@ -166,7 +182,7 @@ ext {
   gitHash = ""
   gitBranch = ""
 
-  println("Using a ${CHANNEL} profile. appbase=${getdown_app_base}")
+  println("Using a ${CHANNEL} profile.")
 }
 
 def JAVA_INTEGER_VERSION
@@ -631,8 +647,8 @@ task copyHelp(type: Copy) {
   }
   from(inputDir) {
     include '**/*.gif'
-      include '**/*.jpg'
-      include '**/*.png'
+    include '**/*.jpg'
+    include '**/*.png'
   }
   into outputDir
 
@@ -650,7 +666,6 @@ task syncLib(type: Sync) {
 task syncResources(type: Sync) {
   from "${jalviewDir}/${resourceDir}"
   include "**/*.*"
-  exclude "install4j"
   into "${classes}"
   preserve {
     include "**"
@@ -1343,6 +1358,7 @@ task jalviewjsEclipsePaths {
     fis.close()
     assumedVersion = false
   }
+  /*
   String[] v = eclipseVersion.split("\\.")
   def v0 = Integer.valueOf(v[0])
   def v1 = Integer.valueOf(v[1])
@@ -1351,8 +1367,10 @@ task jalviewjsEclipsePaths {
   } else {
     eclipseVersionSuffix = "_4.13"
   }
+  utilsDropinsDir = "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}${eclipseVersionSuffix}"
+  */
 
-  utilsDropinsDir = "${jalviewjs_utils_dir}/${jalviewjs_eclipse_dropins_dir}${eclipseVersionSuffix}"
+  utilsDropinsDir = "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}"
   def propKey = "eclipse_debug"
   eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
 
@@ -1363,9 +1381,18 @@ 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")
+  inputFiles += file(jalviewjs_j2s_plugin)
   def outputDir = eclipseDropinsDir
 
   inputs.files inputFiles
@@ -1382,19 +1409,55 @@ 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
+
+  doLast {
+    copy {
+      from jalviewjs_j2s_plugin
+      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
 
-  def zipFiles = fileTree(dir: "${jalviewjs_utils_dir}/${jalviewjs_libjs_dir}", include: "*.zip")
-  zipFiles += "${jalviewjs_utils_dir}/${jalviewjs_swingjs_zip}${eclipseVersionSuffix}"
+  def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
+  zipFiles += "${jalviewDir}/${jalviewjs_swingjs_zip}"
 
   doLast {
     zipFiles.each { file_zip -> 
@@ -1439,9 +1502,9 @@ task jalviewjsEclipseSetup {
   dependsOn jalviewjsCreateJ2sSettings
 }
 
-task jalviewjsCopyResources (type: Copy) {
+task jalviewjsCopyResources (type: Sync) {
   dependsOn jalviewjsSitePath
-  def inputFiles = fileTree(dir: jalviewjs_resource_dir)
+  def inputFiles = fileTree(dir: resourceDir)
   def outputDir = "${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
 
   from inputFiles
@@ -1451,13 +1514,16 @@ task jalviewjsCopyResources (type: Copy) {
     outputFiles += "${outputDir}/${filename}"
     null
   }
+  preserve {
+    include "**"
+  }
   outputs.files outputFiles
   inputs.files inputFiles
 }
 
-task jalviewjsCopySiteResources (type: Copy) {
+task jalviewjsCopySiteResources (type: Sync) {
   dependsOn jalviewjsSitePath
-  def inputFiles = fileTree(dir: "${jalviewjs_utils_dir}/${jalviewjs_site_resource_dir}")
+  def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
   def outputDir = jalviewjsSiteDir
 
   from inputFiles
@@ -1467,14 +1533,15 @@ task jalviewjsCopySiteResources (type: Copy) {
     outputFiles += "${outputDir}/${filename}"
     null
   }
+  preserve {
+    include "**"
+  }
   outputs.files outputFiles
   inputs.files inputFiles
 }
 
 task jalviewjsProjectImport(type: Exec) {
-  dependsOn eclipseProject
-  dependsOn eclipseClasspath
-  dependsOn eclipseJdt
+  dependsOn eclipseSetup
   dependsOn jalviewjsEclipsePaths
   dependsOn jalviewjsEclipseSetup
 
@@ -1500,7 +1567,7 @@ task jalviewjsTranspile(type: Exec) {
   dependsOn jalviewjsEclipsePaths
 
   executable(eclipseBinary)
-  args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipseBuildArg}", eclipse_project_name ])
+  args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
   if (eclipseDebug) {
     args += "-debug"
   }