Jakob Buchgraber | e421f76 | 2018-02-23 11:44:10 +0100 | [diff] [blame] | 1 | [](https://buildkite.com/bazel/kotlin-postsubmit) |
| 2 | |
hsyed | a3a79e9 | 2018-01-31 18:32:26 +0000 | [diff] [blame] | 3 | [Skydoc documentation](https://bazelbuild.github.io/rules_kotlin) |
David Stanke | 3208b17 | 2018-01-31 12:45:04 -0500 | [diff] [blame] | 4 | |
hsyed | 14a04d0 | 2018-02-05 18:24:26 +0000 | [diff] [blame] | 5 | # Announcements |
Hassan Syed | 303eefb | 2018-08-14 12:50:36 +0100 | [diff] [blame] | 6 | * <b>August 14, 2018.</b> Js support. No documentation yet but see the nested example workspace `examples/node`. |
Hassan Syed | afcaf55 | 2018-08-14 12:41:05 +0100 | [diff] [blame] | 7 | * <b>August 14, 2018.</b> Android support. No documentation but it's a simple integration. see |
| 8 | `kotlin/internal/jvm/android.bzl`. |
Hassan Syed | 0a60cad | 2018-07-07 18:02:00 +0100 | [diff] [blame] | 9 | * <b>Jun 29, 2018.</b> The commits from this date forward are compatible with bazel `>=0.14`. JDK9 host issues were |
| 10 | fixed as well some other deprecations. I recommend skipping `0.15.0` if you are on a Mac. |
Hassan Syed | 44a90a7 | 2018-05-25 15:55:20 +0100 | [diff] [blame] | 11 | * <b>May 25, 2018.</b> Test "friend" support. A single friend dep can be provided to `kt_jvm_test` which allows the test |
Hassan Syed | 2d517f9 | 2018-05-24 22:40:39 +0100 | [diff] [blame] | 12 | to access internal members of the module under test. |
| 13 | * <b>February 15, 2018.</b> Toolchains for the JVM rules. Currently this allow tweaking: |
hsyed | 36cf44f | 2018-02-15 23:55:14 +0000 | [diff] [blame] | 14 | * The JVM target (bytecode level). |
| 15 | * API and Language levels. |
| 16 | * Coroutines, enabled by default. |
hsyed | 84a9721 | 2018-02-09 12:59:50 +0000 | [diff] [blame] | 17 | * <b>February 9, 2018.</b> Annotation processing. |
hsyed | 14a04d0 | 2018-02-05 18:24:26 +0000 | [diff] [blame] | 18 | * <b>February 5, 2018. JVM rule name change:</b> the prefix has changed from `kotlin_` to `kt_jvm_`. |
| 19 | |
| 20 | # Overview |
David Stanke | 3208b17 | 2018-01-31 12:45:04 -0500 | [diff] [blame] | 21 | |
Christian Edward Gruber | ac84ceb | 2018-03-04 14:06:00 -0800 | [diff] [blame] | 22 | These rules were initially forked from [pubref/rules_kotlin](http://github.com/pubref/rules_kotlin). |
| 23 | Key changes: |
David Stanke | 3208b17 | 2018-01-31 12:45:04 -0500 | [diff] [blame] | 24 | |
Menny Even Danan | 9d7bcb5 | 2018-07-26 12:15:50 -0400 | [diff] [blame] | 25 | * Replace the macros with three basic rules. `kt_jvm_binary`, `kt_jvm_library` and `kt_jvm_test`. |
David Stanke | 3208b17 | 2018-01-31 12:45:04 -0500 | [diff] [blame] | 26 | * Use a single dep attribute instead of `java_dep` and `dep`. |
| 27 | * Add support for the following standard java rules attributes: |
| 28 | * `data` |
| 29 | * `resource_jars` |
| 30 | * `runtime_deps` |
| 31 | * `resources` |
| 32 | * `resources_strip_prefix` |
| 33 | * `exports` |
| 34 | * Persistent worker support. |
Jakob Buchgraber | e421f76 | 2018-02-23 11:44:10 +0100 | [diff] [blame] | 35 | * Mixed-Mode compilation (compile Java and Kotlin in one pass). |
Christian Edward Gruber | ac84ceb | 2018-03-04 14:06:00 -0800 | [diff] [blame] | 36 | |
hsyed | 740b962 | 2018-07-04 17:57:21 +0100 | [diff] [blame] | 37 | # Quick Guide |
hsyed | 9b1dece | 2018-08-10 16:49:15 +0100 | [diff] [blame] | 38 | This section just contains a quick overview. Consult the generated |
| 39 | [documentation](https://bazelbuild.github.io/rules_kotlin). Note: Skydoc documentation is no longer being generated. |
| 40 | Comprehensive documentation will have to wait till the new documentation generation tool is ready. A contribution to |
| 41 | port the documentation to the RST format like `rules_go` has would be very welcome ! |
hsyed | 740b962 | 2018-07-04 17:57:21 +0100 | [diff] [blame] | 42 | |
Christian Edward Gruber | ac84ceb | 2018-03-04 14:06:00 -0800 | [diff] [blame] | 43 | |
| 44 | ## WORKSPACE |
| 45 | In the project's `WORKSPACE`, declare the external repository and initialize the toolchains, like |
| 46 | this: |
| 47 | |
| 48 | ```build |
Xin | eacc5a2 | 2018-10-24 15:37:17 -0400 | [diff] [blame] | 49 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 50 | |
Christian Edward Gruber | 62243b1 | 2018-03-04 15:36:27 -0800 | [diff] [blame] | 51 | rules_kotlin_version = "67f4a6050584730ebae7f8a40435a209f8e0b48e" |
Christian Edward Gruber | ac84ceb | 2018-03-04 14:06:00 -0800 | [diff] [blame] | 52 | |
| 53 | http_archive( |
| 54 | name = "io_bazel_rules_kotlin", |
| 55 | urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % rules_kotlin_version], |
| 56 | type = "zip", |
| 57 | strip_prefix = "rules_kotlin-%s" % rules_kotlin_version |
| 58 | ) |
| 59 | |
| 60 | load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") |
hsyed | fe593c5 | 2018-09-03 21:10:59 +0100 | [diff] [blame] | 61 | kotlin_repositories() |
Christian Edward Gruber | ac84ceb | 2018-03-04 14:06:00 -0800 | [diff] [blame] | 62 | kt_register_toolchains() |
| 63 | ``` |
| 64 | |
Christian Edward Gruber | ac84ceb | 2018-03-04 14:06:00 -0800 | [diff] [blame] | 65 | ## BUILD files |
| 66 | |
| 67 | In your project's `BUILD` files, load the kotlin rules and use them like so: |
| 68 | |
| 69 | ``` |
| 70 | load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library") |
| 71 | |
| 72 | kt_jvm_library( |
| 73 | name = "package_name", |
| 74 | srcs = glob(["*.kt"]), |
| 75 | deps = [ |
| 76 | "//path/to/dependency", |
| 77 | ], |
| 78 | ) |
| 79 | ``` |
| 80 | |
| 81 | # License |
| 82 | |
| 83 | This project is licensed under the [Apache 2.0 license](LICENSE), as are all contributions |
| 84 | |
| 85 | # Contributing |
| 86 | |
| 87 | See the [CONTRIBUTING](CONTRIBUTING.md) doc for information about how to contribute to |
| 88 | this project. |
| 89 | |