Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 22059:a694f0c9864f
mx: allow libraries as annotation processors.
author | Danilo Ansaloni <danilo.ansaloni@oracle.com> |
---|---|
date | Tue, 23 Jun 2015 11:44:20 +0200 |
parents | 62fa6ad33667 |
children | acd43093257d |
comparison
equal
deleted
inserted
replaced
22058:555c6a8db46b | 22059:a694f0c9864f |
---|---|
619 if not hasattr(self, '_annotationProcessors'): | 619 if not hasattr(self, '_annotationProcessors'): |
620 aps = set() | 620 aps = set() |
621 if hasattr(self, '_declaredAnnotationProcessors'): | 621 if hasattr(self, '_declaredAnnotationProcessors'): |
622 aps = set(self._declaredAnnotationProcessors) | 622 aps = set(self._declaredAnnotationProcessors) |
623 for ap in aps: | 623 for ap in aps: |
624 if project(ap).definedAnnotationProcessorsDist is None: | 624 # ap may be a Project or a Distribution |
625 config = join(project(ap).source_dirs()[0], 'META-INF', 'services', 'javax.annotation.processing.Processor') | 625 apd = dependency(ap) |
626 if not exists(config): | 626 if apd.isLibrary(): |
627 TimeStampFile(config).touch() | 627 # trust it, we could look inside I suppose |
628 abort('Project ' + ap + ' declared in annotationProcessors property of ' + self.name + ' does not define any annotation processors.\n' + | 628 pass |
629 'Please specify the annotation processors in ' + config) | 629 elif apd.isProject(): |
630 if apd.definedAnnotationProcessorsDist is None: | |
631 config = join(project(ap).source_dirs()[0], 'META-INF', 'services', 'javax.annotation.processing.Processor') | |
632 if not exists(config): | |
633 TimeStampFile(config).touch() | |
634 abort('Project ' + ap + ' declared in annotationProcessors property of ' + self.name + ' does not define any annotation processors.\n' + | |
635 'Please specify the annotation processors in ' + config) | |
630 | 636 |
631 allDeps = self.all_deps([], includeLibs=False, includeSelf=False, includeAnnotationProcessors=False) | 637 allDeps = self.all_deps([], includeLibs=False, includeSelf=False, includeAnnotationProcessors=False) |
632 for p in allDeps: | 638 for p in allDeps: |
633 # Add an annotation processor dependency | 639 # Add an annotation processor dependency |
634 if p.definedAnnotationProcessorsDist is not None: | 640 if p.definedAnnotationProcessorsDist is not None: |
643 """ | 649 """ |
644 Gets the class path composed of the distribution jars containing the | 650 Gets the class path composed of the distribution jars containing the |
645 annotation processors that will be applied when compiling this project. | 651 annotation processors that will be applied when compiling this project. |
646 """ | 652 """ |
647 def annotation_processors_path(self): | 653 def annotation_processors_path(self): |
648 aps = [project(ap) for ap in self.annotation_processors()] | 654 aps = [dependency(ap) for ap in self.annotation_processors()] |
649 libAps = set() | 655 libAps = set() |
650 for dep in self.all_deps([], includeLibs=True, includeSelf=False): | 656 for dep in self.all_deps([], includeLibs=True, includeSelf=False): |
651 if dep.isLibrary() and hasattr(dep, 'annotationProcessor') and getattr(dep, 'annotationProcessor').lower() == 'true': | 657 if dep.isLibrary() and hasattr(dep, 'annotationProcessor') and getattr(dep, 'annotationProcessor').lower() == 'true': |
652 libAps = libAps.union(dep.all_deps([], includeLibs=True, includeSelf=True)) | 658 libAps = libAps.union(dep.all_deps([], includeLibs=True, includeSelf=True)) |
653 if len(aps) + len(libAps): | 659 if len(aps) + len(libAps): |
654 return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist] + [lib.get_path(False) for lib in libAps]) | 660 apPaths = [] |
661 for ap in aps: | |
662 if ap.isLibrary(): | |
663 for dep in ap.all_deps([], includeLibs=True): | |
664 dep.append_to_classpath(apPaths, True) | |
665 elif ap.definedAnnotationProcessorsDist: | |
666 apPaths.append(ap.definedAnnotationProcessorsDist.path) | |
667 return os.pathsep.join(apPaths + [lib.get_path(False) for lib in libAps]) | |
655 return None | 668 return None |
656 | 669 |
657 def uses_annotation_processor_library(self): | 670 def uses_annotation_processor_library(self): |
658 for dep in self.all_deps([], includeLibs=True, includeSelf=False): | 671 for dep in self.all_deps([], includeLibs=True, includeSelf=False): |
659 if dep.isLibrary() and hasattr(dep, 'annotationProcessor'): | 672 if dep.isLibrary() and hasattr(dep, 'annotationProcessor'): |