示例#1
0
 def __init__(self,
              package_name=None,
              address=None,
              payload=None,
              **kwargs):
     """
 :param string package_name: The remote module package name, if not supplied the target name is
                             used.
 """
     payload = payload or Payload()
     payload.add_fields({
         'package_name':
         PrimitiveField(package_name or address.target_name),
     })
     super(NpmPackage, self).__init__(address=address,
                                      payload=payload,
                                      **kwargs)
示例#2
0
    def __init__(self, payload=None, requirements=None, **kwargs):
        """
    :param requirements: pip requirements as `python_requirement <#python_requirement>`_\s.
    :type requirements: List of python_requirement calls
    """
        payload = payload or Payload()

        assert_list(requirements,
                    expected_type=PythonRequirement,
                    key_arg='requirements')
        payload.add_fields({
            'requirements':
            PythonRequirementsField(requirements or []),
        })
        super(PythonRequirementLibrary, self).__init__(payload=payload,
                                                       **kwargs)
        self.add_labels('python')
示例#3
0
  def __init__(self,
               payload=None,
               xjc_args=None,
               extra_args=None,
               **kwargs):
    """Generates a Java library from WSDL files using JAX-WS.

    :param list xjc_args: Additional arguments to xjc.
    :param list extra_args: Additional arguments for the CLI.
    """
    payload = payload or Payload()
    payload.add_fields({
      'xjc_args': PrimitiveField(self.assert_list(xjc_args, key_arg='xjc_args')),
      'extra_args': PrimitiveField(self.assert_list(extra_args, key_arg='extra_args')),
    })
    super(JaxWsLibrary, self).__init__(payload=payload, **kwargs)
    self.add_labels('codegen')
示例#4
0
 def __init__(self, address=None, payload=None, sources=None, **kwargs):
     """
 :param sources: Files to "include". Paths are relative to the
   BUILD file's directory.
 :type sources: ``Fileset`` or list of strings
 """
     payload = payload or Payload()
     payload.add_fields({
         'sources':
         self.create_sources_field(sources=self.assert_list(
             sources, key_arg='sources'),
                                   sources_rel_path=address.spec_path,
                                   key_arg='sources'),
     })
     super(Resources, self).__init__(address=address,
                                     payload=payload,
                                     **kwargs)
示例#5
0
 def __init__(self, payload=None, jars=None, managed_dependencies=None, **kwargs):
   """
   :param jars: List of `jar <#jar>`_\\s to depend upon.
   :param managed_dependencies: Address of a managed_jar_dependencies() target to use. If omitted, uses
     the default managed_jar_dependencies() target set by --jar-dependency-management-default-target.
   """
   jars = self.assert_list(jars, expected_type=JarDependency, key_arg='jars')
   payload = payload or Payload()
   payload.add_fields({
     'jars': JarsField(jars),
     'excludes': ExcludesField([]),
     'managed_dependencies': PrimitiveField(managed_dependencies),
   })
   super(JarLibrary, self).__init__(payload=payload, **kwargs)
   # NB: Waiting to validate until superclasses are initialized.
   if not jars:
     raise TargetDefinitionException(self, 'Must have a non-empty list of jars.')
示例#6
0
    def test_target_list_field(self):
        specs = [':t1', ':t2', ':t3']
        payloads = [Payload() for i in range(3)]
        for i, (s, p) in enumerate(zip(specs, payloads)):
            p.add_field('foo', PrimitiveField(i))
            self.make_target(s, payload=p)

        s1, s2, s3 = specs

        context = self.context()

        fp1 = TargetListField([s1, s2]).fingerprint_with_context(context)
        fp2 = TargetListField([s2, s1]).fingerprint_with_context(context)
        fp3 = TargetListField([s1, s3]).fingerprint_with_context(context)

        self.assertEquals(fp1, fp2)
        self.assertNotEquals(fp1, fp3)
