示例#1
0
文件: ide.py 项目: cscotta/commons
def extract_target(java_targets, is_transitive, name = None):
  meta_target = bang.extract_target(java_targets, name)

  internal_deps, jar_deps = _extract_target(meta_target,
                                            is_transitive,
                                            lambda target: is_apt(target))

  # TODO(John Sirois): make an empty source set work in ant/compile.xml
  sources = [ '__no_source__' ]

  all_deps = OrderedSet()
  all_deps.update(internal_deps)
  all_deps.update(jar_deps)

  if is_java(meta_target):
    return JavaLibrary('ide',
                       sources,
                       dependencies = all_deps,
                       excludes = meta_target.excludes,
                       is_meta = True)
  elif is_scala(meta_target):
    return ScalaLibrary('ide',
                        sources,
                        dependencies = all_deps,
                        excludes = meta_target.excludes,
                        is_meta = True)
  else:
    raise TypeError("Cannot generate IDE configuration for targets: %s" % java_targets)
示例#2
0
文件: ide.py 项目: JoeEnnever/commons
def extract_target(java_targets, is_classpath):
  primary_target = InternalTarget.sort_targets(java_targets)[0]

  with ParseContext.temp(primary_target.target_base):
    internal_deps, jar_deps = _extract_target(java_targets, is_classpath)

    # TODO(John Sirois): make an empty source set work in ant/compile.xml
    sources = [ '__no_source__' ]

    all_deps = OrderedSet()
    all_deps.update(internal_deps)
    all_deps.update(jar_deps)

    if is_java(primary_target):
      return JavaLibrary('ide',
                         sources,
                         dependencies = all_deps,
                         is_meta = True)
    elif is_scala(primary_target):
      return ScalaLibrary('ide',
                          sources,
                          dependencies = all_deps,
                          is_meta = True)
    else:
      raise TypeError("Cannot generate IDE configuration for targets: %s" % java_targets)
示例#3
0
文件: ide.py 项目: DikangGu/commons
    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(ExportableJvmLibrary.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 ])
示例#4
0
文件: ide.py 项目: billwei/commons
def extract_target(java_targets, is_transitive, is_classpath, name = None):
  meta_target = bang.extract_target(java_targets, name)

  internal_deps, jar_deps = _extract_target(meta_target, is_transitive, is_classpath)

  # TODO(John Sirois): make an empty source set work in ant/compile.xml
  sources = [ '__no_source__' ]

  all_deps = OrderedSet()
  all_deps.update(internal_deps)
  all_deps.update(jar_deps)

  if is_java(meta_target):
    return JavaLibrary('ide',
                       sources,
                       dependencies = all_deps,
                       excludes = meta_target.excludes,
                       is_meta = True)
  elif is_scala(meta_target):
    return ScalaLibrary('ide',
                        sources,
                        dependencies = all_deps,
                        excludes = meta_target.excludes,
                        is_meta = True)
  else:
    raise TypeError("Cannot generate IDE configuration for targets: %s" % java_targets)
示例#5
0
 def calculate_tests(self, targets):
     tests = OrderedSet()
     for target in targets:
         if is_scala(target) and is_test(target):
             tests.update(
                 os.path.join(target.target_base, test)
                 for test in target.sources)
     return tests
示例#6
0
        def is_cp(target):
            return (
                is_codegen(target)

                # Some IDEs need annotation processors pre-compiled, others are smart enough to detect and
                # proceed in 2 compile rounds
                or is_apt(target) or (self.skip_java and is_java(target)) or
                (self.skip_scala and is_scala(target)) or
                (self.intransitive
                 and target not in self.context.target_roots))
示例#7
0
    def is_cp(target):
      return (
        target.is_codegen

        # Some IDEs need annotation processors pre-compiled, others are smart enough to detect and
        # proceed in 2 compile rounds
        or is_apt(target)

        or (self.skip_java and is_java(target))
        or (self.skip_scala and is_scala(target))
      )
