|author||Romuald Cari <email@example.com>||Mon Mar 11 14:02:42 2019 -0400|
|committer||str <firstname.lastname@example.org>||Mon Mar 11 11:02:42 2019 -0700|
Fix mixed UTF-8 Java and Kotlin builds (#178) When building .java files using the native Java rules, the environment variable LC_LANG=en_US.UTF-8 is explicitely set for the actual build action, see: https://git.io/fhhc7 When building a mixed Kotlin + Java module on Linux, the .java sources are not handled by the native Java rules, and as a result are treated as encoded using US-ASCII due to sandboxing which strips the environment from all locale information, causing the compiler to default to the 'C' locale. This patch adds this environment variable when building Kotlin + Java modules and has no side effects on Kotlin-only modules as UTF-8 is the only valid encoding for .kt source files.
>=0.14. JDK9 host issues were fixed as well some other deprecations. I recommend skipping
0.15.0if you are on a Mac.
kt_jvm_testwhich allows the test to access internal members of the module under test.
These rules were initially forked from pubref/rules_kotlin. Key changes:
This section just contains a quick overview. Consult the generated documentation. Note: Skydoc documentation is no longer being generated. Comprehensive documentation will have to wait till the new documentation generation tool is ready. A contribution to port the documentation to the RST format like
rules_go has would be very welcome !
In the project's
WORKSPACE, declare the external repository and initialize the toolchains, like this:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") rules_kotlin_version = "67f4a6050584730ebae7f8a40435a209f8e0b48e" http_archive( name = "io_bazel_rules_kotlin", urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % rules_kotlin_version], type = "zip", strip_prefix = "rules_kotlin-%s" % rules_kotlin_version ) load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") kotlin_repositories() kt_register_toolchains()
In your project's
BUILD files, load the kotlin rules and use them like so:
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library") kt_jvm_library( name = "package_name", srcs = glob(["*.kt"]), deps = [ "//path/to/dependency", ], )
This project is licensed under the Apache 2.0 license, as are all contributions
See the CONTRIBUTING doc for information about how to contribute to this project.