def test_validation(self): internal_repo = Repository(url=None, push_db_basedir=None) # Adding a JVM Artifact as a provides on a PythonTarget doesn't make a lot of sense. # This test sets up that very scenario, and verifies that pants throws a # TargetDefinitionException. with self.assertRaises(TargetDefinitionException): self.make_target(target_type=PythonTarget, spec=":one", provides=Artifact(org='com.twitter', name='one-jar', repo=internal_repo)) spec = "//:test-with-PythonArtifact" pa = PythonArtifact(name='foo', version='1.0', description='foo') # This test verifies that adding a 'setup_py' provides to a PythonTarget is okay. pt_with_artifact = self.make_target(spec=spec, target_type=PythonTarget, provides=pa) self.assertEqual(pt_with_artifact.address.spec, spec) spec = "//:test-with-none" # This test verifies that having no provides is okay. pt_no_artifact = self.make_target(spec=spec, target_type=PythonTarget, provides=None) self.assertEqual(pt_no_artifact.address.spec, spec)
def provides_artifact(provides_name): if provides_name is None: return None jvm_repo = Repository( name='maven-central', url='http://maven.example.com', push_db_basedir=os.path.join('build-support', 'ivy', 'pushdb'), ) return parse_context.create_object('artifact', org=org, name=provides_name, repo=jvm_repo)
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_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_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 alias_groups(self): return BuildFileAliases.create( targets={ 'target': Dependencies, 'jar_library': JarLibrary, 'java_library': JavaLibrary, }, objects={ 'artifact': Artifact, 'jar': JarDependency, 'repo': Repository(name='repo', url='http://www.www.com', push_db_basedir=os.path.join(self.build_root, 'repo')), } )
def alias_groups(self): return BuildFileAliases(targets={ 'target': Dependencies, 'java_library': JavaLibrary, }, objects={ 'pants': lambda x: x, 'artifact': Artifact, 'public': Repository(name='public', url='http://maven.example.com', push_db_basedir='/tmp'), })
def alias_groups(cls): return BuildFileAliases( targets={ 'target': Target, 'java_library': JavaLibrary, 'python_library': PythonLibrary, }, objects={ 'pants': lambda x: x, 'artifact': Artifact, 'scala_artifact': ScalaArtifact, 'public': Repository(name='public', url='http://maven.example.com', push_db_basedir='/tmp'), } )
def alias_groups(self): self.push_db_basedir = os.path.join(self.build_root, "pushdb") safe_mkdir(self.push_db_basedir) return BuildFileAliases.create( targets={ 'jar_library': JarLibrary, 'java_library': JavaLibrary, 'target': Dependencies, }, objects={ 'artifact': Artifact, 'internal': Repository(name='internal', url='http://example.com', push_db_basedir=self.push_db_basedir), }, )
def alias_groups(cls): return BuildFileAliases( targets={ "target": Target, "java_library": JavaLibrary, "python_library": PythonLibrary, }, objects={ "pants": lambda x: x, "artifact": Artifact, "scala_artifact": ScalaArtifact, "public": Repository( name="public", url="http://maven.example.com", push_db_basedir="/tmp" ), }, )
def alias_groups(cls): cls.push_db_basedir = os.path.join(cls._build_root(), "pushdb") safe_mkdir(cls.push_db_basedir) return BuildFileAliases( targets={ 'jar_library': JarLibrary, 'java_library': JavaLibrary, 'target': Target, }, objects={ 'artifact': Artifact, 'scala_artifact': ScalaArtifact, 'internal': Repository(name='internal', url='http://example.com', push_db_basedir=cls.push_db_basedir), }, )
def alias_groups(cls): return BuildFileAliases( targets={ 'jar_library': JarLibrary, 'java_library': JavaLibrary, 'target': Target, }, objects={ 'artifact': Artifact, 'scala_artifact': ScalaArtifact, }, context_aware_object_factories={ 'internal': lambda _: Repository( name='internal', url='http://example.com', push_db_basedir=cls.push_db_basedir ), }, )
def test_list_provides() -> None: sample_repo = Repository(name="public", url="http://maven.example.com", push_db_basedir="/tmp") sample_artifact = Artifact(org="example_org", name="test", repo=sample_repo) targets = [ MockTarget({ProvidesField.alias: sample_artifact}, address=Address.parse(":provided")), MockTarget({}, address=Address.parse(":not_provided")), ] stdout, _ = run_goal(targets, show_provides=True) assert stdout.strip() == "//:provided example_org#test" # Custom columns stdout, _ = run_goal( targets, show_provides=True, provides_columns="push_db_basedir,address,repo_url,repo_name,artifact_id", ) assert stdout.strip() == "/tmp //:provided http://maven.example.com public example_org#test"
def alias_groups(cls): return BuildFileAliases( targets={ 'target': Target, 'jar_library': JarLibrary, 'java_library': JavaLibrary, }, objects={ 'artifact': Artifact, 'jar': JarDependency, 'scala_artifact': ScalaArtifact, 'scala_jar': ScalaJarDependency, 'repo': Repository(name='repo', url='http://www.www.com', push_db_basedir=os.path.join(cls._build_root(), 'repo')), } )
def alias_groups(cls): return BuildFileAliases( targets={ "jar_library": JarLibrary, "java_library": JavaLibrary, "target": Target }, objects={ "artifact": Artifact, "scala_artifact": ScalaArtifact }, context_aware_object_factories={ "internal": lambda _: Repository(name="internal", url="http://example.com", push_db_basedir=cls.push_db_basedir), }, )
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 alias_groups(cls): return BuildFileAliases( targets={ "target": Target, "jar_library": JarLibrary, "java_library": JavaLibrary, }, objects={ "artifact": Artifact, "jar": JarDependency, "scala_artifact": ScalaArtifact, "scala_jar": ScalaJarDependency, }, context_aware_object_factories={ "repo": lambda _: Repository(name="repo", url="http://www.www.com", push_db_basedir=cls.push_db_basedir), }, )
def test_validation(self): repo = Repository(name="myRepo", url="myUrl", push_db_basedir="myPushDb") Artifact(org="testOrg", name="testName", repo=repo, description="Test") with self.assertRaises(ValueError): Artifact(org=1, name="testName", repo=repo, description="Test") with self.assertRaises(ValueError): Artifact(org="testOrg", name=1, repo=repo, description="Test") with self.assertRaises(ValueError): Artifact(org="testOrg", name="testName", repo=1, description="Test") with self.assertRaises(ValueError): Artifact(org="testOrg", name="testName", repo=repo, description=1)
def alias_groups(cls): return BuildFileAliases( targets={ 'target': Target, 'jar_library': JarLibrary, 'java_library': JavaLibrary, }, objects={ 'artifact': Artifact, 'jar': JarDependency, 'scala_artifact': ScalaArtifact, 'scala_jar': ScalaJarDependency, }, context_aware_object_factories={ 'repo': lambda _: Repository(name='repo', url='http://www.www.com', push_db_basedir=cls.push_db_basedir), }, )
def test_validation(self): repo = Repository(name="myRepo", url="myUrl", push_db_basedir="myPushDb") class TestPublicationMetadata(PublicationMetadata): def _compute_fingerprint(self): return None metadata = TestPublicationMetadata() Artifact(org="testOrg", name="testName", repo=repo, publication_metadata=metadata) with self.assertRaises(ValueError): Artifact(org=1, name="testName", repo=repo, publication_metadata=metadata) with self.assertRaises(ValueError): Artifact(org="testOrg", name=1, repo=repo, publication_metadata=metadata) with self.assertRaises(ValueError): Artifact(org="testOrg", name="testName", repo=1, publication_metadata=metadata) with self.assertRaises(ValueError): Artifact(org="testOrg", name="testName", repo=repo, publication_metadata=1)
import os from pants.backend.jvm.ossrh_publication_metadata import ( Developer, License, OSSRHPublicationMetadata, Scm, ) from pants.backend.jvm.repository import Repository from pants.base.build_environment import get_buildroot from pants.build_graph.build_file_aliases import BuildFileAliases oss_sonatype_repo = Repository( name='oss_sonatype_repo', url='https://oss.sonatype.org/#stagingRepositories', push_db_basedir=os.path.join(get_buildroot(), 'build-support', 'fsqio', 'pushdb'), ) def io_fsq_publication_metadata(description): return OSSRHPublicationMetadata( description=description, url='http://github.com/foursquare/fsqio', licenses=[ License( name='Apache License, Version 2.0', url='http://www.apache.org/licenses/LICENSE-2.0' ) ], developers=[
# Licensed under the Apache License, Version 2.0 (see LICENSE). import os from pants.backend.jvm.ossrh_publication_metadata import ( Developer, License, OSSRHPublicationMetadata, Scm, ) from pants.backend.jvm.repository import Repository from pants.build_graph.build_file_aliases import BuildFileAliases public_repo = Repository( name="public", url="https://oss.sonatype.org/#stagingRepositories", push_db_basedir=os.path.join("build-support", "ivy", "pushdb"), ) testing_repo = Repository( name="testing", url="https://dl.bintray.com/pantsbuild/maven", push_db_basedir=os.path.join("testprojects", "ivy", "pushdb"), ) def org_pantsbuild_publication_metadata(description): return OSSRHPublicationMetadata( description=description, url="http://pantsbuild.github.io/", licenses=[
# coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (nested_scopes, generators, division, absolute_import, with_statement, print_function, unicode_literals) import os from pants.backend.jvm.repository import Repository from pants.base.build_file_aliases import BuildFileAliases from pants.base.build_manual import manual public_repo = Repository(name = 'public', url = 'http://maven.twttr.com', push_db_basedir = os.path.join('build-support', 'ivy', 'pushdb')) testing_repo = Repository(name = 'testing', url = 'http://maven.twttr.com', push_db_basedir = os.path.join('testprojects', 'ivy', 'pushdb')) # Your repositories don't need this manual.builddict magic. # It keeps these examples out of http://pantsbuild.github.io/build_dictionary.html manual.builddict(suppress=True)(public_repo) manual.builddict(suppress=True)(testing_repo) def build_file_aliases(): return BuildFileAliases.create( objects={
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) import os from pants.backend.jvm.ossrh_publication_metadata import ( Developer, License, OSSRHPublicationMetadata, Scm) from pants.backend.jvm.repository import Repository from pants.build_graph.build_file_aliases import BuildFileAliases public_repo = Repository(name='public', url='https://oss.sonatype.org/#stagingRepositories', push_db_basedir=os.path.join('build-support', 'ivy', 'pushdb')) local_repo = Repository(name='local', url='', push_db_basedir=os.path.join('build-support', 'ivy', 'pushdb')) def org_pantsbuild_publication_metadata(description): return OSSRHPublicationMetadata( description=description, url='https://github.com/ActionIQ-OSS', licenses=[ License(name='Apache License, Version 2.0', url='http://www.apache.org/licenses/LICENSE-2.0') ], developers=[ Developer(name='Larry Finn',
# ================================================================================================== import os from pants.backend.jvm.repository import Repository from pants.build_graph.build_file_aliases import BuildFileAliases from pants.goal.task_registrar import TaskRegistrar as task from twitter.common.pants.python.commons.read_contents import read_contents_factory from twitter.common.pants.python.commons.remote_python_thrift_fileset import ( RemotePythonThriftFileset) from twitter.common.pants.python.commons.version import Version public_repo = Repository(name='public', url='http://maven.twttr.com', push_db_basedir=os.path.join('build-support', 'commons', 'ivy', 'pushdb')) def build_file_aliases(): return BuildFileAliases( objects={ 'commons_version': Version('src/python/twitter/common/VERSION').version, 'public': public_repo, # key 'public' must match name='public' above) }, context_aware_object_factories={ 'read_contents': read_contents_factory, 'remote_python_thrift_fileset': RemotePythonThriftFileset.factory,
# Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) import os from pants.backend.jvm.ossrh_publication_metadata import (Developer, License, OSSRHPublicationMetadata, Scm) from pants.backend.jvm.repository import Repository from pants.base.build_file_aliases import BuildFileAliases from pants.base.build_manual import manual public_repo = Repository(name='public', url='https://oss.sonatype.org/#stagingRepositories', push_db_basedir=os.path.join('build-support', 'ivy', 'pushdb')) testing_repo = Repository(name='testing', url='https://dl.bintray.com/pantsbuild/maven', push_db_basedir=os.path.join('testprojects', 'ivy', 'pushdb')) def org_pantsbuild_publication_metadata(description): return OSSRHPublicationMetadata( description=description, url='http://pantsbuild.github.io/', licenses=[ License( name='Apache License, Version 2.0', url='http://www.apache.org/licenses/LICENSE-2.0'
from pants.backend.jvm.repository import Repository from pants.build_graph.build_file_aliases import BuildFileAliases import os public_repo = Repository(name="public", url="TODO", push_db_basedir=os.path.join("build-support", "ivy", "pushdb")) def build_file_aliases(): return BuildFileAliases(objects={ 'public': public_repo, }, )