JAL-3210 gradle eclipse now uses/inserts utils/eclipse/JalviewCodeStyle.xml into...
[jalview.git] / build.gradle
index 43f2c1c..e6a9c34 100644 (file)
@@ -123,7 +123,7 @@ ext {
   getdownDir = string("")
   reportRsyncCmd = false
   buildDist = true
-  buildProperties = build_properties_file
+  buildProperties = string("${resourceDir}/${build_properties_file}")
   getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
   switch (CHANNEL) {
 
@@ -133,7 +133,7 @@ ext {
     getdown_channel_name = string("${bamboo_planKey}/${JAVA_VERSION}")
     getdown_app_base = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
     getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    buildProperties = string("${resourceDir}/${build_properties_file}")
     break
 
     case "RELEASE":
@@ -141,8 +141,13 @@ ext {
     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
     getdown_app_dir = getdown_app_dir_release
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    buildProperties = string("${resourceDir}/${build_properties_file}")
     reportRsyncCommand = true
+    // Don't ignore transpile errors for release build
+    if (jalviewjs_ignore_transpile_errors.equals("true")) {
+      jalviewjs_ignore_transpile_errors = "false"
+      println("Setting jalviewjs_ignore_transpile_errors to 'false'")
+    }
     break
 
     case "ARCHIVE":
@@ -155,7 +160,7 @@ ext {
       exit
     } else {
       packageDir = string("${ARCHIVEDIR}/${packageDir}")
-      buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
+      buildProperties = string("${ARCHIVEDIR}/${resource_dir}/${build_properties_file}")
       buildDist = false
     }
     reportRsyncCommand = true
@@ -171,7 +176,7 @@ ext {
       exit
     } else {
       packageDir = string("${ARCHIVEDIR}/${packageDir}")
-      buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
+      buildProperties = string("${ARCHIVEDIR}/${resource_dir}/${build_properties_file}")
       buildDist = false
     }
     reportRsyncCommand = true
@@ -183,7 +188,7 @@ ext {
     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
     getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    buildProperties = string("${resourceDir}/${build_properties_file}")
     reportRsyncCommand = true
     break
 
@@ -192,8 +197,13 @@ ext {
     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
     getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    buildProperties = string("${resourceDir}/${build_properties_file}")
     reportRsyncCommand = true
+    // Don't ignore transpile errors for release build
+    if (jalviewjs_ignore_transpile_errors.equals("true")) {
+      jalviewjs_ignore_transpile_errors = "false"
+      println("Setting jalviewjs_ignore_transpile_errors to 'false'")
+    }
     break
 
     case ~/^SCRATCH(|-[-\w]*)$/:
@@ -201,14 +211,14 @@ ext {
     getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
     getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
     getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    buildProperties = string("${resourceDir}/${build_properties_file}")
     reportRsyncCommand = true
     break
 
     case "LOCAL":
     getdown_app_base = file(getdownWebsiteDir).toURI().toString()
     getdown_app_dir = getdown_app_dir_alt
-    buildProperties = string("${classesDir}/${build_properties_file}")
+    buildProperties = string("${resourceDir}/${build_properties_file}")
     getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
     break
 
@@ -218,7 +228,6 @@ ext {
     break
 
   }
-buildProperties = string("${resourceDir}/${build_properties_file}")
 
   getdownAppDir = string("${getdownWebsiteDir}/${getdown_app_dir}")
   //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
@@ -452,7 +461,7 @@ eclipse {
         }
         cp.entries.removeAll(removeTheseToo)
 
-        //cp.entries += new Output("${eclipse_bin_dir}/main")
+        cp.entries += new Output("${eclipse_bin_dir}/main")
         if (file(helpSourceDir).isDirectory()) {
           cp.entries += new Library(fileReference(helpSourceDir))
         }
@@ -519,6 +528,7 @@ eclipse {
     javaRuntimeName = eclipse_java_runtime_name
 
     // add in jalview project specific properties/preferences into eclipse core preferences
+    // and also the codestyle XML file
     file {
       withProperties { props ->
         def jalview_prefs = new Properties()
@@ -530,6 +540,22 @@ eclipse {
             props.putAt(t, v)
           }
         }
+        // codestyle file -- overrides previous formatter prefs
+        def csFile = file("${jalviewDirAbsolutePath}/${eclipse_codestyle_file}")
+        if (csFile.exists()) {
+          XmlParser parser = new XmlParser()
+          def profiles = parser.parse(csFile)
+          def profile = profiles.'profile'.find { p -> (p.'@kind' == "CodeFormatterProfile" && p.'@name' == "Jalview") }
+          if (profile != null) {
+            profile.'setting'.each { s ->
+              def id = s.'@id'
+              def value = s.'@value'
+              if (id != null && value != null) {
+                props.putAt(id, value)
+              }
+            }
+          }
+        }
       }
     }
 
@@ -690,7 +716,7 @@ task createBuildProperties(type: WriteProperties) {
 
 clean {
   doFirst {
-       delete buildProperties
+    delete buildProperties
   }
 }
 
@@ -1852,7 +1878,12 @@ DEBUG: ${eclipseDebug}
     if (stdout.toString().contains("Error processing ")) {
       // j2s did not complete transpile
       //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
-      throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
+      if (jalviewjs_ignore_transpile_errors.equals("true")) {
+        println("IGNORING TRANSPILE ERRORS")
+        println("See eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
+      } else {
+        throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'")
+      }
     }
   }
 
@@ -1973,7 +2004,7 @@ task jalviewjsBuildAllCores {
 
     def file = hash['file']
     if (! file.exists()) {
-      println("...classlist file '"+file.getPath()+"' does not exist, skipping")
+      //println("...classlist file '"+file.getPath()+"' does not exist, skipping")
       return false // this is a "continue" in groovy .each closure
     }
     def name = hash['name']
@@ -2046,7 +2077,8 @@ task jalviewjsBuildAllCores {
     'list': allJsFiles,
     'name': allClasslistName
   ]
-  jalviewjsCoreClasslists += allClasslist
+  // not including this version of "all" core at the moment
+  //jalviewjsCoreClasslists += allClasslist
   inputs.files(allClasslist['list'])
   outputs.file(allClasslist['jsfile'])
   outputs.file(allClasslist['zjsfile'])
@@ -2183,12 +2215,19 @@ task jalviewjsBuildSite {
 }
 
 
-task cleanJalviewjsSite {
+task cleanJalviewjsTransferSite {
   doFirst {
     delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}"
     delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}"
     delete "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}"
     delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}"
+  }
+}
+
+
+task cleanJalviewjsSite {
+  dependsOn cleanJalviewjsTransferSite
+  doFirst {
     delete "${jalviewDir}/${jalviewjsSiteDir}"
   }
 }
@@ -2297,8 +2336,8 @@ task jalviewjsIDE_checkJ2sPlugin {
     def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}"
     def eclipseJ2sPluginFile = file(eclipseJ2sPlugin)
     if (!eclipseJ2sPluginFile.exists()) {
-      def msg = "Eclipse J2S Plugin is not installed"
-      println(msg)
+      def msg = "Eclipse J2S Plugin is not installed (could not find '${eclipseJ2sPlugin}')"
+      System.err.println(msg)
       if (! copyPlugin) {
         throw new GradleException(msg)
       }
@@ -2315,7 +2354,7 @@ task jalviewjsIDE_checkJ2sPlugin {
      
     if (j2sPluginMd5 != eclipseJ2sPluginMd5) {
       def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'"
-      println(msg)
+      System.err.println(msg)
       if (! copyPlugin) {
         throw new StopExecutionException(msg)
       }
@@ -2331,7 +2370,7 @@ task jalviewjsIDE_checkJ2sPlugin {
         into eclipseJ2sPluginFile.getParent()
       }
     } else {
-      def msg = "Eclipse J2S Plugin is the same as '${j2sPlugin}'"
+      def msg = "Eclipse J2S Plugin is the same as '${j2sPlugin}' (this is good)"
       println(msg)
     }
   }
@@ -2352,9 +2391,7 @@ task jalviewjsIDE_SyncCore {
 }
 
 
-task jalviewjsIDE_PrepareSite {
-  group "00 JalviewJS in Eclipse"
-  description "Sync libs and resources to site dir, but not closure cores"
+task jalviewjsIDE_SyncSiteAll {
   dependsOn jalviewjsSyncAllLibs
   dependsOn jalviewjsSyncResources
   dependsOn jalviewjsSyncSiteResources
@@ -2362,6 +2399,18 @@ task jalviewjsIDE_PrepareSite {
 }
 
 
+cleanJalviewjsTransferSite.mustRunAfter jalviewjsIDE_SyncSiteAll
+
+
+task jalviewjsIDE_PrepareSite {
+  group "00 JalviewJS in Eclipse"
+  description "Sync libs and resources to site dir, but not closure cores"
+
+  dependsOn jalviewjsIDE_SyncSiteAll
+  dependsOn cleanJalviewjsTransferSite
+}
+
+
 task jalviewjsIDE_AssembleSite {
   group "00 JalviewJS in Eclipse"
   description "Assembles unzipped supporting zipfiles, resources, site resources and closure cores into the Eclipse transpiled site"