示例#7
0
    def __init__(self, address=None, payload=None, sources=None, **kwargs):
        """
    :param sources: thrift source files
    :type sources: :class:`pants.source.wrapped_globs.FilesetWithSpec` or list of strings. Paths
                   are relative to the BUILD file's directory.
    :param import_path: Deprecated: unused.
    """
        payload = payload or Payload()
        payload.add_field(
            'sources',
            self.create_sources_field(sources,
                                      address.spec_path,
                                      key_arg='sources'))

        super(GoThriftLibrary, self).__init__(payload=payload,
                                              address=address,
                                              **kwargs)
示例#8
0
 def payload_for_scope(self, scope):
   """Returns a payload representing the options for the given scope."""
   payload = Payload()
   for (name, _, kwargs) in self.registration_args_iter_for_scope(scope):
     if not kwargs.get('fingerprint', False):
       continue
     val = self.for_scope(scope)[name]
     val_type = kwargs.get('type', '')
     if val_type == Options.file:
       field = FileField(val)
     elif val_type == Options.target_list:
       field = TargetListField(val)
     else:
       field = PrimitiveField(val)
     payload.add_field(name, field)
   payload.freeze()
   return payload
示例#9
0
    def __init__(self,
                 payload=None,
                 service_writer=None,
                 service_writer_options=None,
                 roots=None,
                 registry_class=None,
                 enum_options=None,
                 no_options=None,
                 **kwargs):
        """
    :param string service_writer: the name of the class to pass as the --service_writer option to
    the Wire compiler (For wire 1.0 only)
    :param list service_writer_options: A list of options to pass to the service writer (For
    wire 1.x only)
    :param list roots: passed through to the --roots option of the Wire compiler
    :param string registry_class: fully qualified class name of RegistryClass to create. If in
    doubt, specify com.squareup.wire.SimpleServiceWriter
    :param list enum_options: list of enums to pass to as the --enum-enum_options option, # optional
    :param boolean no_options: boolean that determines if --no_options flag is passed
    """

        if not service_writer and service_writer_options:
            raise TargetDefinitionException(
                self, 'service_writer_options requires setting service_writer')

        payload = payload or Payload()
        payload.add_fields({
            'service_writer':
            PrimitiveField(service_writer or None),
            'service_writer_options':
            PrimitiveField(
                assert_list(service_writer_options,
                            key_arg='service_writer_options',
                            raise_type=TargetDefinitionException)),
            'roots':
            PrimitiveField(roots or []),
            'registry_class':
            PrimitiveField(registry_class or None),
            'enum_options':
            PrimitiveField(enum_options or []),
            'no_options':
            PrimitiveField(no_options or False),
        })

        super(JavaWireLibrary, self).__init__(payload=payload, **kwargs)
        self.add_labels('codegen')
示例#10
0
 def __init__(self, payload=None, buildflags=None, imports=None, **kwargs):
     """
 :param buildflags: Unused, and will be removed in a future release.
 :param list imports: List of addresses of `jar_library <#jar_library>`_
   targets which contain .proto definitions.
 """
     payload = payload or Payload()
     # TODO(Eric Ayers): The target needs to incorporate the settings of --gen-protoc-version
     # and --gen-protoc-plugins into the fingerprint.  Consider adding a custom FingeprintStrategy
     # into ProtobufGen to get it.
     payload.add_fields({'import_specs': PrimitiveField(imports or ())})
     super(JavaProtobufLibrary, self).__init__(payload=payload, **kwargs)
     if buildflags is not None:
         logger.warn(
             "Target definition at {address} sets attribute 'buildflags' which is "
             "ignored and will be removed in a future release".format(
                 address=self.address.spec))
示例#11
0
  def __init__(self,
               config_file="application.conf",
               config_entry="",
               schema="",
               excluded_tables=[],
               driver_class="com.github.tminglei.slickpg.ExPostgresDriver",
               payload=None, **kwargs):
    payload = payload or Payload()
    payload.add_fields({
      "config_entry": PrimitiveField(config_entry),
      "schema": PrimitiveField(schema),
      "config_file": PrimitiveField(config_file),
      "driver_class": PrimitiveField(driver_class),
      "excluded_tables": PrimitiveField(excluded_tables),
    })

    super(SlickGenTarget, self).__init__(payload=payload, **kwargs)
    def __init__(self, payload=None, packages=None, **kwargs):
        """
        :param list packages: the `ConanRequirement`s to resolve into a `packaged_native_library()` target.
        """
        payload = payload or Payload()

        assert_list(
            packages,
            key_arg="packages",
            expected_type=ConanRequirement,
            raise_type=self._DeprecatedStringPackage,
        )

        payload.add_fields({
            "packages": ConanRequirementSetField(packages),
        })
        super().__init__(payload=payload, **kwargs)
