Mercurial > hg > truffle
comparison mxtool/mx.py @ 16455:59fdea1f9e36
factored out _eclipseinit_project to all per-project Eclipse configuration
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 10 Jul 2014 15:03:18 +0200 |
parents | 9fe3cb463079 |
children | 4aaa97f42b92 |
comparison
equal
deleted
inserted
replaced
16454:973b5704b95d | 16455:59fdea1f9e36 |
---|---|
2041 | 2041 |
2042 jdtProperties = join(self.proj.dir, '.settings', 'org.eclipse.jdt.core.prefs') | 2042 jdtProperties = join(self.proj.dir, '.settings', 'org.eclipse.jdt.core.prefs') |
2043 rootJdtProperties = join(self.proj.suite.mxDir, 'eclipse-settings', 'org.eclipse.jdt.core.prefs') | 2043 rootJdtProperties = join(self.proj.suite.mxDir, 'eclipse-settings', 'org.eclipse.jdt.core.prefs') |
2044 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties): | 2044 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties): |
2045 # Try to fix a missing properties file by running eclipseinit | 2045 # Try to fix a missing properties file by running eclipseinit |
2046 eclipseinit([], buildProcessorJars=False) | 2046 _eclipseinit_project(self.proj) |
2047 if not exists(jdtProperties): | 2047 if not exists(jdtProperties): |
2048 log('JDT properties file {0} not found'.format(jdtProperties)) | 2048 log('JDT properties file {0} not found'.format(jdtProperties)) |
2049 else: | 2049 else: |
2050 with open(jdtProperties) as fp: | 2050 with open(jdtProperties) as fp: |
2051 origContent = fp.read() | 2051 origContent = fp.read() |
3172 path = join(eclipseSettingsDir, name) | 3172 path = join(eclipseSettingsDir, name) |
3173 if configZip.isOlderThan(path): | 3173 if configZip.isOlderThan(path): |
3174 return False | 3174 return False |
3175 return True | 3175 return True |
3176 | 3176 |
3177 def _eclipseinit_project(p, files=None, libFiles=None): | |
3178 assert java(p.javaCompliance) | |
3179 | |
3180 if not exists(p.dir): | |
3181 os.makedirs(p.dir) | |
3182 | |
3183 out = XMLDoc() | |
3184 out.open('classpath') | |
3185 | |
3186 for src in p.srcDirs: | |
3187 srcDir = join(p.dir, src) | |
3188 if not exists(srcDir): | |
3189 os.mkdir(srcDir) | |
3190 out.element('classpathentry', {'kind' : 'src', 'path' : src}) | |
3191 | |
3192 if len(p.annotation_processors()) > 0: | |
3193 genDir = p.source_gen_dir() | |
3194 if not exists(genDir): | |
3195 os.mkdir(genDir) | |
3196 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) | |
3197 if files: | |
3198 files.append(genDir) | |
3199 | |
3200 # Every Java program depends on a JRE | |
3201 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)}) | |
3202 | |
3203 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | |
3204 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.pde.core.requiredPlugins'}) | |
3205 | |
3206 containerDeps = set() | |
3207 libraryDeps = set() | |
3208 projectDeps = set() | |
3209 | |
3210 for dep in p.all_deps([], True): | |
3211 if dep == p: | |
3212 continue | |
3213 if dep.isLibrary(): | |
3214 if hasattr(dep, 'eclipse.container'): | |
3215 container = getattr(dep, 'eclipse.container') | |
3216 containerDeps.add(container) | |
3217 libraryDeps -= set(dep.all_deps([], True)) | |
3218 else: | |
3219 libraryDeps.add(dep) | |
3220 elif dep.isProject(): | |
3221 projectDeps.add(dep) | |
3222 | |
3223 for dep in containerDeps: | |
3224 out.element('classpathentry', {'exported' : 'true', 'kind' : 'con', 'path' : dep}) | |
3225 | |
3226 for dep in libraryDeps: | |
3227 path = dep.path | |
3228 dep.get_path(resolve=True) | |
3229 | |
3230 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse | |
3231 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's | |
3232 # safest to simply use absolute paths. | |
3233 path = _make_absolute(path, p.suite.dir) | |
3234 | |
3235 attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path} | |
3236 | |
3237 sourcePath = dep.get_source_path(resolve=True) | |
3238 if sourcePath is not None: | |
3239 attributes['sourcepath'] = sourcePath | |
3240 out.element('classpathentry', attributes) | |
3241 if libFiles: | |
3242 libFiles.append(path) | |
3243 | |
3244 for dep in projectDeps: | |
3245 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name}) | |
3246 | |
3247 out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')}) | |
3248 out.close('classpath') | |
3249 classpathFile = join(p.dir, '.classpath') | |
3250 update_file(classpathFile, out.xml(indent='\t', newl='\n')) | |
3251 if files: | |
3252 files.append(classpathFile) | |
3253 | |
3254 csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml') | |
3255 if exists(csConfig): | |
3256 out = XMLDoc() | |
3257 | |
3258 dotCheckstyle = join(p.dir, ".checkstyle") | |
3259 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' | |
3260 out.open('fileset-config', {'file-format-version' : '1.2.0', 'simple-config' : 'true'}) | |
3261 out.open('local-check-config', {'name' : 'Checks', 'location' : checkstyleConfigPath, 'type' : 'project', 'description' : ''}) | |
3262 out.element('additional-data', {'name' : 'protect-config-file', 'value' : 'false'}) | |
3263 out.close('local-check-config') | |
3264 out.open('fileset', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) | |
3265 out.element('file-match-pattern', {'match-pattern' : '.', 'include-pattern' : 'true'}) | |
3266 out.close('fileset') | |
3267 out.open('filter', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) | |
3268 out.element('filter-data', {'value' : 'java'}) | |
3269 out.close('filter') | |
3270 | |
3271 exclude = join(p.dir, '.checkstyle.exclude') | |
3272 if exists(exclude): | |
3273 out.open('filter', {'name' : 'FilesFromPackage', 'enabled' : 'true'}) | |
3274 with open(exclude) as f: | |
3275 for line in f: | |
3276 if not line.startswith('#'): | |
3277 line = line.strip() | |
3278 exclDir = join(p.dir, line) | |
3279 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir | |
3280 out.element('filter-data', {'value' : line}) | |
3281 out.close('filter') | |
3282 | |
3283 out.close('fileset-config') | |
3284 update_file(dotCheckstyle, out.xml(indent=' ', newl='\n')) | |
3285 if files: | |
3286 files.append(dotCheckstyle) | |
3287 else: | |
3288 # clean up existing .checkstyle file | |
3289 dotCheckstyle = join(p.dir, ".checkstyle") | |
3290 if exists(dotCheckstyle): | |
3291 os.unlink(dotCheckstyle) | |
3292 | |
3293 out = XMLDoc() | |
3294 out.open('projectDescription') | |
3295 out.element('name', data=p.name) | |
3296 out.element('comment', data='') | |
3297 out.element('projects', data='') | |
3298 out.open('buildSpec') | |
3299 out.open('buildCommand') | |
3300 out.element('name', data='org.eclipse.jdt.core.javabuilder') | |
3301 out.element('arguments', data='') | |
3302 out.close('buildCommand') | |
3303 if exists(csConfig): | |
3304 out.open('buildCommand') | |
3305 out.element('name', data='net.sf.eclipsecs.core.CheckstyleBuilder') | |
3306 out.element('arguments', data='') | |
3307 out.close('buildCommand') | |
3308 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | |
3309 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']: | |
3310 out.open('buildCommand') | |
3311 out.element('name', data=buildCommand) | |
3312 out.element('arguments', data='') | |
3313 out.close('buildCommand') | |
3314 | |
3315 # The path should always be p.name/dir. independent of where the workspace actually is. | |
3316 # So we use the parent folder of the project, whatever that is, to generate such a relative path. | |
3317 logicalWorkspaceRoot = os.path.dirname(p.dir) | |
3318 binFolder = os.path.relpath(p.output_dir(), logicalWorkspaceRoot) | |
3319 | |
3320 if _isAnnotationProcessorDependency(p): | |
3321 refreshFile = os.path.relpath(join(p.dir, p.name + '.jar'), logicalWorkspaceRoot) | |
3322 _genEclipseBuilder(out, p, 'Jar', 'archive ' + p.name, refresh=True, refreshFile=refreshFile, relevantResources=[binFolder], async=True, xmlIndent='', xmlStandalone='no') | |
3323 | |
3324 out.close('buildSpec') | |
3325 out.open('natures') | |
3326 out.element('nature', data='org.eclipse.jdt.core.javanature') | |
3327 if exists(csConfig): | |
3328 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature') | |
3329 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | |
3330 out.element('nature', data='org.eclipse.pde.PluginNature') | |
3331 out.close('natures') | |
3332 out.close('projectDescription') | |
3333 projectFile = join(p.dir, '.project') | |
3334 update_file(projectFile, out.xml(indent='\t', newl='\n')) | |
3335 if files: | |
3336 files.append(projectFile) | |
3337 | |
3338 settingsDir = join(p.dir, ".settings") | |
3339 if not exists(settingsDir): | |
3340 os.mkdir(settingsDir) | |
3341 | |
3342 # collect the defaults from mxtool | |
3343 defaultEclipseSettingsDir = join(dirname(__file__), 'eclipse-settings') | |
3344 esdict = {} | |
3345 if exists(defaultEclipseSettingsDir): | |
3346 for name in os.listdir(defaultEclipseSettingsDir): | |
3347 if isfile(join(defaultEclipseSettingsDir, name)): | |
3348 esdict[name] = os.path.abspath(join(defaultEclipseSettingsDir, name)) | |
3349 | |
3350 # check for suite overrides | |
3351 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings') | |
3352 if exists(eclipseSettingsDir): | |
3353 for name in os.listdir(eclipseSettingsDir): | |
3354 if isfile(join(eclipseSettingsDir, name)): | |
3355 esdict[name] = os.path.abspath(join(eclipseSettingsDir, name)) | |
3356 | |
3357 # check for project overrides | |
3358 projectSettingsDir = join(p.dir, 'eclipse-settings') | |
3359 if exists(projectSettingsDir): | |
3360 for name in os.listdir(projectSettingsDir): | |
3361 if isfile(join(projectSettingsDir, name)): | |
3362 esdict[name] = os.path.abspath(join(projectSettingsDir, name)) | |
3363 | |
3364 # copy a possibly modified file to the project's .settings directory | |
3365 for name, path in esdict.iteritems(): | |
3366 # ignore this file altogether if this project has no annotation processors | |
3367 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0: | |
3368 continue | |
3369 | |
3370 with open(path) as f: | |
3371 content = f.read() | |
3372 content = content.replace('${javaCompliance}', str(p.javaCompliance)) | |
3373 if len(p.annotation_processors()) > 0: | |
3374 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') | |
3375 update_file(join(settingsDir, name), content) | |
3376 if files: | |
3377 files.append(join(settingsDir, name)) | |
3378 | |
3379 if len(p.annotation_processors()) > 0: | |
3380 out = XMLDoc() | |
3381 out.open('factorypath') | |
3382 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
3383 for ap in p.annotation_processors(): | |
3384 for dep in dependency(ap).all_deps([], True): | |
3385 if dep.isLibrary(): | |
3386 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse | |
3387 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's | |
3388 # safest to simply use absolute paths. | |
3389 path = _make_absolute(dep.get_path(resolve=True), p.suite.dir) | |
3390 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
3391 if files: | |
3392 files.append(path) | |
3393 elif dep.isProject(): | |
3394 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + dep.name + '/' + dep.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
3395 out.close('factorypath') | |
3396 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) | |
3397 if files: | |
3398 files.append(join(p.dir, '.factorypath')) | |
3399 | |
3177 def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False): | 3400 def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False): |
3178 configZip = TimeStampFile(join(suite.mxDir, 'eclipse-config.zip')) | 3401 configZip = TimeStampFile(join(suite.mxDir, 'eclipse-config.zip')) |
3179 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') | 3402 configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') |
3180 if refreshOnly and not configZip.exists(): | 3403 if refreshOnly and not configZip.exists(): |
3181 return | 3404 return |
3182 | 3405 |
3183 if _check_ide_timestamp(suite, configZip, 'eclipse'): | 3406 if _check_ide_timestamp(suite, configZip, 'eclipse'): |
3184 logv('[Eclipse configurations are up to date - skipping]') | 3407 logv('[Eclipse configurations are up to date - skipping]') |
3185 return | 3408 return |
3186 | 3409 |
3410 | |
3411 | |
3187 files = [] | 3412 files = [] |
3188 libFiles = [] | 3413 libFiles = [] |
3189 if buildProcessorJars: | 3414 if buildProcessorJars: |
3190 files += _processorjars_suite(suite) | 3415 files += _processorjars_suite(suite) |
3191 | 3416 |
3196 projToDist[p.name] = (dist, [dep.name for dep in distDeps]) | 3421 projToDist[p.name] = (dist, [dep.name for dep in distDeps]) |
3197 | 3422 |
3198 for p in suite.projects: | 3423 for p in suite.projects: |
3199 if p.native: | 3424 if p.native: |
3200 continue | 3425 continue |
3201 | 3426 _eclipseinit_project(p) |
3202 assert java(p.javaCompliance) | |
3203 | |
3204 if not exists(p.dir): | |
3205 os.makedirs(p.dir) | |
3206 | |
3207 out = XMLDoc() | |
3208 out.open('classpath') | |
3209 | |
3210 for src in p.srcDirs: | |
3211 srcDir = join(p.dir, src) | |
3212 if not exists(srcDir): | |
3213 os.mkdir(srcDir) | |
3214 out.element('classpathentry', {'kind' : 'src', 'path' : src}) | |
3215 | |
3216 if len(p.annotation_processors()) > 0: | |
3217 genDir = p.source_gen_dir() | |
3218 if not exists(genDir): | |
3219 os.mkdir(genDir) | |
3220 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) | |
3221 files.append(genDir) | |
3222 | |
3223 # Every Java program depends on a JRE | |
3224 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)}) | |
3225 | |
3226 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | |
3227 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.pde.core.requiredPlugins'}) | |
3228 | |
3229 containerDeps = set() | |
3230 libraryDeps = set() | |
3231 projectDeps = set() | |
3232 | |
3233 for dep in p.all_deps([], True): | |
3234 if dep == p: | |
3235 continue | |
3236 if dep.isLibrary(): | |
3237 if hasattr(dep, 'eclipse.container'): | |
3238 container = getattr(dep, 'eclipse.container') | |
3239 containerDeps.add(container) | |
3240 libraryDeps -= set(dep.all_deps([], True)) | |
3241 else: | |
3242 libraryDeps.add(dep) | |
3243 elif dep.isProject(): | |
3244 projectDeps.add(dep) | |
3245 | |
3246 for dep in containerDeps: | |
3247 out.element('classpathentry', {'exported' : 'true', 'kind' : 'con', 'path' : dep}) | |
3248 | |
3249 for dep in libraryDeps: | |
3250 path = dep.path | |
3251 dep.get_path(resolve=True) | |
3252 | |
3253 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse | |
3254 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's | |
3255 # safest to simply use absolute paths. | |
3256 path = _make_absolute(path, p.suite.dir) | |
3257 | |
3258 attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path} | |
3259 | |
3260 sourcePath = dep.get_source_path(resolve=True) | |
3261 if sourcePath is not None: | |
3262 attributes['sourcepath'] = sourcePath | |
3263 out.element('classpathentry', attributes) | |
3264 libFiles.append(path) | |
3265 | |
3266 for dep in projectDeps: | |
3267 out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name}) | |
3268 | |
3269 out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')}) | |
3270 out.close('classpath') | |
3271 classpathFile = join(p.dir, '.classpath') | |
3272 update_file(classpathFile, out.xml(indent='\t', newl='\n')) | |
3273 files.append(classpathFile) | |
3274 | |
3275 csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml') | |
3276 if exists(csConfig): | |
3277 out = XMLDoc() | |
3278 | |
3279 dotCheckstyle = join(p.dir, ".checkstyle") | |
3280 checkstyleConfigPath = '/' + p.checkstyleProj + '/.checkstyle_checks.xml' | |
3281 out.open('fileset-config', {'file-format-version' : '1.2.0', 'simple-config' : 'true'}) | |
3282 out.open('local-check-config', {'name' : 'Checks', 'location' : checkstyleConfigPath, 'type' : 'project', 'description' : ''}) | |
3283 out.element('additional-data', {'name' : 'protect-config-file', 'value' : 'false'}) | |
3284 out.close('local-check-config') | |
3285 out.open('fileset', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) | |
3286 out.element('file-match-pattern', {'match-pattern' : '.', 'include-pattern' : 'true'}) | |
3287 out.close('fileset') | |
3288 out.open('filter', {'name' : 'all', 'enabled' : 'true', 'check-config-name' : 'Checks', 'local' : 'true'}) | |
3289 out.element('filter-data', {'value' : 'java'}) | |
3290 out.close('filter') | |
3291 | |
3292 exclude = join(p.dir, '.checkstyle.exclude') | |
3293 if exists(exclude): | |
3294 out.open('filter', {'name' : 'FilesFromPackage', 'enabled' : 'true'}) | |
3295 with open(exclude) as f: | |
3296 for line in f: | |
3297 if not line.startswith('#'): | |
3298 line = line.strip() | |
3299 exclDir = join(p.dir, line) | |
3300 assert isdir(exclDir), 'excluded source directory listed in ' + exclude + ' does not exist or is not a directory: ' + exclDir | |
3301 out.element('filter-data', {'value' : line}) | |
3302 out.close('filter') | |
3303 | |
3304 out.close('fileset-config') | |
3305 update_file(dotCheckstyle, out.xml(indent=' ', newl='\n')) | |
3306 files.append(dotCheckstyle) | |
3307 else: | |
3308 # clean up existing .checkstyle file | |
3309 dotCheckstyle = join(p.dir, ".checkstyle") | |
3310 if exists(dotCheckstyle): | |
3311 os.unlink(dotCheckstyle) | |
3312 | |
3313 out = XMLDoc() | |
3314 out.open('projectDescription') | |
3315 out.element('name', data=p.name) | |
3316 out.element('comment', data='') | |
3317 out.element('projects', data='') | |
3318 out.open('buildSpec') | |
3319 out.open('buildCommand') | |
3320 out.element('name', data='org.eclipse.jdt.core.javabuilder') | |
3321 out.element('arguments', data='') | |
3322 out.close('buildCommand') | |
3323 if exists(csConfig): | |
3324 out.open('buildCommand') | |
3325 out.element('name', data='net.sf.eclipsecs.core.CheckstyleBuilder') | |
3326 out.element('arguments', data='') | |
3327 out.close('buildCommand') | |
3328 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | |
3329 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']: | |
3330 out.open('buildCommand') | |
3331 out.element('name', data=buildCommand) | |
3332 out.element('arguments', data='') | |
3333 out.close('buildCommand') | |
3334 | |
3335 # The path should always be p.name/dir. independent of where the workspace actually is. | |
3336 # So we use the parent folder of the project, whatever that is, to generate such a relative path. | |
3337 logicalWorkspaceRoot = os.path.dirname(p.dir) | |
3338 binFolder = os.path.relpath(p.output_dir(), logicalWorkspaceRoot) | |
3339 | |
3340 if _isAnnotationProcessorDependency(p): | |
3341 refreshFile = os.path.relpath(join(p.dir, p.name + '.jar'), logicalWorkspaceRoot) | |
3342 _genEclipseBuilder(out, p, 'Jar', 'archive ' + p.name, refresh=True, refreshFile=refreshFile, relevantResources=[binFolder], async=True, xmlIndent='', xmlStandalone='no') | |
3343 | |
3344 out.close('buildSpec') | |
3345 out.open('natures') | |
3346 out.element('nature', data='org.eclipse.jdt.core.javanature') | |
3347 if exists(csConfig): | |
3348 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature') | |
3349 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | |
3350 out.element('nature', data='org.eclipse.pde.PluginNature') | |
3351 out.close('natures') | |
3352 out.close('projectDescription') | |
3353 projectFile = join(p.dir, '.project') | |
3354 update_file(projectFile, out.xml(indent='\t', newl='\n')) | |
3355 files.append(projectFile) | |
3356 | |
3357 settingsDir = join(p.dir, ".settings") | |
3358 if not exists(settingsDir): | |
3359 os.mkdir(settingsDir) | |
3360 | |
3361 # collect the defaults from mxtool | |
3362 defaultEclipseSettingsDir = join(dirname(__file__), 'eclipse-settings') | |
3363 esdict = {} | |
3364 if exists(defaultEclipseSettingsDir): | |
3365 for name in os.listdir(defaultEclipseSettingsDir): | |
3366 if isfile(join(defaultEclipseSettingsDir, name)): | |
3367 esdict[name] = os.path.abspath(join(defaultEclipseSettingsDir, name)) | |
3368 | |
3369 # check for suite overrides | |
3370 eclipseSettingsDir = join(p.suite.mxDir, 'eclipse-settings') | |
3371 if exists(eclipseSettingsDir): | |
3372 for name in os.listdir(eclipseSettingsDir): | |
3373 if isfile(join(eclipseSettingsDir, name)): | |
3374 esdict[name] = os.path.abspath(join(eclipseSettingsDir, name)) | |
3375 | |
3376 # check for project overrides | |
3377 projectSettingsDir = join(p.dir, 'eclipse-settings') | |
3378 if exists(projectSettingsDir): | |
3379 for name in os.listdir(projectSettingsDir): | |
3380 if isfile(join(projectSettingsDir, name)): | |
3381 esdict[name] = os.path.abspath(join(projectSettingsDir, name)) | |
3382 | |
3383 # copy a possibly modified file to the project's .settings directory | |
3384 for name, path in esdict.iteritems(): | |
3385 # ignore this file altogether if this project has no annotation processors | |
3386 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0: | |
3387 continue | |
3388 | |
3389 with open(path) as f: | |
3390 content = f.read() | |
3391 content = content.replace('${javaCompliance}', str(p.javaCompliance)) | |
3392 if len(p.annotation_processors()) > 0: | |
3393 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') | |
3394 update_file(join(settingsDir, name), content) | |
3395 files.append(join(settingsDir, name)) | |
3396 | |
3397 if len(p.annotation_processors()) > 0: | |
3398 out = XMLDoc() | |
3399 out.open('factorypath') | |
3400 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
3401 for ap in p.annotation_processors(): | |
3402 for dep in dependency(ap).all_deps([], True): | |
3403 if dep.isLibrary(): | |
3404 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse | |
3405 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's | |
3406 # safest to simply use absolute paths. | |
3407 path = _make_absolute(dep.get_path(resolve=True), p.suite.dir) | |
3408 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
3409 files.append(path) | |
3410 elif dep.isProject(): | |
3411 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + dep.name + '/' + dep.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
3412 out.close('factorypath') | |
3413 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) | |
3414 files.append(join(p.dir, '.factorypath')) | |
3415 | 3427 |
3416 _, launchFile = make_eclipse_attach(suite, 'localhost', '8000', deps=sorted_deps(projectNames=None, includeLibs=True)) | 3428 _, launchFile = make_eclipse_attach(suite, 'localhost', '8000', deps=sorted_deps(projectNames=None, includeLibs=True)) |
3417 files.append(launchFile) | 3429 files.append(launchFile) |
3418 | 3430 |
3419 _zip_files(files, suite.dir, configZip.path) | 3431 _zip_files(files, suite.dir, configZip.path) |
3420 _zip_files(libFiles, suite.dir, configLibsZip) | 3432 _zip_files(libFiles, suite.dir, configLibsZip) |
3421 | 3433 |
3422 # Create an Eclipse project for each distribution that will create/update the archive | 3434 # Create an Eclipse project for each distribution that will create/update the archive |
3423 # for the distribution whenever any project of the distribution is updated. | 3435 # for the distribution whenever any project of the distribution is updated. |
3424 for dist in suite.dists: | 3436 for dist in suite.dists: |
3425 name = dist.name | |
3426 if hasattr(dist, 'subDir'): | 3437 if hasattr(dist, 'subDir'): |
3427 projectDir = join(suite.dir, dist.subDir, dist.name + '.dist') | 3438 projectDir = join(suite.dir, dist.subDir, dist.name + '.dist') |
3428 else: | 3439 else: |
3429 projectDir = join(suite.dir, dist.name + '.dist') | 3440 projectDir = join(suite.dir, dist.name + '.dist') |
3430 if not exists(projectDir): | 3441 if not exists(projectDir): |