示例#8
0
    def is_cp(target):
      return (
        is_codegen(target)

        # Some IDEs need annotation processors pre-compiled, others are smart enough to detect and
        # proceed in 2 compile rounds
        or is_apt(target)

        or (self.skip_java and is_java(target))
        or (self.skip_scala and is_scala(target))
        or (self.intransitive and target not in self.context.target_roots)
      )
示例#9
0
文件: ide.py 项目: cscotta/commons
        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(
                            ExportableJvmLibrary.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)

                # Other BUILD files may specify sources in the same directory as this target.  Those BUILD
                # files might be in parent directories (globs('a/b/*.java')) or even children directories if
                # this target globs children as well.  Gather all these candidate BUILD files to test for
                # sources they own that live in the directories this targets sources live in.
                target_dirset = find_source_basedirs(target)
                candidates = Target.get_all_addresses(target.address.buildfile)
                for ancestor in target.address.buildfile.ancestors():
                    candidates.update(Target.get_all_addresses(ancestor))
                for sibling in target.address.buildfile.siblings():
                    candidates.update(Target.get_all_addresses(sibling))
                for descendant in target.address.buildfile.descendants():
                    candidates.update(Target.get_all_addresses(descendant))

                def is_sibling(target):
                    return source_target(
                        target) and target_dirset.intersection(
                            find_source_basedirs(target))

                return filter(
                    is_sibling,
                    [Target.get(a) for a in candidates if a != target.address])
示例#10
0
  def calculate_tests(self, targets):
    def is_test_file(test):
      # TODO(John Sirois): config for a list of include regexes and exclude regexes
      basename = os.path.basename(test)
      return (test.endswith('Test.scala')
              or test.endswith('IT.scala')
              or test.endswith('Spec.scala')) \
             and not basename.startswith('Base') and not basename.startswith('Abstract')

    tests = set()
    for target in targets:
      if is_scala(target) and is_test(target):
        tests.update(os.path.join(target.target_base, test) for test in target.sources
                     if is_test_file(test))
    return tests
示例#11
0
        def configure_target(target):
            if target not in analyzed:
                analyzed.add(target)

                self.has_scala = not self.skip_scala and (self.has_scala
                                                          or is_scala(target))

                if isinstance(target, JavaLibrary) or isinstance(
                        target, ScalaLibrary):
                    resources = set()
                    if target.resources:
                        resources.update(target.resources)
                    if resources:
                        self.resource_extensions.update(
                            Project.extract_resource_extensions(resources))
                        configure_source_sets(target.sibling_resources_base,
                                              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)

                # Other BUILD files may specify sources in the same directory as this target.  Those BUILD
                # files might be in parent directories (globs('a/b/*.java')) or even children directories if
                # this target globs children as well.  Gather all these candidate BUILD files to test for
                # sources they own that live in the directories this targets sources live in.
                target_dirset = find_source_basedirs(target)
                candidates = Target.get_all_addresses(target.address.buildfile)
                for ancestor in target.address.buildfile.ancestors():
                    candidates.update(Target.get_all_addresses(ancestor))
                for sibling in target.address.buildfile.siblings():
                    candidates.update(Target.get_all_addresses(sibling))
                for descendant in target.address.buildfile.descendants():
                    candidates.update(Target.get_all_addresses(descendant))

                def is_sibling(target):
                    return source_target(
                        target) and target_dirset.intersection(
                            find_source_basedirs(target))

                return filter(
                    is_sibling,
                    [Target.get(a) for a in candidates if a != target.address])
示例#12
0
文件: ide.py 项目: crnt/commons
    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(ExportableJvmLibrary.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)

        # Other BUILD files may specify sources in the same directory as this target.  Those BUILD
        # files might be in parent directories (globs('a/b/*.java')) or even children directories if
        # this target globs children as well.  Gather all these candidate BUILD files to test for
        # sources they own that live in the directories this targets sources live in.
        target_dirset = find_source_basedirs(target)
        candidates = Target.get_all_addresses(target.address.buildfile)
        for ancestor in target.address.buildfile.ancestors():
          candidates.update(Target.get_all_addresses(ancestor))
        for sibling in target.address.buildfile.siblings():
          candidates.update(Target.get_all_addresses(sibling))
        for descendant in target.address.buildfile.descendants():
          candidates.update(Target.get_all_addresses(descendant))

        def is_sibling(target):
          return source_target(target) and target_dirset.intersection(find_source_basedirs(target))

        return filter(is_sibling, [ Target.get(a) for a in candidates if a != target.address ])