示例#13
0
    def __init__(self,
                 address=None,
                 payload=None,
                 sources=None,
                 compatibility=None,
                 **kwargs):
        """
    :param address: The Address that maps to this Target in the BuildGraph.
    :type address: :class:`pants.build_graph.address.Address`
    :param payload: The configuration encapsulated by this target.  Also in charge of most
                    fingerprinting details.
    :type payload: :class:`pants.base.payload.Payload`
    :param sources: Files to "include". Paths are relative to the
      BUILD file's directory.
    :type sources: ``Fileset`` or list of strings. Must include setup.py.
    :param compatibility: either a string or list of strings that represents
      interpreter compatibility for this target, using the Requirement-style
      format, e.g. ``'CPython>=3', or just ['>=2.7','<3']`` for requirements
      agnostic to interpreter class.
    """
        payload = payload or Payload()
        payload.add_fields({
            'sources':
            self.create_sources_field(sources,
                                      address.spec_path,
                                      key_arg='sources'),
            'compatibility':
            PrimitiveField(maybe_list(compatibility or ()))
        })
        super(PythonDistribution, self).__init__(address=address,
                                                 payload=payload,
                                                 **kwargs)

        if not 'setup.py' in sources:
            raise TargetDefinitionException(
                self,
                'A setup.py in the top-level directory relative to the target definition is required.'
            )

        # Check that the compatibility requirements are well-formed.
        for req in self.payload.compatibility:
            try:
                PythonIdentity.parse_requirement(req)
            except ValueError as e:
                raise TargetDefinitionException(self, str(e))
示例#14
0
    def __init__(self,
                 address=None,
                 payload=None,
                 sources_target=None,
                 dest=None,
                 args=None,
                 **kwargs):
        """
    :API: public

    :param string sources_target: The address of the (typically unpacked_jars) target to get sources
      from.
    :param dest: The target type of the synthetic target to generate (eg, java_library).
    :param dict args: Any additional arguments necessary to construct the synthetic destination
      target (sources and dependencies are supplied automatically).
    """
        self.address = address
        if not sources_target:
            raise TargetDefinitionException(
                self, 'You must specify the address of a target to acquire '
                'sources from via the "sources_target" parameter.')
        if not dest or not hasattr(dest, 'target_types'):
            raise TargetDefinitionException(
                self, 'You must specify a target type for the "dest" '
                'parameter.')
        if len(dest.target_types) != 1:
            raise TargetDefinitionException(
                self,
                'Target alias {} has multiple possible target types {}.'.
                format(dest, dest.target_types),
            )
        dest = dest.target_types[0]
        self._dest = dest
        self._dest_args = args
        payload = payload or Payload()
        payload.add_fields({
            'sources_target_spec':
            PrimitiveField(
                self._sources_target_to_spec(address, sources_target)),
            'dest':
            PrimitiveField(dest.__name__),
        })
        super(RemoteSources, self).__init__(address=address,
                                            payload=payload,
                                            **kwargs)
