JAL-3210 gradle eclipse now uses/inserts utils/eclipse/JalviewCodeStyle.xml into...
authorBen Soares <bsoares@dundee.ac.uk>
Mon, 13 Jan 2020 17:12:40 +0000 (17:12 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Mon, 13 Jan 2020 17:12:40 +0000 (17:12 +0000)
build.gradle
gradle.properties

index 5190968..e6a9c34 100644 (file)
@@ -528,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()
@@ -539,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)
+              }
+            }
+          }
+        }
       }
     }
 
index fda866e..42391fe 100644 (file)
@@ -143,6 +143,7 @@ bamboo_planKey =
 bamboo_getdown_channel_suffix = /latest/artifact/shared/getdown-channel
 
 eclipse_extra_jdt_prefs_file = .settings/org.eclipse.jdt.core.jalview.prefs
+eclipse_codestyle_file = utils/eclipse/JalviewCodeStyle.xml
 eclipse_project_name = jalview
 eclipse_bin_dir = bin
 eclipse_debug = false