def classname_for_classfile(self, target, classpath_products): contents = ClasspathUtil.classpath_contents((target,), classpath_products) for f in contents: classname = ClasspathUtil.classname_for_rel_classfile(f) # None for non `.class` files if classname: yield classname
def classname_for_classfile(self, target, classpath_products): contents = ClasspathUtil.classpath_contents((target, ), classpath_products) for f in contents: classname = ClasspathUtil.classname_for_rel_classfile(f) # None for non `.class` files if classname: yield classname
def _classnames_from_source_file(self, context): source_products = context.products.get_data('classes_by_source').get(self._sourcefile) if not source_products: # It's valid - if questionable - to have a source file with no classes when, for # example, the source file has all its code commented out. context.log.warn('Source file {0} generated no classes'.format(self._sourcefile)) else: for _, classes in source_products.rel_paths(): for cls in classes: yield ClasspathUtil.classname_for_rel_classfile(cls)
def _calculate_tests_from_targets(self, targets): """ :param list targets: list of targets to calculate test classes for. generates tuples (class_name, target). """ classpath_products = self.context.products.get_data('runtime_classpath') for target in targets: contents = ClasspathUtil.classpath_contents((target,), classpath_products, confs=self.confs) for f in contents: classname = ClasspathUtil.classname_for_rel_classfile(f) if classname: yield (classname, target)
def _target_classes(self, target): """Set of target's provided classes. Call at the target level is to memoize efficiently. """ target_classes = set() contents = ClasspathUtil.classpath_contents((target,), self.runtime_classpath) for f in contents: classname = ClasspathUtil.classname_for_rel_classfile(f) if classname: target_classes.add(classname) return target_classes
def _calculate_tests_from_targets(self, targets): """ :param list targets: list of targets to calculate test classes for. generates tuples (Test, Target). """ classpath_products = self.context.products.get_data('runtime_classpath') for target in targets: contents = ClasspathUtil.classpath_contents((target,), classpath_products, confs=self.confs) for f in contents: classname = ClasspathUtil.classname_for_rel_classfile(f) if classname: yield Test(classname=classname), target
def _target_classes(self, target): """Set of target's provided classes. Call at the target level is to memoize efficiently. """ target_classes = set() contents = ClasspathUtil.classpath_contents((target,), self.runtime_classpath) for f in contents: classname = ClasspathUtil.classname_for_rel_classfile(f) if classname: target_classes.add(classname) return target_classes
def _calculate_tests_from_targets(self, targets): """ :param list targets: list of targets to calculate test classes for. generates tuples (class_name, target). """ classpath_products = self._context.products.get_data( 'runtime_classpath') for target in targets: contents = ClasspathUtil.classpath_contents( (target, ), classpath_products, confs=self._task_exports.confs, transitive=False) for f in contents: classname = ClasspathUtil.classname_for_rel_classfile(f) if classname: yield (classname, target)
def classname_for_classfile(self, compile_context, class_file_name): assert class_file_name.startswith(compile_context.classes_dir) return ClasspathUtil.classname_for_rel_classfile(class_file_name[len(compile_context.classes_dir) + 1:])
def classname_for_classfile(self, compile_context, class_file_name): assert class_file_name.startswith(compile_context.classes_dir) rel_classfile_path = class_file_name[len(compile_context.classes_dir) + 1:] return ClasspathUtil.classname_for_rel_classfile(rel_classfile_path)
def _classfile_to_classname(cls): return ClasspathUtil.classname_for_rel_classfile(cls)
def _classfile_to_classname(cls): return ClasspathUtil.classname_for_rel_classfile(cls)