示例#15
0
    def __init__(self,
                 name=None,
                 filename=None,
                 version=None,
                 platform=None,
                 arch=None,
                 namespace=None,
                 extract=None,
                 payload=None,
                 **kwargs):
        """
    Represent a remote source to be fetched as part of the RpmBuild process.

    :param string name: Basename of the source package or file, as well as the target name.
      e.g. 'node.tar.gz' or 'thrift'.
    :param string version: version of the source distribution.
    :param string platform: Intended platform. Currently defaults to linux
    :param string arch: Intended architecture of the package. Currently defaults to 'x86_64'.
    :param string filename: Name of the file intended for fetching. Defaults to the target name.
    :param string namespace: Directory name that holds these sources. Defaults to using the split filename,
      e.g. 'node' for 'node.tar.gz' or 'thrift' for 'thrift'. This argument is mostly for tricky edge cases.
    :param bool extract: When True, remote source will be extracted. Supports
      archive types understood by `pants.fs.archive.archiver_for_path(filename)`.
    """

        # TODO(mateo): Support platform-independent bundles, which is what most source distributions will be.
        # TODO(mateo): Add a 'release' param. For now, I have been rolling it into the version field or hardcoding it.
        self.version = version
        self.platform = platform or 'linux'
        self.arch = arch or 'x86_64'
        self.filename = filename or name
        self.namespace = namespace or self.filename.split('.')[0]
        self.extract = extract
        payload = payload or Payload()
        payload.add_fields({
            'version': PrimitiveField(self.version),
            'platform': PrimitiveField(self.platform),
            'arch': PrimitiveField(self.arch),
            'filename': PrimitiveField(self.filename),
            'namespace': PrimitiveField(self.namespace),
            'extract': PrimitiveField(self.extract),
        })
        super(RemoteSource, self).__init__(name=name,
                                           payload=payload,
                                           **kwargs)
示例#16
0
文件: doc.py 项目: jtrobec/pants
    def __init__(self,
                 address=None,
                 payload=None,
                 source=None,
                 format=None,
                 links=None,
                 resources=None,
                 provides=None,
                 **kwargs):
        """
    :param source: Path to page source file.
    :param format: Page's format, ``md`` or ``rst``. By default, Pants infers from ``source`` file
       extension: ``.rst`` is ReStructured Text; anything else is Markdown.
    :param links: Other ``page`` targets that this `page` links to.
    :type links: List of target specs
    :param provides: Optional "Addresses" at which this page is published.
       E.g., a wiki location.
    :type provides: List of ``wiki_artifact``s
    :param resources: An optional list of Resources objects.
    """
        payload = payload or Payload()
        if not format:
            if source and source.lower().endswith('.rst'):
                format = 'rst'
            else:
                format = 'md'
        payload.add_fields({
            'sources':
            self.create_sources_field(sources=[source],
                                      sources_rel_path=address.spec_path,
                                      key_arg='sources'),
            'format':
            PrimitiveField(format),
            'links':
            PrimitiveField(links or []),
            'provides':
            self.ProvidesTupleField(provides or []),
        })
        self._resource_specs = resources or []
        super(Page, self).__init__(address=address, payload=payload, **kwargs)

        if provides and not isinstance(provides[0], WikiArtifact):
            raise ValueError(
                'Page must provide a wiki_artifact. Found instead: {}'.format(
                    provides))
示例#17
0
 def __init__(self,
              address=None,
              payload=None,
              image_name=None,
              image_tag=None,
              **kwargs):
     payload = payload or Payload()
     payload.add_fields({
         'image_name':
         PrimitiveField(image_name),
         'image_tag':
         PrimitiveField('c' + get_scm().commit_id)
     })
     self.image_name = image_name
     self.image_tag = image_tag
     super(DockerTargetBase, self).__init__(address=address,
                                            payload=payload,
                                            **kwargs)
示例#18
0
 def __init__(self, entries=None):
   """
   :param entries: Additional headers, value pairs to add to the MANIFEST.MF.
     You can just add fixed string header / value pairs.
   :type entries: dictionary of string : string
   """
   self.payload = Payload()
   if entries:
     if not isinstance(entries, dict):
       raise self.ExpectedDictionaryError("entries must be a dictionary of strings.")
     for key in entries.keys():
       if not isinstance(key, str):
         raise self.ExpectedDictionaryError(
           "entries must be dictionary of strings, got key {} type {}"
           .format(key, type(key).__name__))
   self.payload.add_fields({
     'entries': PrimitiveField(entries or {}),
     })
