Merge pull request #68 from bazelbuild/fix_export_trans_runtime_path

fix export deps runtime deps so that hjars are not selected
tree: e62ffa57b2070545a42b72699c0c6aa5229350b1
  1. .bazelci/
  2. docs/
  3. examples/
  4. kotlin/
  5. tests/
  6. third_party/
  7. .bazelproject
  8. .bazelrc
  9. .gitignore
  10. AUTHORS
  11. BUILD
  12. CONTRIBUTING.md
  13. CONTRIBUTORS
  14. LICENSE
  15. Makefile
  16. README.md
  17. WORKSPACE
README.md

Build status

Skydoc documentation

Announcements

  • February 15, 2018.. Toolchains for the JVM rules. Currently this allow tweaking:
    • The JVM target (bytecode level).
    • API and Language levels.
    • Coroutines, enabled by default.
  • February 9, 2018. Annotation processing.
  • February 5, 2018. JVM rule name change: the prefix has changed from kotlin_ to kt_jvm_.

Overview

These rules were initially forked from pubref/rules_kotlin. Key changes:

  • Replace the macros with three basic rules. kotlin_binary, kotlin_library and kotlin_test.
  • Use a single dep attribute instead of java_dep and dep.
  • Add support for the following standard java rules attributes:
    • data
    • resource_jars
    • runtime_deps
    • resources
    • resources_strip_prefix
    • exports
  • Persistent worker support.
  • Mixed-Mode compilation (compile Java and Kotlin in one pass).

Usage

WORKSPACE

In the project's WORKSPACE, declare the external repository and initialize the toolchains, like this:

kotlin_release_version="1.2.30"
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(kotlin_release_version=kotlin_release_version)
kt_register_toolchains()

If you omit kotlin_release_version and just call kotlin_repositories() with no arguments, you'll get the current kotlin compiler version (at least as known to the rules_kotlin project).

BUILD files

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",
    ],
)

License

This project is licensed under the Apache 2.0 license, as are all contributions

Contributing

See the CONTRIBUTING doc for information about how to contribute to this project.