Example #1
0
  def __init__(self, name, binary, bundles, basename=None):
    """
    :param string name: The name of this target, which combined with this
      build file defines the target :class:`pants.base.address.Address`.
    :param binary: The :class:`pants.targets.jvm_binary.JvmBinary`,
      or a :class:`pants.targets.pants_target.Pants` pointer to one.
    :param bundles: One or more :class:`pants.targets.jvm_binary.Bundle`'s
      describing "extra files" that should be included with this app
      (e.g.: config files, startup scripts).
    :param string basename: Name of this application, if different from the
      ``name``. Pants uses this in the ``bundle`` goal to name the distribution
      artifact. In most cases this parameter is not necessary.
    """
    super(JvmApp, self).__init__(name, dependencies=[])

    self._binaries = maybe_list(
        util.resolve(binary),
        expected_type=(Pants, JarLibrary, JvmBinary),
        raise_type=partial(TargetDefinitionException, self))

    self._bundles = maybe_list(bundles, expected_type=Bundle,
                               raise_type=partial(TargetDefinitionException, self))

    if name == basename:
      raise TargetDefinitionException(self, 'basename must not equal name.')
    self.basename = basename or name

    self._resolved_binary = None
    self._resolved_bundles = []
Example #2
0
  def __init__(self, org, name, repo, description=None):
    """
    :param string org: Organization of this artifact, or groupId in maven parlance.
    :param string name: Name of the artifact, or artifactId in maven parlance.
    :param repo: :class:`pants.targets.repository.Repository`
      this artifact is published to.
    :param string description: Description of this artifact.
    """
    if not isinstance(org, Compatibility.string):
      raise ValueError("org must be %s but was %s" % (Compatibility.string, org))
    if not isinstance(name, Compatibility.string):
      raise ValueError("name must be %s but was %s" % (Compatibility.string, name))

    if repo is None:
      raise ValueError("repo must be supplied")
    repos = []
    for tgt in maybe_list(resolve(repo), expected_type=(Pants, Repository)):
      repos.extend(tgt.resolve())
    if len(repos) != 1:
      raise ValueError("An artifact must have exactly 1 repo, given: %s" % repos)
    repo = repos[0]

    if description is not None and not isinstance(description, Compatibility.string):
      raise ValueError("description must be None or %s but was %s"
                       % (Compatibility.string, description))

    self.org = org
    self.name = name
    self.rev = None
    self.repo = repo
    self.description = description
Example #3
0
 def _maybe_apply_deps(self):
   if self._processed_dependencies is not None:
     self.update_dependencies(self._processed_dependencies)
     self._processed_dependencies = None
   if self._injected_deps:
     self.update_dependencies(resolve(self._injected_deps))
     self._injected_deps = []
Example #4
0
 def testMixedList(self):
   self.assertEquals(
     resolve([MockPantsTarget("1"), "2", MockPantsTarget("3"), "4", "5"], clazz=MockPantsTarget),
     [MockPantsTarget("1"),
      MockPantsTarget("2"),
      MockPantsTarget("3"),
      MockPantsTarget("4"),
      MockPantsTarget("5")])
Example #5
0
  def __init__(self,
               name,
               sources=None,
               java_sources=None,
               provides=None,
               dependencies=None,
               excludes=None,
               resources=None,
               exclusives=None):
    """
    :param string name: The name of this target, which combined with this
      build file defines the target :class:`pants.base.address.Address`.
    :param sources: A list of filenames representing the source code
      this library is compiled from.
    :type sources: list of strings
    :param java_sources:
      :class:`pants.targets.java_library.JavaLibrary` or list of
      JavaLibrary targets this library has a circular dependency on.
      Prefer using dependencies to express non-circular dependencies.
    :param Artifact provides:
      The :class:`pants.targets.artifact.Artifact`
      to publish that represents this target outside the repo.
    :param dependencies: List of :class:`pants.base.target.Target` instances
      this target depends on.
    :type dependencies: list of targets
    :param excludes: List of :class:`pants.targets.exclude.Exclude` instances
      to filter this target's transitive dependencies against.
    :param resources: An optional list of paths (DEPRECATED) or ``resources``
      targets containing resources that belong on this library's classpath.
    :param exclusives: An optional list of exclusives tags.
    """
    super(ScalaLibrary, self).__init__(
        name,
        sources,
        provides,
        dependencies,
        excludes,
        exclusives=exclusives)

    if (sources is None) and (resources is None):
      raise TargetDefinitionException(self, 'Must specify sources and/or resources.')

    self.resources = resources

    self._java_sources = []
    self._raw_java_sources = util.resolve(java_sources)

    self.add_labels('scala')
    # Defer resolves until done parsing the current BUILD file, certain source_root arrangements
    # might allow java and scala sources to co-mingle and so have targets in the same BUILD.
    self._post_construct(self._link_java_cycles)