示例#19
0
 def __init__(self, java_sources=None, payload=None, **kwargs):
   """
   :param java_sources: Java libraries this library has a *circular*
     dependency on.
     If you don't have the particular problem of circular dependencies
     forced by splitting interdependent java and scala into multiple targets,
     don't use this at all.
     Prefer using ``dependencies`` to express non-circular dependencies.
   :type java_sources: target spec or list of target specs
   :param resources: An optional list of paths (DEPRECATED) or ``resources``
     targets containing resources that belong on this library's classpath.
   """
   payload = payload or Payload()
   payload.add_fields({
     'java_sources': PrimitiveField(self.assert_list(java_sources, key_arg='java_sources')),
   })
   super(ScalaLibrary, self).__init__(payload=payload, **kwargs)
   self.add_labels('scala')
示例#20
0
 def __init__(self,
              dependencies_archive_url=None,
              sources=None,
              address=None,
              payload=None,
              **kwargs):
     """
     :param string url: The location of a tar.gz file containing containing a node_modules directory.
     """
     payload = payload or Payload()
     payload.add_fields({
         "dependencies_archive_url":
         PrimitiveField(dependencies_archive_url),
     })
     super().__init__(sources=sources,
                      address=address,
                      payload=payload,
                      **kwargs)
示例#21
0
  def __init__(self, prep_executable=None, prep_args=None, payload=None, prep_environ=False, **kwargs):
    """
    :API: public

    :param prep_executable: The path to the executable that should be run.
    :param prep_args: A list of command-line args to the excutable.
    :param prep_environ: If True, the output of the command will be treated as
      a \\\\0-separated list of key=value pairs to insert into the environment.
      Note that this will pollute the environment for all future tests, so
      avoid it if at all possible.
    """
    payload = payload or Payload()
    payload.add_fields({
      'prep_command_executable': PrimitiveField(prep_executable),
      'prep_command_args': PrimitiveField(prep_args or []),
      'prep_environ': PrimitiveField(prep_environ),
    })
    super(PrepCommand, self).__init__(payload=payload, **kwargs)
示例#22
0
 def __init__(self, payload=None, jars=None, **kwargs):
     """
 :param jars: List of `jar <#jar>`_\s to depend upon.
 """
     jars = self.assert_list(jars,
                             expected_type=JarDependency,
                             key_arg='jars')
     payload = payload or Payload()
     payload.add_fields({
         'jars': JarsField(jars),
         'excludes': ExcludesField([]),
     })
     super(JarLibrary, self).__init__(payload=payload, **kwargs)
     # NB: Waiting to validate until superclasses are initialized.
     if not jars:
         raise TargetDefinitionException(
             self, 'Must have a non-empty list of jars.')
     self.add_labels('jars', 'jvm')
示例#23
0
 def __init__(self, payload=None, buildflags=None, imports=None, **kwargs):
     """
 :param buildflags: Unused, and will be removed in a future release.
 :param imports: List of addresses of `jar_library <#jar_library>`_
   targets which contain .proto definitions.
 """
     payload = payload or Payload()
     payload.add_fields({'raw_imports': PrimitiveField(imports or ())})
     super(JavaProtobufLibrary, self).__init__(payload=payload, **kwargs)
     if buildflags is not None:
         logger.warn(
             " Target definition at {address} sets attribute 'buildflags' which is "
             "ignored and will be removed in a future release".format(
                 address=self.address.spec))
     self.add_labels('codegen')
     if imports:
         self.add_labels('has_imports')
     self._imports = None
示例#24
0
 def test_missing_payload_field(self):
   payload = Payload()
   payload.add_field('foo', PrimitiveField('test-value'))
   payload.add_field('bar', PrimitiveField(None))
   self.assertEquals('test-value', payload.foo);
   self.assertEquals('test-value', payload.get_field('foo').value)
   self.assertEquals('test-value', payload.get_field_value('foo'))
   self.assertEquals(None, payload.bar);
   self.assertEquals(None, payload.get_field('bar').value)
   self.assertEquals(None, payload.get_field_value('bar'))
   self.assertEquals(None, payload.get_field('bar', default='nothing').value)
   self.assertEquals(None, payload.get_field_value('bar', default='nothing'))
   with self.assertRaises(KeyError):
     self.assertEquals(None, payload.field_doesnt_exist)
   self.assertEquals(None, payload.get_field('field_doesnt_exist'))
   self.assertEquals(None, payload.get_field_value('field_doesnt_exist'))
   self.assertEquals('nothing', payload.get_field('field_doesnt_exist', default='nothing'))
   self.assertEquals('nothing', payload.get_field_value('field_doesnt_exist', default='nothing'))