示例#13
0
    def configure_target(target):
      if target not in analyzed:
        analyzed.add(target)

        self.has_scala = not self.skip_scala and (self.has_scala or is_scala(target))

        if isinstance(target, JavaLibrary) or isinstance(target, ScalaLibrary):
          resources = set()
          if target.resources:
            resources.update(target.resources)
          if resources:
            self.resource_extensions.update(Project.extract_resource_extensions(resources))
            configure_source_sets(target.sibling_resources_base,
                                  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)

        # Other BUILD files may specify sources in the same directory as this target.  Those BUILD
        # files might be in parent directories (globs('a/b/*.java')) or even children directories if
        # this target globs children as well.  Gather all these candidate BUILD files to test for
        # sources they own that live in the directories this targets sources live in.
        target_dirset = find_source_basedirs(target)
        candidates = Target.get_all_addresses(target.address.buildfile)
        for ancestor in target.address.buildfile.ancestors():
          candidates.update(Target.get_all_addresses(ancestor))
        for sibling in target.address.buildfile.siblings():
          candidates.update(Target.get_all_addresses(sibling))
        for descendant in target.address.buildfile.descendants():
          candidates.update(Target.get_all_addresses(descendant))

        def is_sibling(target):
          return source_target(target) and target_dirset.intersection(find_source_basedirs(target))

        return filter(is_sibling, [ Target.get(a) for a in candidates if a != target.address ])
示例#14
0
 def source_target(target):
   return (self.transitive or target in self.targets) and has_sources(target) \
       and (not is_codegen(target)
            and not (self.skip_java and is_java(target))
            and not (self.skip_scala and is_scala(target)))
示例#15
0
文件: ide.py 项目: znewman01/commons
 def is_cp(target):
   return target.is_codegen \
          or is_apt(target) \
          or (skip_java and is_java(target)) \
          or (skip_scala and is_scala(target))
示例#16
0
 def source_target(target):
     return (self.transitive or target in self.targets) and has_sources(target) \
         and (not is_codegen(target)
              and not (self.skip_java and is_java(target))
              and not (self.skip_scala and is_scala(target)))
示例#17
0
 def is_coverage_target(self, tgt):
   return (is_java(tgt) or is_scala(tgt)) and not is_test(tgt) and not is_codegen(tgt)
示例#18
0
 def calculate_tests(self, targets):
   for target in targets:
     if (is_java(target) or is_scala(target)) and is_test(target):
       for test in target.sources:
         for cls in self.normalize(test, target.target_base):
           yield cls
示例#19
0
文件: goal.py 项目: wangnana/commons
def _is_scala(target):
    return (is_scala(target)
            or (isinstance(target, (JvmBinary, junit_tests, Benchmark))
                and _has_sources(target, '.scala')))
示例#20
0
 def is_coverage_target(self, tgt):
     return (is_java(tgt)
             or is_scala(tgt)) and not is_test(tgt) and not is_codegen(tgt)
示例#21
0
 def calculate_tests(self, targets):
     for target in targets:
         if (is_java(target) or is_scala(target)) and is_test(target):
             for test in target.sources:
                 for cls in self.normalize(test, target.target_base):
                     yield cls
示例#22
0
文件: ide.py 项目: znewman01/commons
 def source_target(target):
   return has_sources(target) \
       and (not target.is_codegen
            and not (self.skip_java and is_java(target))
            and not (self.skip_scala and is_scala(target)))
示例#23
0
 def calculate_tests(self, targets):
   tests = OrderedSet()
   for target in targets:
     if is_scala(target) and is_test(target):
       tests.update(os.path.join(target.target_base, test) for test in target.sources)
   return tests
示例#24
0
def _is_scala(target):
  return (is_scala(target)
          or (isinstance(target, (JvmBinary, junit_tests, Benchmark))
              and _has_sources(target, '.scala')))