This is liable to change in the future.A
kotlin_library()rule is used to define a set of Kotlin files that can be compiled together. The main output of a
kotlin_library()rule is a single JAR file containing all of the compiled class files and resources.
The name of the rule.
The set of
.ktsfiles to compile for this rule. If any of the files in this list end in
.src.zip, then the entries in the ZIP file that end in
.ktwill be included as ordinary inputs to compilation.
Static files to include among the compiled
.classfiles. These files can be loaded via Class.getResource().
The path that resources are resolved against. For example, if
resourcescontains the file
"res/com/example/foo.txt", that file will end up as
"com/example/foo.txt"in the output JAR. This parameter overrides the
Rules (usually other
kotlin_libraryrules) that are used to generate the classpath required to compile this
List of additional arguments to pass into the Kotlin compiler.
Specifies a list of
Patternsthat are used to exclude
JAR. The pattern matching is based on the name of the class. This can be used to exclude a member class or delete a local view of a class that will be replaced during a later stage of the build.
kotlin_libraryrules that depend on this rule will also include its
exported_depsin their classpaths. This is useful when the public API of a rule has return types or checked exceptions that are defined in another rule, which would otherwise require callers to add an extra dependency. It's also useful for exposing e.g. a collection of
prebuilt_jarrules as a single target for callers to depend on. Targets in
exported_depsare implicitly included in the
depsof this rule, so they don't need to be repeated there.
These represent dependencies that are known to be provided at run time, but are required in order for the code to compile. Examples of
provided_depsinclude the JEE servlet APIs. When this rule is included in a
provided_depswill not be packaged into the output.
This is a combination of
exported_deps. Rules listed in this parameter will be added to classpath of rules that depend on this rule, but they will not be included in a binary if binary depends on a such target.
List of build targets that identify tests that exercise this target.
List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their
exported_depsattributes. For more information, see visibility.
# A rule that compiles a single .kt file. kotlin_library( name = 'JsonUtil', srcs = ['JsonUtil.kt'], deps = [ '//third_party/guava:guava', '//third_party/jackson:jackson', ], ) # A rule that compiles all of the .kt files under the directory in # which the rule is defined using glob(). It also excludes an # individual file that may have additional dependencies, so it is # compiled by a separate rule. kotlin_library( name = 'messenger', srcs = glob(['**/*.kt'], excludes = ['MessengerModule.kt']), deps = [ '//src/com/facebook/base:base', '//third_party/guava:guava', ], ) kotlin_library( name = 'MessengerModule', srcs = ['MessengerModule.kt'], deps = [ '//src/com/facebook/base:base', '//src/com/google/inject:inject', '//third_party/guava:guava', '//third_party/jsr-330:jsr-330', ], ) # A rule that builds a library with both relative and # fully-qualified deps. kotlin_library( name = 'testutil', srcs = glob(['tests/**/*.kt'], excludes = 'tests/**/*Test.kt'), deps = [ ':lib-fb4a', '//java/com/facebook/base:base', ], )