示例#25
0
 def __init__(self,
              script_name=None,
              timeout=None,
              address=None,
              payload=None,
              **kwargs):
     """
 :param string script_name: The tests script name in package.json. Defaults to "test".
 :param int timeout: The test target timeout.
 """
     payload = payload or Payload()
     payload.add_fields({
         'script_name': PrimitiveField(script_name or 'test'),
         'timeout': PrimitiveField(timeout)
     })
     super(NodeTest, self).__init__(address=address,
                                    payload=payload,
                                    **kwargs)
示例#26
0
    def __init__(self,
                 name,
                 address,
                 build_graph,
                 payload=None,
                 tags=None,
                 description=None,
                 **kwargs):
        """
    :param string name: The name of this target, which combined with this
      build file defines the target address.
    :param dependencies: Other targets that this target depends on.
    :type dependencies: list of target specs
    :param Address address: The Address that maps to this Target in the BuildGraph
    :param BuildGraph build_graph: The BuildGraph that this Target lives within
    :param Payload payload: The configuration encapsulated by this target.  Also in charge of
      most fingerprinting details.
    :param iterable<string> tags: Arbitrary string tags that describe this target. Usable
        by downstream/custom tasks for reasoning about build graph. NOT included in payloads
        and thus not used in fingerprinting, thus not suitable for anything that affects how
        a particular target is built.
    :param string description: Human-readable description of this target.
    """
        # dependencies is listed above; implementation hides in TargetAddressable
        self.payload = payload or Payload()
        self.payload.freeze()
        self.name = name
        self.address = address
        self._tags = set(tags or [])
        self._build_graph = build_graph
        self.description = description
        self.labels = set()

        self._cached_fingerprint_map = {}
        self._cached_transitive_fingerprint_map = {}

        if kwargs:
            error_message = '{target_type} received unknown arguments: {args}'
            raise self.UnknownArguments(
                address.spec,
                error_message.format(target_type=type(self).__name__,
                                     args=''.join(
                                         '\n  {} = {}'.format(key, value)
                                         for key, value in kwargs.items())))
示例#27
0
    def __init__(self,
                 cwd=None,
                 test_platform=None,
                 payload=None,
                 timeout=None,
                 extra_jvm_options=None,
                 extra_env_vars=None,
                 **kwargs):
        """
    :param str cwd: working directory (relative to the build root) for the tests under this
      target. If unspecified (None), the working directory will be controlled by junit_run's --cwd.
    :param str test_platform: The name of the platform (defined under the jvm-platform subsystem) to
      use for running tests (that is, a key into the --jvm-platform-platforms dictionary). If
      unspecified, the platform will default to the same one used for compilation.
    :param int timeout: A timeout (in seconds) which covers the total runtime of all tests in this
      target. Only applied if `--test-junit-timeouts` is set to True.
    :param list extra_jvm_options: A list of key value pairs of jvm options to use when running the
      tests. Example: ['-Dexample.property=1'] If unspecified, no extra jvm options will be added.
    :param dict extra_env_vars: A map of environment variables to set when running the tests, e.g.
      { 'FOOBAR': 12 }. Using `None` as the value will cause the variable to be unset.
    """
        self.cwd = cwd
        payload = payload or Payload()

        if extra_env_vars is None:
            extra_env_vars = {}
        for key, value in extra_env_vars.items():
            if value is not None:
                extra_env_vars[key] = str(value)

        payload.add_fields({
            'test_platform':
            PrimitiveField(test_platform),
            'extra_jvm_options':
            PrimitiveField(tuple(extra_jvm_options or ())),
            'extra_env_vars':
            PrimitiveField(tuple(extra_env_vars.items())),
        })
        self._timeout = timeout
        super(JavaTests, self).__init__(payload=payload, **kwargs)

        # TODO(John Sirois): These could be scala, clojure, etc.  'jvm' and 'tests' are the only truly
        # applicable labels - fixup the 'java' misnomer.
        self.add_labels('java', 'tests')
