JAL-3225 tasks to create extra desired settings for eclipse
authorsoares <bsoares@dundee.ac.uk>
Wed, 1 Apr 2020 15:37:55 +0000 (16:37 +0100)
committersoares <bsoares@dundee.ac.uk>
Wed, 1 Apr 2020 15:37:55 +0000 (16:37 +0100)
build.gradle
utils/eclipse/org.eclipse.jdt.groovy.core.prefs [new file with mode: 0644]
utils/eclipse/org.eclipse.jdt.ui.prefs [new file with mode: 0644]

index 3bc0ced..183828f 100644 (file)
@@ -1,5 +1,8 @@
 import org.apache.tools.ant.filters.ReplaceTokens
 import org.gradle.internal.os.OperatingSystem
+import org.gradle.plugins.ide.internal.generator.PropertiesPersistableConfigurationObject
+import org.gradle.api.internal.PropertiesTransformer
+import org.gradle.util.ConfigureUtil
 import org.gradle.plugins.ide.eclipse.model.Output
 import org.gradle.plugins.ide.eclipse.model.Library
 import java.security.MessageDigest
@@ -601,6 +604,63 @@ eclipse {
 }
 
 
+/* hack to change eclipse prefs in .settings files other than org.eclipse.jdt.core.prefs */
+// Class to allow updating arbitrary properties files
+class PropertiesFile extends PropertiesPersistableConfigurationObject {
+  public PropertiesFile(PropertiesTransformer t) { super(t); }
+  @Override protected void load(Properties properties) { }
+  @Override protected void store(Properties properties) { }
+  @Override protected String getDefaultResourceName() { return ""; }
+  // This is necessary, because PropertiesPersistableConfigurationObject fails
+  // if no default properties file exists.
+  @Override public void loadDefaults() { load(new StringBufferInputStream("")); }
+}
+
+// Task to update arbitrary properties files (set outputFile)
+class PropertiesFileTask extends PropertiesGeneratorTask<PropertiesFile> {
+  private final PropertiesFileContentMerger file;
+  public PropertiesFileTask() { file = new PropertiesFileContentMerger(getTransformer()); }
+  protected PropertiesFile create() { return new PropertiesFile(getTransformer()); }
+  protected void configure(PropertiesFile props) {
+    file.getBeforeMerged().execute(props); file.getWhenMerged().execute(props);
+  }
+  public void file(Closure closure) { ConfigureUtil.configure(closure, file); }
+}
+
+task eclipseUIPreferences(type: PropertiesFileTask) {
+  description = "Generate Eclipse additional settings"
+  def filename = "org.eclipse.jdt.ui.prefs"
+  outputFile = "$projectDir/.settings/${filename}" as File
+  file {
+    withProperties {
+      it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
+    }
+  }
+}
+
+task eclipseGroovyCorePreferences(type: PropertiesFileTask) {
+  description = "Generate Eclipse additional settings"
+  def filename = "org.eclipse.jdt.groovy.core.prefs"
+  outputFile = "$projectDir/.settings/${filename}" as File
+  file {
+    withProperties {
+      it.load new FileInputStream("$projectDir/utils/eclipse/${filename}" as String)
+    }
+  }
+}
+
+task eclipseAllPreferences {
+  dependsOn eclipseJdt
+  dependsOn eclipseUIPreferences
+  dependsOn eclipseGroovyCorePreferences
+}
+
+eclipseUIPreferences.mustRunAfter eclipseJdt
+eclipseGroovyCorePreferences.mustRunAfter eclipseJdt
+
+/* end of eclipse preferences hack */
+
+
 task cloverInstr {
   // only instrument source, we build test classes as normal
   inputs.files files (sourceSets.main.allJava,sourceSets.test.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
diff --git a/utils/eclipse/org.eclipse.jdt.groovy.core.prefs b/utils/eclipse/org.eclipse.jdt.groovy.core.prefs
new file mode 100644 (file)
index 0000000..09d843d
--- /dev/null
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+groovy.compiler.level=30
diff --git a/utils/eclipse/org.eclipse.jdt.ui.prefs b/utils/eclipse/org.eclipse.jdt.ui.prefs
new file mode 100644 (file)
index 0000000..93bda1c
--- /dev/null
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+cleanup.remove_redundant_type_arguments=false