• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Protobuf-specific kotlin build rules."""
2
3load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
4load("//java/osgi:kotlin_osgi.bzl", "osgi_kt_jvm_library")
5
6BUNDLE_DOC_URL = "https://developers.google.com/protocol-buffers/"
7BUNDLE_LICENSE = "https://opensource.org/licenses/BSD-3-Clause"
8
9def protobuf_versioned_kt_jvm_library(
10        automatic_module_name,
11        bundle_description,
12        bundle_name,
13        bundle_symbolic_name,
14        bundle_additional_imports = [],
15        bundle_additional_exports = [],
16        **kwargs):
17    """Extends `kt_jvm_library` to add OSGi headers to the MANIFEST.MF using bndlib
18
19    This macro should be usable as a drop-in replacement for kt_jvm_library.
20
21    The additional arguments are given the bndlib tool to generate an OSGi-compliant manifest file.
22    See [bnd documentation](https://bnd.bndtools.org/chapters/110-introduction.html)
23
24    Takes all the args that are standard for a kt_jvm_library target plus the following.
25    Args:
26        bundle_description: (required) The Bundle-Description header defines a short
27            description of this bundle.
28        automatic_module_name: (required) The Automatic-Module-Name header that represents
29            the name of the module when this bundle is used as an automatic
30            module.
31        bundle_name: (required) The Bundle-Name header defines a readable name for this
32            bundle. This should be a short, human-readable name that can
33            contain spaces.
34        bundle_symbolic_name: (required) The Bundle-SymbolicName header specifies a
35            non-localizable name for this bundle. The bundle symbolic name
36            together with a version must identify a unique bundle though it can
37            be installed multiple times in a framework. The bundle symbolic
38            name should be based on the reverse domain name convention.
39        bundle_additional_exports: The Export-Package header contains a
40            declaration of exported packages. These are additional export
41            package statements to be added before the default wildcard export
42            "*;version={$Bundle-Version}".
43        bundle_additional_imports: The Import-Package header declares the
44            imported packages for this bundle. These are additional import
45            package statements to be added before the default wildcard import
46            "*".
47        **kwargs: Additional key-word arguments that are passed to the internal
48            kt_jvm_library target.
49    """
50    osgi_kt_jvm_library(
51        automatic_module_name = automatic_module_name,
52        bundle_doc_url = BUNDLE_DOC_URL,
53        bundle_license = BUNDLE_LICENSE,
54        bundle_version = PROTOBUF_JAVA_VERSION,
55        bundle_description = bundle_description,
56        bundle_name = bundle_name,
57        bundle_symbolic_name = bundle_symbolic_name,
58        bundle_additional_exports = bundle_additional_exports,
59        bundle_additional_imports = bundle_additional_imports + ["sun.misc;resolution:=optional"],
60        **kwargs
61    )
62