示例#28
0
    def __init__(self,
                 address=None,
                 payload=None,
                 sources_rel_path=None,
                 sources=None,
                 provides=None,
                 excludes=None,
                 resources=None,
                 configurations=None,
                 no_cache=False,
                 **kwargs):
        """
    :param configurations: One or more ivy configurations to resolve for this target.
      This parameter is not intended for general use.
    :type configurations: tuple of strings
    :param excludes: List of `exclude <#exclude>`_\s to filter this target's
      transitive dependencies against.
    :param sources: Source code files to build. Paths are relative to the BUILD
       file's directory.
    :type sources: ``Fileset`` (from globs or rglobs) or list of strings
    :param no_cache: If True, this should not be stored in the artifact cache
    """
        if sources_rel_path is None:
            sources_rel_path = address.spec_path
        payload = payload or Payload()
        payload.add_fields({
            'sources':
            SourcesField(sources=self.assert_list(sources),
                         sources_rel_path=sources_rel_path),
            'provides':
            provides,
            'excludes':
            ExcludesField(self.assert_list(excludes, expected_type=Exclude)),
            'configurations':
            ConfigurationsField(self.assert_list(configurations)),
        })
        self._resource_specs = self.assert_list(resources)

        super(JvmTarget, self).__init__(address=address,
                                        payload=payload,
                                        **kwargs)
        self.add_labels('jvm')
        if no_cache:
            self.add_labels('no_cache')
示例#29
0
    def __init__(self,
                 name=None,
                 payload=None,
                 binary=None,
                 bundles=None,
                 basename=None,
                 deployjar=None,
                 archive=None,
                 **kwargs):
        """
    :param string binary: Target spec of the ``jvm_binary`` that contains the
      app main.
    :param bundles: One or more ``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``. Optionally pants uses this in the ``bundle`` goal to name the distribution
      artifact.  Note this is unsafe because of the possible conflict when multiple bundles
      are built.
    :param boolean deployjar: If True, pack all 3rdparty and internal jar classfiles into
      a single deployjar in the bundle's root dir. If unset, all jars will go into the
      bundle's libs directory, the root will only contain a synthetic jar with its manifest's
      Class-Path set to those jars.
    :param string archive: Create an archive of this type from the bundle.
    """
        if archive and archive not in Archive.TYPE_NAMES:
            raise self.InvalidArchiveType(
                'Given archive type "{}" is invalid, choose from {}.'.format(
                    archive, list(Archive.TYPE_NAMES)))

        payload = payload or Payload()
        payload.add_fields({
            'basename': PrimitiveField(basename or name),
            'binary': PrimitiveField(binary),
            'bundles': BundleField(bundles or []),
            'deployjar': PrimitiveField(deployjar),
            'archive': PrimitiveField(archive),
        })
        super(JvmApp, self).__init__(name=name, payload=payload, **kwargs)

        if name == basename:
            raise TargetDefinitionException(self,
                                            'basename must not equal name.')
示例#30
0
  def __init__(self, cwd=None, test_platform=None, payload=None, timeout=None, **kwargs):
    """
    :param str cwd: working directory (relative to the build root) for the tests under this
      target. If unspecified (None), the working directory will be controlled by junit_run's --cwd.
    :param str test_platform: The name of the platform (defined under the jvm-platform subsystem) to
      use for running tests (that is, a key into the --jvm-platform-platforms dictionary). If
      unspecified, the platform will default to the same one used for compilation.
    """
    self.cwd = cwd
    payload = payload or Payload()
    payload.add_fields({
      'test_platform': PrimitiveField(test_platform)
    })
    self._timeout = timeout
    super(JavaTests, self).__init__(payload=payload, **kwargs)

    # TODO(John Sirois): These could be scala, clojure, etc.  'jvm' and 'tests' are the only truly
    # applicable labels - fixup the 'java' misnomer.
    self.add_labels('java', 'tests')