def configure_target(target): if target not in analyzed: analyzed.add(target) self.has_scala = self.has_scala or is_scala(target) if isinstance(target, JavaLibrary) or isinstance( target, ScalaLibrary): # TODO(John Sirois): this does not handle test resources, make test resources 1st class # in ant build and punch this through to pants model resources = set() if target.resources: resources.update(target.resources) if target.binary_resources: resources.update(target.binary_resources) if resources: self.resource_extensions.update( Project.extract_resource_extensions(resources)) configure_source_sets(RESOURCES_BASE_DIR, resources, is_test=False) if target.sources: test = is_test(target) self.has_tests = self.has_tests or test configure_source_sets(target.target_base, target.sources, is_test=test) siblings = Target.get_all_addresses(target.address.buildfile) return filter( accept_target, [Target.get(a) for a in siblings if a != target.address])
def execute(self): if self.options.only_provides: def extract_artifact_id(target): provided_jar = target._as_jar_dependency() return "%s%s%s" % (provided_jar.org, self.options.separator, provided_jar.name) extractors = dict( address=lambda target: str(target.address), artifact_id=extract_artifact_id, repo_name=lambda target: target.provides.repo.name, repo_url=lambda target: target.provides.repo.url, repo_db=lambda target: target.provides.repo.push_db, ) column_extractors = [ extractors[col] for col in (self.options.provides_columns.split(',')) ] print_fn = lambda address: self._print_provides( column_extractors, address) else: print_fn = lambda address: str(address) for buildfile in self.buildfiles: for address in Target.get_all_addresses(buildfile): line = print_fn(address) if line: print line
def execute(self): for buildfile in BuildFile.scan_buildfiles(self.root_dir): for address in Target.get_all_addresses(buildfile): target = Target.get(address) if hasattr(target, 'sources'): for sourcefile in target.sources: print sourcefile, address
def configure_target(target): if target not in analyzed: analyzed.add(target) self.has_scala = self.has_scala or is_scala(target) if isinstance(target, JavaLibrary) or isinstance(target, ScalaLibrary): # TODO(John Sirois): this does not handle test resources, make test resources 1st class # in ant build and punch this through to pants model resources = set() if target.resources: resources.update(target.resources) if target.binary_resources: resources.update(target.binary_resources) if resources: self.resource_extensions.update(Project.extract_resource_extensions(resources)) configure_source_sets(RESOURCES_BASE_DIR, resources, is_test = False) if target.sources: test = is_test(target) self.has_tests = self.has_tests or test configure_source_sets(target.target_base, target.sources, is_test = test) siblings = Target.get_all_addresses(target.address.buildfile) return filter(accept_target, [ Target.get(a) for a in siblings if a != target.address ])
def scan_addresses(root_dir, base_path=None): """Parses all targets available in BUILD files under base_path and returns their addresses. If no base_path is specified, root_dir is assumed to be the base_path""" addresses = OrderedSet() for buildfile in BuildFile.scan_buildfiles(root_dir, base_path): addresses.update(Target.get_all_addresses(buildfile)) return addresses
def scan_addresses(root_dir, base_path = None): """Parses all targets available in BUILD files under base_path and returns their addresses. If no base_path is specified, root_dir is assumed to be the base_path""" addresses = OrderedSet() for buildfile in BuildFile.scan_buildfiles(root_dir, base_path): addresses.update(Target.get_all_addresses(buildfile)) return addresses
def execute(self): if self.options.only_provides: def extract_artifact_id(target): provided_jar = target._as_jar_dependency() return "%s%s%s" % (provided_jar.org, self.options.separator, provided_jar.name) extractors = dict( address = lambda target: str(target.address), artifact_id = extract_artifact_id, repo_name = lambda target: target.provides.repo.name, repo_url = lambda target: target.provides.repo.url, repo_db = lambda target: target.provides.repo.push_db, ) column_extractors = [ extractors[col] for col in (self.options.provides_columns.split(',')) ] print_fn = lambda address: self._print_provides(column_extractors, address) else: print_fn = lambda address: str(address) for buildfile in self.buildfiles: for address in Target.get_all_addresses(buildfile): line = print_fn(address) if line: print line