Skip to content

Commit

Permalink
Add forwarding references for js, jvm, ktlint. (#557)
Browse files Browse the repository at this point in the history
* Add forwarding references for js, jvm, ktlint.

Revert loading android rules until they can be loaded via sub repo
Issue: #556

Signed-off-by: [email protected] <[email protected]>

* Move options to compile.bzl
Remove references to rules.bzl
Issue: #556

Signed-off-by: [email protected] <[email protected]>

* Split up all the functional modules: jvm, js, android, core, repositories

Fix the starlark. Stardoc needs the ability to be told that, no, a bzl_library won't exist here. Now, get parsing. Most rules do not expose bzl_libraries making docgen a pain.

Issue: #556
Signed-off-by: [email protected] <[email protected]>

* Deprecation announcement is now spammy.

Unfortunately, there is no clean builddozer call to split up load statement.
Issue: #556

Signed-off-by: [email protected] <[email protected]>

* Fix workspace references.

Issue: #556
Signed-off-by: [email protected] <[email protected]>

* Fix more references.
Centralize the android build tools version.
Issue: #556

Signed-off-by: [email protected] <[email protected]>

* Lint, lint, lint.
Issue: #556

Signed-off-by: [email protected] <[email protected]>

* finding the right version...

* finding the right version...

* finding the right version...

* finding the right version...

* matched build tools version

* Use the release reporistories. Whoops.

Signed-off-by: [email protected] <[email protected]>

* Renamed release.repositories to release.doc reflecting the usage.

Signed-off-by: [email protected] <[email protected]>
  • Loading branch information
restingbull authored Jul 24, 2021
1 parent 55867f8 commit 7b7ac2d
Show file tree
Hide file tree
Showing 65 changed files with 752 additions and 424 deletions.
4 changes: 2 additions & 2 deletions CompileAvoidance.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This feature can be enabled through the `experimental_use_abi_jars` flag in the
follows

```python
load("//kotlin:kotlin.bzl", "define_kt_toolchain")
load("//kotlin:core.bzl", "define_kt_toolchain")


define_kt_toolchain(
Expand All @@ -31,7 +31,7 @@ If you encounter such bugs, ABI generation can be disabled on a per target basis
following tag

```python
load("//kotlin:kotlin.bzl", "kt_jvm_library")
load("//kotlin:jvm.bzl", "kt_jvm_library")

kt_jvm_library(
name = "framework",
Expand Down
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ http_archive(
sha256 = rules_kotlin_sha,
)

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below

load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below
```

Expand All @@ -109,17 +111,19 @@ http_archive(
sha256 = rules_kotlin_sha,
)

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below
kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
kotlin_repositories()

load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
```

## `BUILD` files

In your project's `BUILD` files, load the Kotlin rules and use them like so:

```python
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

kt_jvm_library(
name = "package_name",
Expand All @@ -136,7 +140,7 @@ To enable a custom toolchain (to configure language level, etc.)
do the following. In a `<workspace>/BUILD.bazel` file define the following:

```python
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain")
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "define_kt_toolchain")

define_kt_toolchain(
name = "kotlin_toolchain",
Expand All @@ -158,7 +162,7 @@ To choose a different `kotlinc` distribution (1.3 and 1.4 variants supported), d
in your `WORKSPACE` file (or import from a `.bzl` file:

```python
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories")
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")

KOTLIN_VERSION = "1.3.31"
KOTLINC_RELEASE_SHA = "107325d56315af4f59ff28db6837d03c2660088e3efeb7d4e41f3e01bb848d6a"
Expand Down Expand Up @@ -192,9 +196,12 @@ local_repository(

load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
kt_download_local_dev_dependencies()
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below
kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below

load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
kotlin_repositories()

load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
```

# Kotlin and Java compiler flags
Expand All @@ -205,7 +212,7 @@ Note: Not all compiler flags are supported in all language versions. When this h

For example you can define global compiler flags by doing:
```python
load("//kotlin:kotlin.bzl", "kt_kotlinc_options", "kt_javac_options", "define_kt_toolchain")
load("//kotlin:core.bzl", "kt_kotlinc_options", "kt_javac_options", "define_kt_toolchain")

kt_kotlinc_options(
name = "kt_kotlinc_options",
Expand All @@ -231,7 +238,8 @@ Compiler flags that are passed to the rule definitions will be taken over the to

Example:
```python
load("//kotlin:kotlin.bzl", "kt_kotlinc_options", "kt_javac_options", "kt_jvm_library")
load("//kotlin:core.bzl", "kt_kotlinc_options", "kt_javac_options", "kt_jvm_library")
load("//kotlin:jvm.bzl","kt_javac_options", "kt_jvm_library")

kt_kotlinc_options(
name = "kt_kotlinc_options_for_package_name",
Expand Down Expand Up @@ -259,7 +267,8 @@ The `kt_compiler_plugin` rule allows running Kotlin compiler plugins, such as no

For example, you can add allopen to your project like this:
```python
load("//kotlin:kotlin.bzl", "kt_compiler_plugin", "kt_jvm_library")
load("//kotlin:core.bzl", "kt_compiler_plugin")
load("//kotlin:jvm.bzl", "kt_jvm_library")

kt_compiler_plugin(
name = "open_for_testing_plugin",
Expand Down
7 changes: 5 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")

kt_download_local_dev_dependencies()

load("//kotlin:kotlin.bzl", "kotlin_repositories")
load("//kotlin:repositories.bzl", "kotlin_repositories", "versions")

kotlin_repositories()

Expand All @@ -37,6 +37,9 @@ load(
"android_sdk_repository",
)

android_sdk_repository(name = "androidsdk")
android_sdk_repository(
name = "androidsdk",
build_tools_version = versions.ANDROID.BUILD_TOOLS,
)

android_ndk_repository(name = "androidndk")
Loading

0 comments on commit 7b7ac2d

Please sign in to comment.