def test_copy(self): b = self.make_target('b', JvmTarget, excludes=[Exclude('com.example', 'lib')]) a = self.make_target('a', JvmTarget, dependencies=[b]) classpath_product = ClasspathProducts() resolved_jar = self.add_jar_classpath_element_for_path(classpath_product, a, self._example_jar_path()) classpath_product.add_for_target(a, [('default', self.path('a/path'))]) copied = classpath_product.copy() self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))], classpath_product.get_for_target(a)) self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))], copied.get_for_target(a)) self.add_excludes_for_targets(copied, b, a) self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))], classpath_product.get_for_target(a)) self.assertEqual([('default', self.path('a/path'))], copied.get_for_target(a)) copied.add_for_target(b, [('default', self.path('b/path'))]) self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))], classpath_product.get_for_target(a)) self.assertEqual([('default', self.path('a/path')), ('default', self.path('b/path'))], copied.get_for_target(a))
def test_single_classpath_element_no_excludes(self): a = self.make_target('a', JvmTarget) classpath_product = ClasspathProducts(self.pants_workdir) path = self.path('jar/path') self.add_jar_classpath_element_for_path(classpath_product, a, path) self.assertEqual([('default', path)], classpath_product.get_for_target(a))
def test_single_classpath_element_no_excludes(self): a = self.make_target('a', JvmTarget) classpath_product = ClasspathProducts() path = os.path.join(self.build_root, 'jar/path') self.add_jar_classpath_element_for_path(classpath_product, a, path) self.assertEqual([('default', path)], classpath_product.get_for_target(a))
def test_transitive_dependencies_excluded_classpath_element(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) self.add_jar_classpath_element_for_path(classpath_product, a, self._example_jar_path()) self.add_excludes_for_targets(classpath_product, b, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_excluded_classpath_element(self): a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example', 'lib')]) classpath_product = ClasspathProducts() example_jar_path = self._example_jar_path() classpath_product.add_for_target(a, [('default', example_jar_path)]) classpath_product.add_excludes_for_targets([a]) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_intransitive_dependencies_excluded_classpath_element(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() classpath_product.add_for_target(a, [('default', example_jar_path)]) classpath_product.add_excludes_for_targets([a, b]) intransitive_classpath = classpath_product.get_for_target(a) self.assertEqual([('default', example_jar_path)], intransitive_classpath)
def test_excludes_used_across_targets(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example', 'lib')]) classpath_product = ClasspathProducts() classpath_product.add_for_target(b, [('default', self._example_jar_path())]) classpath_product.add_excludes_for_targets([a]) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_excludes_org_name(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example')], dependencies=[b]) classpath_product = ClasspathProducts() classpath_product.add_for_target(b, [('default', self._example_jar_path())]) classpath_product.add_excludes_for_targets([a]) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_excludes_org_name(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example')], dependencies=[b]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, b) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_excludes_used_across_targets(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example', 'lib')]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, b) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_excludes_similar_org_name(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.exam')], dependencies=[b]) classpath_product = ClasspathProducts() self.add_example_jar_classpath_element_for(classpath_product, b) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(a) self.assertEqual([('default', self._example_jar_path())], classpath)
def test_excluded_classpath_element(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() self.add_jar_classpath_element_for_path(classpath_product, a, example_jar_path) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_jar_provided_exclude_with_similar_org(self): provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example.lib', '', Repository())) root = self.make_target('root', JvmTarget, dependencies=[provider]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, root) self.add_excludes_for_targets(classpath_product, provider, root) classpath = classpath_product.get_for_target(root) self.assertEqual([('default', self._example_jar_path())], classpath)
def test_parent_exclude_excludes_dependency_jar(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, dependencies=[b], excludes=[Exclude('com.example', 'lib')]) classpath_product = ClasspathProducts() example_jar_path = self._example_jar_path() self.add_jar_classpath_element_for_path(classpath_product, b, example_jar_path) self.add_excludes_for_targets(classpath_product, b, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_parent_exclude_excludes_dependency_jar(self): b = self.make_target("b", JvmTarget) a = self.make_target("a", JvmTarget, dependencies=[b], excludes=[Exclude("com.example", "lib")]) classpath_product = ClasspathProducts(self.pants_workdir) example_jar_path = self._example_jar_path() self.add_jar_classpath_element_for_path(classpath_product, b, example_jar_path) self.add_excludes_for_targets(classpath_product, b, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_parent_excludes_ignored_for_resolving_child_target(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, dependencies=[b], excludes=[Exclude('com.example', 'lib')]) example_jar_path = self._example_jar_path() classpath_product = ClasspathProducts(self.pants_workdir) self.add_jar_classpath_element_for_path(classpath_product, b, example_jar_path) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(b) self.assertEqual([('default', example_jar_path)], classpath)
def test_jar_provided_exclude_with_similar_name(self): # note exclude 'jars/com.example/l' should not match jars/com.example/lib/jars/123.4.jar provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example', 'li', Repository())) root = self.make_target('root', JvmTarget, dependencies=[provider]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, root) self.add_excludes_for_targets(classpath_product, provider, root) classpath = classpath_product.get_for_target(root) self.assertEqual([('default', self._example_jar_path())], classpath)
def test_jar_in_classpath_not_a_resolved_jar_ignored_by_excludes(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example')], dependencies=[b]) example_jar_path = self._example_jar_path() classpath_product = ClasspathProducts() classpath_product.add_for_target(b, [('default', example_jar_path)]) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(a) self.assertEqual([('default', example_jar_path)], classpath)
def test_jar_provided_by_transitive_target_excluded(self): provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example', 'lib', Repository())) consumer = self.make_target('consumer', JvmTarget) root = self.make_target('root', JvmTarget, dependencies=[provider, consumer]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, consumer) self.add_excludes_for_targets(classpath_product, consumer, provider, root) classpath = classpath_product.get_for_target(root) self.assertEqual([], classpath)
def test_jar_provided_by_transitive_target_excluded(self): provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example', 'lib', Repository())) consumer = self.make_target('consumer', JvmTarget) root = self.make_target('root', JvmTarget, dependencies=[provider, consumer]) classpath_product = ClasspathProducts() classpath_product.add_for_target(consumer, [('default', self._example_jar_path())]) classpath_product.add_excludes_for_targets([root, provider, consumer]) classpath = classpath_product.get_for_target(root) self.assertEqual([], classpath)
def test_excludes_org_name(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example')], dependencies=[b]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, b) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_jar_provided_exclude_with_similar_org(self): provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example.lib', '', Repository())) root = self.make_target('root', JvmTarget, dependencies=[provider]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, root) self.add_excludes_for_targets(classpath_product, provider, root) classpath = classpath_product.get_for_target(root) self.assertEqual([('default', self._example_jar_path())], classpath)
def test_intransitive_dependencies_excluded_classpath_element(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() classpath_product.add_for_target(a, [('default', example_jar_path)]) classpath_product.add_excludes_for_targets([a, b]) intransitive_classpath = classpath_product.get_for_target(a) self.assertEqual([('default', example_jar_path)], intransitive_classpath)
def test_exclude_leaves_other_jars_unaffected(self): b = self.make_target('b', JvmTarget, excludes=[Exclude('com.example', 'lib')]) a = self.make_target('a', JvmTarget, dependencies=[b]) classpath_product = ClasspathProducts() com_example_jar_path = self._example_jar_path() org_example_jar_path = os.path.join(self.build_root, 'ivy/jars/org.example/lib/123.4.jar') classpath_product.add_for_target(a, [('default', com_example_jar_path), ('default', org_example_jar_path)]) classpath_product.add_excludes_for_targets([b]) classpath = classpath_product.get_for_target(a) self.assertEqual([('default', org_example_jar_path)], classpath)
def test_excluded_classpath_element(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() self.add_jar_classpath_element_for_path(classpath_product, a, example_jar_path) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_jar_provided_exclude_with_similar_name(self): # note exclude 'jars/com.example/l' should not match jars/com.example/lib/jars/123.4.jar provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example', 'li', Repository())) root = self.make_target('root', JvmTarget, dependencies=[provider]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, root) self.add_excludes_for_targets(classpath_product, provider, root) classpath = classpath_product.get_for_target(root) self.assertEqual([('default', self._example_jar_path())], classpath)
def test_excludes_org_name(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, excludes=[Exclude('com.example')], dependencies=[b]) classpath_product = ClasspathProducts() classpath_product.add_for_target( b, [('default', self._example_jar_path())]) classpath_product.add_excludes_for_targets([a]) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_parent_exclude_excludes_dependency_jar(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, dependencies=[b], excludes=[Exclude('com.example', 'lib')]) classpath_product = ClasspathProducts() example_jar_path = self._example_jar_path() classpath_product.add_for_target(b, [('default', example_jar_path)]) classpath_product.add_excludes_for_targets([a, b]) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_parent_excludes_ignored_for_resolving_child_target(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, dependencies=[b], excludes=[Exclude('com.example', 'lib')]) example_jar_path = self._example_jar_path() classpath_product = ClasspathProducts(self.pants_workdir) self.add_jar_classpath_element_for_path(classpath_product, b, example_jar_path) self.add_excludes_for_targets(classpath_product, a) classpath = classpath_product.get_for_target(b) self.assertEqual([('default', example_jar_path)], classpath)
def test_parent_exclude_excludes_dependency_jar(self): b = self.make_target('b', JvmTarget) a = self.make_target('a', JvmTarget, dependencies=[b], excludes=[Exclude('com.example', 'lib')]) classpath_product = ClasspathProducts(self.pants_workdir) example_jar_path = self._example_jar_path() self.add_jar_classpath_element_for_path(classpath_product, b, example_jar_path) self.add_excludes_for_targets(classpath_product, b, a) classpath = classpath_product.get_for_target(a) self.assertEqual([], classpath)
def test_exclude_leaves_other_jars_unaffected(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) com_example_jar_path = self._example_jar_path() org_example_jar_path = self.path('ivy/jars/org.example/lib/123.4.jar') classpath_product.add_jars_for_targets([a], 'default', [resolved_example_jar_at(com_example_jar_path), resolved_example_jar_at(org_example_jar_path, org='org.example')]) self.add_excludes_for_targets(classpath_product, b) classpath = classpath_product.get_for_target(a) self.assertEqual([('default', org_example_jar_path)], classpath)
def test_exclude_leaves_other_jars_unaffected(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) com_example_jar_path = self._example_jar_path() org_example_jar_path = self.path('ivy/jars/org.example/lib/123.4.jar') classpath_product.add_jars_for_targets([a], 'default', [resolved_example_jar_at(com_example_jar_path), resolved_example_jar_at(org_example_jar_path, org='org.example')]) self.add_excludes_for_targets(classpath_product, b) classpath = classpath_product.get_for_target(a) self.assertEqual([('default', org_example_jar_path)], classpath)
def test_jar_provided_by_transitive_target_excluded(self): provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example', 'lib', Repository())) consumer = self.make_target('consumer', JvmTarget) root = self.make_target('root', JvmTarget, dependencies=[provider, consumer]) classpath_product = ClasspathProducts(self.pants_workdir) self.add_example_jar_classpath_element_for(classpath_product, consumer) self.add_excludes_for_targets(classpath_product, consumer, provider, root) classpath = classpath_product.get_for_target(root) self.assertEqual([], classpath)
def test_jar_provided_by_transitive_target_excluded(self): provider = self.make_target('provider', ExportableJvmLibrary, provides=Artifact('com.example', 'lib', Repository())) consumer = self.make_target('consumer', JvmTarget) root = self.make_target('root', JvmTarget, dependencies=[provider, consumer]) classpath_product = ClasspathProducts() classpath_product.add_for_target( consumer, [('default', self._example_jar_path())]) classpath_product.add_excludes_for_targets([root, provider, consumer]) classpath = classpath_product.get_for_target(root) self.assertEqual([], classpath)
def test_exclude_leaves_other_jars_unaffected(self): b = self.make_target('b', JvmTarget, excludes=[Exclude('com.example', 'lib')]) a = self.make_target('a', JvmTarget, dependencies=[b]) classpath_product = ClasspathProducts() com_example_jar_path = self._example_jar_path() org_example_jar_path = os.path.join( self.build_root, 'ivy/jars/org.example/lib/123.4.jar') classpath_product.add_for_target(a, [('default', com_example_jar_path), ('default', org_example_jar_path)]) classpath_product.add_excludes_for_targets([b]) classpath = classpath_product.get_for_target(a) self.assertEqual([('default', org_example_jar_path)], classpath)
def test_exclude_leaves_other_jars_unaffected(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) com_example_jar_path = self._example_jar_path() org_example_jar_path = self.path("ivy/jars/org.example/lib/123.4.jar") classpath_product.add_jars_for_targets( [a], "default", [ resolved_example_jar_at(com_example_jar_path), resolved_example_jar_at(org_example_jar_path, org="org.example"), ], ) self.add_excludes_for_targets(classpath_product, b) classpath = classpath_product.get_for_target(a) self.assertEqual([("default", org_example_jar_path)], classpath)
def test_exclude_leaves_other_jars_unaffected(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) com_example_jar_path = self._example_jar_path() org_example_jar_path = self.path("ivy/jars/org.example/lib/123.4.jar") classpath_product.add_jars_for_targets( [a], "default", [ resolved_example_jar_at(com_example_jar_path), resolved_example_jar_at(org_example_jar_path, org="org.example"), ], ) self.add_excludes_for_targets(classpath_product, b) classpath = classpath_product.get_for_target(a) self.assertEqual([("default", org_example_jar_path)], classpath)