コード例 #1
0
    def test_get_product_target_mappings_for_targets_intransitive(self):
        b = self.make_target('b',
                             JvmTarget,
                             excludes=[Exclude('com.example', 'lib')])
        a = self.make_target('a', JvmTarget, dependencies=[b])

        classpath_product = ClasspathProducts(self.pants_workdir)
        example_jar_path = self._example_jar_path()
        resolved_jar = self.add_jar_classpath_element_for_path(
            classpath_product, a, example_jar_path)

        classpath_product.add_for_target(
            b, [('default', self.path('b/loose/classes/dir'))])
        classpath_product.add_for_target(
            a, [('default', self.path('a/loose/classes/dir')),
                ('default', self.path('an/internally/generated.jar'))])

        classpath_target_tuples = classpath_product.get_product_target_mappings_for_targets(
            [a])
        self.assertEqual([
            (('default',
              ArtifactClasspathEntry(example_jar_path, resolved_jar.coordinate,
                                     resolved_jar.cache_path)), a),
            (('default', ClasspathEntry(self.path('a/loose/classes/dir'))), a),
            (('default',
              ClasspathEntry(self.path('an/internally/generated.jar'))), a)
        ], classpath_target_tuples)
コード例 #2
0
  def test_get_product_target_mappings_for_targets_ignore_excludes(self):
    a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example', 'lib')])

    classpath_product = ClasspathProducts(self.pants_workdir)
    example_jar_path = self._example_jar_path()
    resolved_jar = self.add_jar_classpath_element_for_path(classpath_product, a, example_jar_path,
                                                           conf='fred-conf')
    self.add_excludes_for_targets(classpath_product, a)

    classpath_target_tuples = classpath_product.get_product_target_mappings_for_targets([a], respect_excludes=False)

    expected_entry = ArtifactClasspathEntry(example_jar_path,
                                            resolved_jar.coordinate,
                                            resolved_jar.cache_path)
    self.assertEqual([(('fred-conf', expected_entry), a)], classpath_target_tuples)
コード例 #3
0
  def test_get_classpath_entries_for_targets_dedup(self):
    b = self.make_target('b', JvmTarget)
    a = self.make_target('a', JvmTarget, dependencies=[b])
    classpath_product = ClasspathProducts(self.pants_workdir)
    example_jar_path = self._example_jar_path()

    # resolved_jar is added for both a and b but should return only as one classpath entry
    resolved_jar = self.add_jar_classpath_element_for_path(classpath_product, a, example_jar_path,
                                                           conf='fred-conf')
    self.add_jar_classpath_element_for_path(classpath_product, b, example_jar_path,
                                            conf='fred-conf')
    classpath_target_tuples = classpath_product.get_classpath_entries_for_targets([a], respect_excludes=False)

    expected_entry = ArtifactClasspathEntry(example_jar_path,
                                            resolved_jar.coordinate,
                                            resolved_jar.cache_path)
    self.assertEqual([('fred-conf', expected_entry)], classpath_target_tuples)
コード例 #4
0
  def test_get_artifact_classpath_entries_for_targets(self):
    b = self.make_target('b', JvmTarget, excludes=[Exclude('com.example', 'lib')])
    a = self.make_target('a', JvmTarget, dependencies=[b])

    classpath_product = ClasspathProducts(self.pants_workdir)
    example_jar_path = self._example_jar_path()
    resolved_jar = self.add_jar_classpath_element_for_path(classpath_product, a, example_jar_path)

    # These non-artifact classpath entries should be ignored.
    classpath_product.add_for_target(b, [('default', self.path('b/loose/classes/dir'))])
    classpath_product.add_for_target(a, [('default', self.path('a/loose/classes/dir')),
                                         ('default', self.path('an/internally/generated.jar'))])

    classpath = classpath_product.get_artifact_classpath_entries_for_targets([a])
    self.assertEqual([('default', ArtifactClasspathEntry(example_jar_path,
                                                         resolved_jar.coordinate,
                                                         resolved_jar.cache_path))],
                     classpath)