From: soares Date: Wed, 1 Apr 2020 15:37:55 +0000 (+0100) Subject: JAL-3225 tasks to create extra desired settings for eclipse X-Git-Tag: Release_2_11_4_0~45^2~18^2~20 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5a1a6b6c4f1ad6f05557be8247ee596fdafb8b62;p=jalview.git JAL-3225 tasks to create extra desired settings for eclipse --- diff --git a/build.gradle b/build.gradle index 3bc0ced..183828f 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { + 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 index 0000000..09d843d --- /dev/null +++ b/utils/eclipse/org.eclipse.jdt.groovy.core.prefs @@ -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 index 0000000..93bda1c --- /dev/null +++ b/utils/eclipse/org.eclipse.jdt.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +cleanup.remove_redundant_type_arguments=false