Example #6
0
  def __init__(self, name, dependencies, overrides=None, exclusives=None):
    """
    :param string name: The name of this target, which combined with this
      build file defines the target :class:`pants.base.address.Address`.
    :param dependencies: List of :class:`pants.base.target.Target` instances
      this target depends on.
    :param overrides: List of strings, each of which will be recursively resolved to
      any targets that provide artifacts. Those artifacts will override corresponding
      direct/transitive dependencies in the dependencies list.
    :param exclusives: An optional map of exclusives tags. See CheckExclusives for details.
    """
    super(JarLibrary, self).__init__(name, exclusives=exclusives)

    self._pre_override_dependencies = OrderedSet(
        maybe_list(util.resolve(dependencies),
                   expected_type=(ExternalDependency, AnonymousDeps, Target),
                   raise_type=partial(TargetDefinitionException, self)))
    self._dependencies = None
    self._dependency_addresses = None
    self.override_targets = set(map(Pants, overrides or []))
    self.add_labels('jars')
Example #7
0
  def __init__(self, name, dependencies, exclusives=None):
    """
    :param string name: The name of this module target, addressable via pants via the
      portion of the spec following the colon.
    :param dependencies: List of :class:`pants.base.target.Target` instances
      this target depends on.
    :type dependencies: list of targets
    """
    Target.__init__(self, name, exclusives=exclusives)
    self._injected_deps = []
    self._processed_dependencies = resolve(dependencies)

    self.add_labels('internal')
    self.dependency_addresses = OrderedSet()

    self._dependencies = OrderedSet()
    self._internal_dependencies = OrderedSet()
    self._jar_dependencies = OrderedSet()

    if dependencies:
      maybe_list(self._processed_dependencies,
                 expected_type=(ExternalDependency, AnonymousDeps, Target),
                 raise_type=partial(TargetDefinitionException, self))
Example #8
0
 def resources(self, resources):
   self._resources = []
   self._raw_resources = util.resolve(resources)
Example #9
0
 def __init__(self, name, dependencies=None, exclusives=None):
   Target.__init__(self, name, exclusives=exclusives)
   self.dependencies = OrderedSet(resolve(dependencies)) if dependencies else OrderedSet()
Example #10
0
 def inject_dependencies(self):
   self.update_dependencies(resolve(self._injected_deps))
Example #11
0
 def testNonTarget(self):
   self.assertEquals(
     resolve([MockPantsTarget(1), [4, 'asdf'], "qwer",], clazz=MockPantsTarget),
     [MockPantsTarget(1), [4, MockPantsTarget('asdf')], MockPantsTarget('qwer')])
Example #12
0
 def testPantsTarget(self):
   self.assertEquals(resolve(MockPantsTarget("asdf"), clazz=MockPantsTarget).foo, "asdf")
Example #13
0
 def testNone(self):
   self.assertEquals(resolve(None, clazz=MockPantsTarget), None)
Example #14
0
 def testUnicodeString(self):
   self.assertEquals(resolve(u"asdf", clazz=MockPantsTarget).foo, u"asdf")
Example #15
0
 def testString(self):
   self.assertEquals(resolve("asdf", clazz=MockPantsTarget).foo, "asdf")