Skip to content

Commit 9c92535

Browse files
authored
Update rules_android to fix --incompatible_disable_native_repo_rules failure (#1358)
* Update rules_android to fix --incompatible_disable_native_repo_rules failure This will pull in bazelbuild/rules_android#376 and fix [release failures](https://buildkite.com/bazel/bcr-presubmit/builds/18423/steps/canvas?sid=0198cdb5-4b4a-459a-9762-9bcb94947930) * Add load for android_sdk_repository * switch to module support for android_sdk_repository, fix kapt test for dealing with transitions * Disable autoloads * Use sdk and ndk rules in module.bzl * Set ndk to 25b for android_ndk_repository compatibility * fix local repository * Move deprecating flags to bzlmod only * update example rules_android version * Deal with dependency uses of incompatible_disable_native_repo_rules * Remove http_jar * remove rbe tag (rbe status is now derived from the task name) * Comment out unsupported commands, update flags to be more orderly. * Fix bzlmod, bump versions * Always pass workspace flags * update docs * Ubuntu has character issues * emdash. * ignore whitespace
1 parent 09901ce commit 9c92535

File tree

20 files changed

+330
-218
lines changed

20 files changed

+330
-218
lines changed

.bazelci/presubmit.yml

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,65 @@
11
---
2+
# Common task configurations.
3+
.unittests: &unittests
4+
build_flags: ${{ test_flags }}
5+
test_flags: ${{ test_flags }}
6+
test_targets:
7+
- "//src/..."
8+
build_targets:
9+
- "//src/..."
10+
11+
.integration_tests: &integration_tests
12+
name: "Integration Tests"
13+
platform: ${{ platform.name }}
14+
environment:
15+
ANDROID_NDK_HOME: ${{ platform.android_ndk_home }}
16+
test_flags: ${{ integration_shard_flags }}
17+
test_targets:
18+
- //examples:all
19+
20+
# Common platform configurations.
21+
.ubuntu2404: &ubuntu2404
22+
platform: ubuntu2404
23+
environment:
24+
ANDROID_NDK_HOME: /opt/android-ndk-r25b
25+
26+
.ubuntu2204: &ubuntu2204
27+
platform: ubuntu2204
28+
environment:
29+
ANDROID_NDK_HOME: /opt/android-ndk-r25b
30+
31+
.macos: &macos
32+
platform: macos
33+
environment:
34+
ANDROID_NDK_HOME: /Users/buildkite/android-ndk-r25b
35+
36+
# bazelci pipeline
237
matrix:
3-
unittest_platform:
4-
- ubuntu2404
5-
- ubuntu2204
6-
integration_platform:
7-
- ubuntu2404
8-
- ubuntu2204
938
integration_shard_flags:
1039
- ["--test_tag_filters=shard_0"]
1140
- ["--test_tag_filters=shard_1"]
1241
- ["--test_tag_filters=shard_2"]
13-
# - macos
14-
# - windows re-enable when rules_bazel_integration_test can support custom test runner on windows.
1542
test_flags:
16-
- []
43+
- ["--enable_bzlmod=true"]
1744
validate_config: 1
18-
bazel: 8.4.2
45+
bazel: 7.6.1
1946
buildifier:
2047
version: 8.2.0
2148
# no lint warnings for the moment. They are basically a smoke alarm in hell.
2249
# keep this argument in sync with .pre-commit-config.yaml
2350
warnings: "+unsorted-dict-items,-confusing-name,-constant-glob,-duplicated-name,-function-docstring,-function-docstring-args,-function-docstring-header,-module-docstring,-name-conventions,-no-effect,-constant-glob,-provider-params,-print,-rule-impl-return,-bzl-visibility,-unnamed-macro,-uninitialized,-unreachable"
2451
tasks:
25-
unittests:
26-
name: "Unit Tests"
27-
platform: ${{ unittest_platform }}
28-
build_flags: ${{ test_flags }}
29-
test_flags: ${{ test_flags }}
30-
test_targets:
31-
- "//src/..."
32-
build_targets:
33-
- "//src/..."
34-
integration_tests:
35-
name: "Integration Tests"
36-
platform: ${{ integration_platform }}
37-
test_flags: ${{ integration_shard_flags }}
38-
test_targets:
39-
- //examples:all
40-
environment:
41-
ANDROID_NDK_HOME: /opt/android-ndk-r25b
42-
rbe_ubuntu2404:
52+
macos_unittests:
53+
<<: [ *macos, *unittests ]
54+
ubuntu2404_unittests:
55+
<<: [*ubuntu2404, *unittests]
56+
ubuntu2404_integration_tests:
57+
<<: [*ubuntu2404, *integration_tests]
58+
ubuntu2204_unittests:
59+
<<: [*ubuntu2204, *unittests]
60+
ubuntu2204_integration_tests:
61+
<<: [*ubuntu2204, *integration_tests]
62+
rbe_ubuntu1604:
4363
test_targets:
4464
- "--"
4565
- "//src/test/kotlin/io/bazel/kotlin/builder:builder_tests"
@@ -48,21 +68,17 @@ tasks:
4868
- "//src/test/kotlin/io/bazel/kotlin:KotlinJvmAssociatesBasicVisibilityTest"
4969
- "//src/test/kotlin/io/bazel/kotlin:KotlinJvmBasicAssertionTest"
5070
test_flags:
51-
# Override the default worker strategy for remote builds (worker strategy
52-
# cannot be used with remote builds)
5371
- "--strategy=KotlinCompile=remote"
5472
stardoc:
5573
name: Stardoc api documentation
56-
platform: ubuntu2404
57-
build_flags:
58-
- "--enable_bzlmod=true"
74+
platform: rbe_ubuntu1604
5975
build_targets:
6076
- //kotlin:stardoc
6177
test_targets:
6278
- //docs:are_docs_up_to_date_test
6379
ktlint:
6480
name: KtLint
65-
platform: ubuntu2404
81+
<<: *ubuntu2404
6682
test_targets:
6783
- //...
6884
test_flags:

.bazelrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
common --enable_bzlmod=true
22
common --incompatible_use_plus_in_repo_names
33
common --incompatible_disallow_empty_glob=false
4-
54
common --java_runtime_version=remotejdk_17
65
common --tool_java_runtime_version=remotejdk_17
76

7+
# TODO[https://github.com/bazelbuild/rules_kotlin/issues/1395]: Uncomment when all rules support not using native repo rules.
8+
# common --incompatible_disable_native_repo_rules=true
9+
# common --incompatible_autoload_externally=
10+
811
build --strategy=KotlinCompile=worker
912
build --test_output=all
1013
build --verbose_failures

BUILD

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ test_suite(
6060
# Release target.
6161
release_archive(
6262
name = "rules_kotlin_release",
63-
srcs = [
64-
"WORKSPACE.bzlmod",
65-
],
6663
src_map = {
6764
"BUILD.release.bazel": "BUILD.bazel",
6865
"MODULE.release.bazel": "MODULE.bazel",
@@ -85,6 +82,7 @@ filegroup(
8582
visibility = ["//:__subpackages__"],
8683
)
8784

85+
# TODO[https://github.com/bazelbuild/rules_kotlin/issues/1395]: Must be run with `--config=deprecated`
8886
buildifier(
8987
name = "buildifier.check",
9088
exclude_patterns = [

MODULE.bazel

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module(
22
name = "rules_kotlin",
3-
version = "1.8.1",
3+
version = "2.2.0",
44
compatibility_level = 1,
55
repo_name = "rules_kotlin",
66
)
@@ -19,11 +19,24 @@ bazel_dep(name = "platforms", version = "0.0.11")
1919
bazel_dep(name = "bazel_skylib", version = "1.8.2")
2020
bazel_dep(name = "rules_java", version = "8.9.0")
2121
bazel_dep(name = "rules_python", version = "0.23.1")
22-
bazel_dep(name = "rules_android", version = "0.6.4")
22+
bazel_dep(name = "rules_android", version = "0.6.6")
23+
24+
remote_android_extensions = use_extension(
25+
"@rules_android//bzlmod_extensions:android_extensions.bzl",
26+
"remote_android_tools_extensions",
27+
)
28+
use_repo(remote_android_extensions, "android_tools")
29+
30+
android_sdk_repository_extension = use_extension("@rules_android//rules/android_sdk_repository:rule.bzl", "android_sdk_repository_extension")
31+
use_repo(android_sdk_repository_extension, "androidsdk")
32+
33+
register_toolchains("@androidsdk//:all")
34+
2335
bazel_dep(name = "bazel_features", version = "1.25.0")
2436
bazel_dep(name = "rules_shell", version = "0.4.1")
2537

26-
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True)
38+
# TODO[https://github.com/bazelbuild/rules_kotlin/issues/1395]: Update when fixed version is available.
39+
bazel_dep(name = "buildifier_prebuilt", version = "8.2.1", dev_dependency = True)
2740

2841
rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
2942
use_repo(rules_java_toolchains, "remote_java_tools")

WORKSPACE.bzlmod

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/are_docs_up_to_date_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ new="$2"
1010
[[ -f $new ]] || fail "missing new docs"
1111
[[ -f $current ]] || fail "missing current docs"
1212

13-
diff -u "$1" "$2" || fail "kotlin docs are out of date"
13+
diff -wu "$1" "$2" || fail "kotlin docs are out of date"

docs/kotlin.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Define kotlin compiler options.
420420
| <a id="kt_kotlinc_options-x_enable_incremental_compilation"></a>x_enable_incremental_compilation | Enable incremental compilation | Boolean | optional | `False` |
421421
| <a id="kt_kotlinc_options-x_explicit_api_mode"></a>x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | `"off"` |
422422
| <a id="kt_kotlinc_options-x_inline_classes"></a>x_inline_classes | Enable experimental inline classes | Boolean | optional | `False` |
423-
| <a id="kt_kotlinc_options-x_jdk_release"></a>x_jdk_release | Compile against the specified JDK API version, similarly to javac's '-release'. This requires JDK 9 or newer. The supported versions depend on the JDK used; for JDK 17+, the supported versions are 1.8 and 921. This also sets the value of '-jvm-target' to be equal to the selected JDK version. | String | optional | `""` |
423+
| <a id="kt_kotlinc_options-x_jdk_release"></a>x_jdk_release | Compile against the specified JDK API version, similarly to javac's '-release'. This requires JDK 9 or newer. The supported versions depend on the JDK used; for JDK 17+, the supported versions are 1.8 and 9-21. This also sets the value of '-jvm-target' to be equal to the selected JDK version. | String | optional | `""` |
424424
| <a id="kt_kotlinc_options-x_jspecify_annotations"></a>x_jspecify_annotations | Controls how JSpecify annotations are treated. Options are 'default', 'ignore', 'warn', and 'strict'. | String | optional | `""` |
425425
| <a id="kt_kotlinc_options-x_jsr_305"></a>x_jsr_305 | Specifies how to handle JSR-305 annotations in Kotlin code. Options are 'default', 'ignore', 'warn', and 'strict'. | String | optional | `""` |
426426
| <a id="kt_kotlinc_options-x_jvm_default"></a>x_jvm_default | Specifies that a JVM default method should be generated for non-abstract Kotlin interface member. | String | optional | `"off"` |
@@ -611,7 +611,7 @@ Call this in the WORKSPACE file to setup the Kotlin rules.
611611
<pre>
612612
load("@rules_kotlin//kotlin:repositories.doc.bzl", "versions")
613613

614-
versions.use_repository(<a href="#versions.use_repository-name">name</a>, <a href="#versions.use_repository-version">version</a>, <a href="#versions.use_repository-rule">rule</a>, <a href="#versions.use_repository-kwargs">**kwargs</a>)
614+
versions.use_repository(<a href="#versions.use_repository-rule">rule</a>, <a href="#versions.use_repository-name">name</a>, <a href="#versions.use_repository-version">version</a>, <a href="#versions.use_repository-kwargs">kwargs</a>)
615615
</pre>
616616

617617

@@ -621,9 +621,9 @@ versions.use_repository(<a href="#versions.use_repository-name">name</a>, <a hre
621621

622622
| Name | Description | Default Value |
623623
| :------------- | :------------- | :------------- |
624+
| <a id="versions.use_repository-rule"></a>rule | <p align="center"> - </p> | none |
624625
| <a id="versions.use_repository-name"></a>name | <p align="center"> - </p> | none |
625626
| <a id="versions.use_repository-version"></a>version | <p align="center"> - </p> | none |
626-
| <a id="versions.use_repository-rule"></a>rule | <p align="center"> - </p> | none |
627627
| <a id="versions.use_repository-kwargs"></a>kwargs | <p align="center"> - </p> | none |
628628

629629

examples/android/MODULE.bazel

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module(name = "android-example")
22

3-
bazel_dep(name = "rules_android", version = "0.6.4")
3+
bazel_dep(name = "rules_android", version = "0.6.6")
44
bazel_dep(name = "bazel_skylib", version = "1.7.1")
55
bazel_dep(name = "rules_robolectric", version = "4.14.1.2", repo_name = "robolectric")
66
bazel_dep(name = "rules_java", version = "8.9.0")
@@ -12,6 +12,13 @@ use_repo(android_sdk_repository_extension, "androidsdk")
1212

1313
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")
1414

15+
bazel_dep(name = "rules_android_ndk", version = "0.1.2")
16+
17+
android_ndk_repository_extension = use_extension("@rules_android_ndk//:extension.bzl", "android_ndk_repository_extension")
18+
use_repo(android_ndk_repository_extension, "androidndk")
19+
20+
register_toolchains("@androidndk//:all")
21+
1522
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
1623
maven.install(
1724
name = "maven_rules_kotlin_example",

examples/android/WORKSPACE.bzlmod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
android_sdk_repository(name = "androidsdk")
2-
3-
android_ndk_repository(name = "androidndk")

examples/trivial/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module(name = "trival-example")
22

33
bazel_dep(name = "rules_java", version = "8.9.0")
4-
bazel_dep(name = "rules_kotlin", version = "1.9.5")
4+
bazel_dep(name = "rules_kotlin", version = "2.2.0")
55
bazel_dep(name = "rules_jvm_external", version = "6.6")
66
bazel_dep(name = "rules_shell", version = "0.4.0")
77

0 commit comments

Comments
 (0)