comparison mxtool/mx.py @ 14745:65b005b58825

Allow project-specific overrides of Eclipse configuration files
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 25 Mar 2014 11:50:57 -0700
parents 4f8268dee8aa
children a6c1c3eb20c4
comparison
equal deleted inserted replaced
14744:bf51a92a1bdd 14745:65b005b58825
2865 2865
2866 settingsDir = join(p.dir, ".settings") 2866 settingsDir = join(p.dir, ".settings")
2867 if not exists(settingsDir): 2867 if not exists(settingsDir):
2868 os.mkdir(settingsDir) 2868 os.mkdir(settingsDir)
2869 2869
2870 # collect the defaults from mxtool
2871 defaultEclipseSettingsDir = join(dirname(__file__), 'eclipse-settings')
2872 esdict = {}
2873 if exists(defaultEclipseSettingsDir):
2874 for name in os.listdir(defaultEclipseSettingsDir):
2875 if isfile(join(defaultEclipseSettingsDir, name)):
2876 esdict[name] = os.path.abspath(join(defaultEclipseSettingsDir, name))
2877
2878 # check for suite overrides
2870 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings') 2879 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings')
2871 if exists(eclipseSettingsDir): 2880 if exists(eclipseSettingsDir):
2872 for name in os.listdir(eclipseSettingsDir): 2881 for name in os.listdir(eclipseSettingsDir):
2873 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0: 2882 if isfile(join(eclipseSettingsDir, name)):
2874 continue 2883 esdict[name] = os.path.abspath(join(eclipseSettingsDir, name))
2875 path = join(eclipseSettingsDir, name) 2884
2876 if isfile(path): 2885 # check for project overrides
2877 with open(join(eclipseSettingsDir, name)) as f: 2886 projectSettingsDir = join(p.dir, 'eclipse-settings')
2878 content = f.read() 2887 if exists(projectSettingsDir):
2879 content = content.replace('${javaCompliance}', str(p.javaCompliance)) 2888 for name in os.listdir(projectSettingsDir):
2880 if len(p.annotation_processors()) > 0: 2889 if isfile(join(projectSettingsDir, name)):
2881 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') 2890 esdict[name] = os.path.abspath(join(projectSettingsDir, name))
2882 update_file(join(settingsDir, name), content) 2891
2883 files.append(join(settingsDir, name)) 2892 # copy a possibly modified file to the project's .settings directory
2893 for name, path in esdict.iteritems():
2894 # ignore this file altogether if this project has no annotation processors
2895 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0:
2896 continue
2897
2898 with open(path) as f:
2899 content = f.read()
2900 content = content.replace('${javaCompliance}', str(p.javaCompliance))
2901 if len(p.annotation_processors()) > 0:
2902 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled')
2903 update_file(join(settingsDir, name), content)
2904 files.append(join(settingsDir, name))
2884 2905
2885 if len(p.annotation_processors()) > 0: 2906 if len(p.annotation_processors()) > 0:
2886 out = XMLDoc() 2907 out = XMLDoc()
2887 out.open('factorypath') 2908 out.open('factorypath')
2888 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) 2909 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'})