예제 #1
0
파일: filemap.py 프로젝트: online/commons
 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
예제 #2
0
파일: ide.py 프로젝트: collude/collude
        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])
예제 #3
0
파일: ide.py 프로젝트: collude/collude
    def __init__(self, root_dir, parser, argv):
        Command.__init__(self, root_dir, parser, argv)

        self.project_name = self.options.project_name
        addresses = self._parse_addresses() if self.args else scan_addresses(
            root_dir)
        self.targets = [Target.get(address) for address in addresses]
예제 #4
0
    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
예제 #5
0
    def execute(self):
        target = Target.get(self.address)

        if self.is_graph:
            self._print_digraph(target)
        else:
            self._print_dependency_tree(target)
예제 #6
0
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
예제 #7
0
파일: build.py 프로젝트: online/commons
    def execute(self):
        print "Build operating on address: %s" % self.address

        try:
            target = Target.get(self.address)
        except:
            self.error("Problem parsing BUILD target %s: %s" %
                       (self.address, traceback.format_exc()))

        if not target:
            self.error("Target %s does not exist" % self.address)

        return self._build(target)
예제 #8
0
    def __init__(self, root_dir, parser, argv):
        Command.__init__(self, root_dir, parser, argv)

        if not self.args:
            self.error("A spec argument is required")

        try:
            specs_end = self.args.index('--')
            if len(self.args) > specs_end:
                self.build_args = self.args.__getslice__(
                    specs_end + 1,
                    len(self.args) + 1)
            else:
                self.build_args = []
        except ValueError:
            specs_end = 1
            self.build_args = self.args[1:] if len(self.args) > 1 else []

        self.targets = OrderedSet()
        for spec in self.args.__getslice__(0, specs_end):
            try:
                address = Address.parse(root_dir, spec)
            except:
                self.error("Problem parsing spec %s: %s" %
                           (spec, traceback.format_exc()))

            try:
                target = Target.get(address)
            except:
                self.error("Problem parsing BUILD target %s: %s" %
                           (address, traceback.format_exc()))

            try:
                InternalTarget.check_cycles(target)
            except CycleException as e:
                self.error("Target contains an internal dependency cycle: %s" %
                           e)

            if not target:
                self.error("Target %s does not exist" % address)
            if not target.address.is_meta:
                target.address.is_meta = self.options.is_meta or address.is_meta
            self.targets.add(target)

        self.is_ide = self.options.is_ide
        self.ide_transitivity = self.options.ide_transitivity
예제 #9
0
파일: doc.py 프로젝트: online/commons
  def _parse_targets(self, root_dir):
    targets = OrderedSet()
    for spec in self.args:
      try:
        address = Address.parse(root_dir, spec)
      except:
        self.error("Problem parsing spec %s: %s" % (spec, traceback.format_exc()))

      try:
        target = Target.get(address)
      except:
        self.error("Problem parsing target %s: %s" % (address, traceback.format_exc()))

      if not Doc._is_documentable(target):
        self.error("Target: %s is not documentable" % address)

      targets.add(target)

    return targets
예제 #10
0
    def __init__(self, root_dir, parser, argv):
        Command.__init__(self, root_dir, parser, argv)

        if len(self.args) is not 1:
            self.error("Exactly one BUILD address is required.")

        spec = self.args[0]
        try:
            address = Address.parse(root_dir, spec)
        except:
            self.error("Problem parsing spec %s: %s" %
                       (spec, traceback.format_exc()))

        try:
            self.target = Target.get(address)
        except:
            self.error("Problem parsing BUILD target %s: %s" %
                       (address, traceback.format_exc()))

        if not self.target:
            self.error("Target %s does not exist" % address)
예제 #11
0
 def _print_provides(self, column_extractors, address):
     target = Target.get(address)
     if isinstance(target, ExportableJavaLibrary) and target.provides:
         return " ".join(
             extractor(target) for extractor in column_extractors)
예제 #12
0
 def execute(self):
   for sourcefile in Target.get(self.address).sources:
     print sourcefile
예제 #13
0
파일: doc.py 프로젝트: collude/collude
 def get_targets():
     for address in util.scan_addresses(root_dir):
         target = Target.get(address)
         if Doc._is_documentable(target):
             yield target
예제 #14
0
파일: list.py 프로젝트: collude/collude
 def _print_provides(self, column_extractors, address):
   target = Target.get(address)
   if is_exported(target):
     return " ".join(extractor(target) for extractor in column_extractors)