Skip to content

Commit a5324ff

Browse files
committed
Bazel: move patching of rules_kotlin to a registry override
1 parent e7c680e commit a5324ff

File tree

9 files changed

+78
-8
lines changed

9 files changed

+78
-8
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ build:linux --cxxopt=-std=c++20
1414
build:macos --cxxopt=-std=c++20 --cpu=darwin_x86_64
1515
build:windows --cxxopt=/std:c++20 --cxxopt=/Zc:preprocessor
1616

17+
common --registry=file://%workspace%/misc/bazel/override_registry
18+
common --registry=https://bcr.bazel.build
19+
1720
import %workspace%/exported.bazelrc
1821
try-import %workspace%/local.bazelrc

MODULE.bazel

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0")
2121
bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "absl")
2222
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2323
bazel_dep(name = "fmt", version = "10.0.0")
24-
bazel_dep(name = "rules_kotlin", version = "1.9.4")
25-
26-
# we patch `rules_kotlin` to allow passing `-language-version` at a jvm_kt_library level
27-
single_version_override(
28-
module_name = "rules_kotlin",
29-
patch_strip = 1,
30-
patches = ["//java/kotlin-extractor:rules_kotlin.patch"],
31-
)
24+
bazel_dep(name = "rules_kotlin", version = "1.9.4-patched")
3225

3326
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
3427
pip.parse(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This was taken from https://github.com/bazelbuild/bazel-central-repository and readapted:
2+
* The latest version was renamed with a `-patched` suffix
3+
* The above rename was done also in the files:
4+
* `modules/rules_kotlin/metadata.json`
5+
* `module/rules_kotlin/1.9.4-patched/MODULE.bazel`
6+
* `modules/rules_kotlin/1.9.4-patched/patches/add_language_version_option.patch` was added
7+
* the above patch was added in `modules/rules_kotlin/1.9.4-patched/source.json`, with integrity SHAs generated via
8+
`echo -n sha256-; cat <file> | openssl dgst -sha256 -binary | base64`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mirrors": []
3+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module(
2+
name = "rules_kotlin",
3+
version = "1.9.4-patched",
4+
repo_name = "rules_kotlin",
5+
)
6+
7+
bazel_dep(name = "platforms", version = "0.0.6")
8+
bazel_dep(name = "bazel_skylib", version = "1.4.2")
9+
bazel_dep(name = "rules_java", version = "7.2.0")
10+
bazel_dep(name = "rules_python", version = "0.23.1")
11+
bazel_dep(name = "rules_cc", version = "0.0.8")
12+
13+
rules_kotlin_extensions = use_extension(
14+
"//src/main/starlark/core/repositories:bzlmod_setup.bzl",
15+
"rules_kotlin_extensions",
16+
)
17+
use_repo(
18+
rules_kotlin_extensions,
19+
"com_github_google_ksp",
20+
"com_github_jetbrains_kotlin",
21+
"com_github_pinterest_ktlint",
22+
"rules_android",
23+
)
24+
25+
register_toolchains("//kotlin/internal:default_toolchain")
26+
27+
# TODO(bencodes) We should be able to remove this once rules_android has rolled out official Bzlmod support
28+
remote_android_extensions = use_extension("@bazel_tools//tools/android:android_extensions.bzl", "remote_android_tools_extensions")
29+
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
30+
31+
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
===================================================================
2+
--- a/MODULE.bazel
3+
+++ b/MODULE.bazel
4+
@@ -1,7 +1,7 @@
5+
module(
6+
name = "rules_kotlin",
7+
- version = "1.9.0",
8+
+ version = "1.9.4",
9+
repo_name = "rules_kotlin",
10+
)
11+
12+
bazel_dep(name = "platforms", version = "0.0.6")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"integrity": "sha256-dsD8wsI+33NjIK3tGs2d3guuQY5XMd8Skz2IbLqGt5U=",
3+
"url": "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.9.4/rules_kotlin-v1.9.4.tar.gz",
4+
"patches": {
5+
"module_dot_bazel_version.patch": "sha256-8Fu6NiXzckWm8oaVY/rPonGEqWG5ijV0r2GUf7ajKHM=",
6+
"add_language_version_option.patch": "sha256-uF6LFpkqe9ye7+avviY1NE5ZhxJ3WMLenS+mbg4XFTM="
7+
},
8+
"patch_strip": 1
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"homepage": "https://github.com/bazelbuild/rules_kotlin",
3+
"maintainers": [],
4+
"repository": [
5+
"github:bazelbuild/rules_kotlin"
6+
],
7+
"versions": [
8+
"1.9.4-patched"
9+
],
10+
"yanked_versions": {}
11+
}

0 commit comments

Comments
 (0)