Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ Call this in the WORKSPACE file to setup the Kotlin rules.
| <a id="kotlin_repositories-is_bzlmod"></a>is_bzlmod | <p align="center"> - </p> | `False` |
| <a id="kotlin_repositories-compiler_repository_name"></a>compiler_repository_name | for the kotlinc compiler repository. | `"com_github_jetbrains_kotlin"` |
| <a id="kotlin_repositories-ksp_repository_name"></a>ksp_repository_name | <p align="center"> - </p> | `"com_github_google_ksp"` |
| <a id="kotlin_repositories-compiler_release"></a>compiler_release | version provider from versions.bzl. | `struct(sha256 = "b6698d5728ad8f9edcdd01617d638073191d8a03139cc538a391b4e3759ad297", url_templates = ["https://github.com/JetBrains/kotlin/releases/download/v{version}/kotlin-compiler-{version}.zip"], version = "2.1.0")` |
| <a id="kotlin_repositories-ksp_compiler_release"></a>ksp_compiler_release | (internal) version provider from versions.bzl. | `struct(sha256 = "fc27b08cadc061a4a989af01cbeccb613feef1995f4aad68f2be0f886a3ee251", url_templates = ["https://github.com/google/ksp/releases/download/{version}/artifacts.zip"], version = "2.1.0-1.0.28")` |
| <a id="kotlin_repositories-compiler_release"></a>compiler_release | version provider from versions.bzl. | `struct(sha256 = "a118197b0de55ffab2bc8d5cd03a5e39033cfb53383d6931bc761dec0784891a", url_templates = ["https://github.com/JetBrains/kotlin/releases/download/v{version}/kotlin-compiler-{version}.zip"], version = "2.1.20")` |
| <a id="kotlin_repositories-ksp_compiler_release"></a>ksp_compiler_release | (internal) version provider from versions.bzl. | `struct(sha256 = "9f74659d447d3df29cabe0c8ee068810af313a584c1bbdde821f9894127f26e0", url_templates = ["https://github.com/google/ksp/releases/download/{version}/artifacts.zip"], version = "2.1.20-1.0.32")` |


<a id="versions.use_repository"></a>
Expand Down
8 changes: 4 additions & 4 deletions examples/dagger/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "maven_rules_kotlin_example",
artifacts = [
"com.google.dagger:dagger:2.51.1",
"com.google.dagger:dagger-compiler:2.51.1",
"com.google.dagger:dagger-producers:2.51.1",
"com.google.dagger:dagger:2.56.2",
"com.google.dagger:dagger-compiler:2.56.2",
"com.google.dagger:dagger-producers:2.56.2",
"javax.inject:javax.inject:1",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2",
],
repositories = [
"https://repo1.maven.org/maven2",
Expand Down
70 changes: 19 additions & 51 deletions examples/jetpack_compose/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ http_archive(
url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.9.5/rules_kotlin-v1.9.5.tar.gz",
)

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

http_archive(
name = "rules_jvm_external",
Expand All @@ -23,16 +23,10 @@ http_archive(
)

http_archive(
name = "rules_java",
sha256 = versions.RULES_JAVA.sha256,
urls = [url.format(version = versions.RULES_JAVA.version) for url in versions.RULES_JAVA.url_templates],
)

http_archive(
name = "bazel_features",
sha256 = versions.BAZEL_FEATURES.sha256,
strip_prefix = versions.BAZEL_FEATURES.strip_prefix_template.format(version = versions.BAZEL_FEATURES.version),
urls = [url.format(version = versions.BAZEL_FEATURES.version) for url in versions.BAZEL_FEATURES.url_templates],
name = "robolectric",
sha256 = "b2d2164bae80fcfbdd078eb2f0935ba06557402b8c814928d9e3bec7358e2b7b",
strip_prefix = "robolectric-bazel-4.14.1.2",
urls = ["https://github.com/robolectric/robolectric-bazel/releases/download/4.14.1.2/robolectric-bazel-4.14.1.2.tar.gz"],
)

http_archive(
Expand All @@ -41,10 +35,6 @@ http_archive(
urls = [url.format(version = versions.BAZEL_SKYLIB.version) for url in versions.BAZEL_SKYLIB.url_templates],
)

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

# Android rules dependencies
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")

Expand Down Expand Up @@ -90,37 +80,19 @@ register_toolchains(
"@rules_android//toolchains/android_sdk:android_sdk_tools",
)

KOTLINC_RELEASE = versions.KOTLIN_CURRENT_COMPILER_RELEASE

kotlin_repositories(
compiler_release = kotlinc_version(
release = "2.0.0",
sha256 = "ef578730976154fd2c5968d75af8c2703b3de84a78dffe913f670326e149da3b",
) if KOTLINC_RELEASE.version == "1.9.22" else kotlinc_version(
release = KOTLINC_RELEASE.version,
sha256 = KOTLINC_RELEASE.sha256,
),
)
kotlin_repositories()

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

kt_register_toolchains()

register_toolchains("//:kotlin_toolchain")

KOTLIN_TO_COMPOSE = {
"1.9.22": [
"org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable:2.0.0",
"androidx.core:core-ktx:1.7.0",
"androidx.appcompat:appcompat:1.4.1",
"androidx.activity:activity-compose:1.3.0",
"androidx.compose.material:material:1.2.1",
"androidx.compose.ui:ui:1.2.1",
"androidx.compose.ui:ui-tooling:1.2.1",
"androidx.compose.runtime:runtime:1.2.1",
],
"2.1.0": [
"org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable:2.1.0",
load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
name = "maven_rules_kotlin_example",
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
artifacts = [
"org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable:2.1.20",
"androidx.core:core-ktx:1.15.0",
"androidx.appcompat:appcompat:1.7.0",
"androidx.activity:activity-compose:1.7.0",
Expand All @@ -130,24 +102,20 @@ KOTLIN_TO_COMPOSE = {
"androidx.compose.ui:ui-tooling:1.7.6",
"androidx.compose.runtime:runtime:1.7.6",
],
}

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
name = "maven_rules_kotlin_example",
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
artifacts = KOTLIN_TO_COMPOSE[KOTLINC_RELEASE.version],
fetch_sources = True,
maven_install_json = "//:maven_install-%s.json" % KOTLINC_RELEASE.version,
maven_install_json = "//:maven_install.json",
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
resolver = "coursier" if KOTLINC_RELEASE.version == "1.9.22" else "maven",
resolver = "maven",
use_starlark_android_rules = True,
)

load("@maven_rules_kotlin_example//:defs.bzl", "pinned_maven_install")

pinned_maven_install()

load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")

robolectric_repositories()
Loading