Пример #1
0
  def _register_products(self, targets, analysis_file):
    classes_by_source = self.context.products.get_data('classes_by_source')
    classes_by_target = self.context.products.get_data('classes_by_target')
    resources_by_target = self.context.products.get_data('resources_by_target')

    if classes_by_source is not None or classes_by_target is not None:
      computed_classes_by_source = self._compute_classes_by_source(analysis_file)
      resource_mapping = ResourceMapping(self._classes_dir)
      for target in targets:
        target_products = classes_by_target[target] if classes_by_target is not None else None
        for source in self._sources_by_target.get(target, []):  # Source is relative to buildroot.
          classes = computed_classes_by_source.get(source, [])  # Classes are absolute paths.
          for cls in classes:
            resources = self._resources_by_class_file(cls, resource_mapping)
            resources_by_target[target].add_abs_paths(self._classes_dir, resources)

          if classes_by_target is not None:
            target_products.add_abs_paths(self._classes_dir, classes)
          if classes_by_source is not None:
            classes_by_source[source].add_abs_paths(self._classes_dir, classes)

    # TODO(pl): https://github.com/pantsbuild/pants/issues/206
    if resources_by_target is not None:
      for target in targets:
        target_resources = resources_by_target[target]
        for root, abs_paths in self.extra_products(target):
          target_resources.add_abs_paths(root, abs_paths)
 def compute_resource_mapping(self, compile_contexts):
     return ResourceMapping(self._classes_dir)
Пример #3
0
    def test_resource_mapping_noitems(self):
        rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping-broken-missing-items'
        resource_mapping = ResourceMapping(rel_dir)

        with self.assertRaises(ResourceMapping.MissingItemsLineException):
            resource_mapping.mappings
Пример #4
0
    def test_resource_mapping_mangled(self):
        rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping-broken-mangled'
        resource_mapping = ResourceMapping(rel_dir)

        with self.assertRaises(ResourceMapping.UnparseableLineException):
            resource_mapping.mappings
Пример #5
0
    def test_resource_mapping_long(self):
        rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping-broken-long'
        resource_mapping = ResourceMapping(rel_dir)

        with self.assertRaises(ResourceMapping.TooLongFileException):
            resource_mapping.mappings
Пример #6
0
    def test_resource_mapping_ok(self):
        rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping'
        resource_mapping = ResourceMapping(rel_dir)

        self.assertEquals(2, len(resource_mapping.mappings))