Skip to content

Commit 5240f97

Browse files
committed
switch to module support for android_sdk_repository, fix kapt test for dealing with transitions
1 parent e5a02b4 commit 5240f97

File tree

5 files changed

+43
-13
lines changed

5 files changed

+43
-13
lines changed

.bazelrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ common --enable_bzlmod=true
22
common --incompatible_use_plus_in_repo_names
33
common --incompatible_disallow_empty_glob=false
44
common --incompatible_disable_native_repo_rules=true
5-
65
common:rbe --java_runtime_version=11
76
common:rbe --tool_java_runtime_version=11
87

BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ test_suite(
5858
# Release target.
5959
release_archive(
6060
name = "rules_kotlin_release",
61-
srcs = [
62-
"WORKSPACE.bzlmod",
63-
],
6461
src_map = {
6562
"BUILD.release.bazel": "BUILD.bazel",
6663
"MODULE.release.bazel": "MODULE.bazel",

MODULE.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ bazel_dep(name = "bazel_skylib", version = "1.7.1")
1414
bazel_dep(name = "rules_java", version = "8.9.0")
1515
bazel_dep(name = "rules_python", version = "0.23.1")
1616
bazel_dep(name = "rules_android", version = "0.6.6")
17+
18+
remote_android_extensions = use_extension(
19+
"@rules_android//bzlmod_extensions:android_extensions.bzl",
20+
"remote_android_tools_extensions",
21+
)
22+
use_repo(remote_android_extensions, "android_tools")
23+
24+
android_sdk_repository_extension = use_extension("@rules_android//rules/android_sdk_repository:rule.bzl", "android_sdk_repository_extension")
25+
use_repo(android_sdk_repository_extension, "androidsdk")
26+
27+
register_toolchains("@androidsdk//:all")
28+
1729
bazel_dep(name = "bazel_features", version = "1.25.0")
1830
bazel_dep(name = "rules_shell", version = "0.4.1")
1931

WORKSPACE.bzlmod

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/test/starlark/core/plugin/kapt/kapt_test.bzl

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,51 @@ load("//kotlin/compiler:kapt.bzl", "kapt_compiler_plugin")
55
load("//src/test/starlark:case.bzl", "Want", "suite")
66
load("//src/test/starlark:truth.bzl", "flags_and_values_of")
77

8+
def _normalize_path_with_cfg(file):
9+
"""Attempts to normalize the file to standard configs.
10+
11+
This turns out to be necessary due to multiple transitions with testing.analysis_test.
12+
"""
13+
prefix = file.path.removesuffix(file.short_path)
14+
segments = prefix.split("/")
15+
if segments[0] == "bazel-out":
16+
# not exactly reliable, but the current test rules perform several transitions making it
17+
# difficult to validate if a file is actually where it should be.
18+
if "exec" in segments[1]:
19+
return "(exec) " + file.short_path
20+
return "(target) " + file.short_path
21+
if file.is_source():
22+
return "(source) " + file.short_path
23+
24+
return file.path
25+
826
def _action(env, got):
927
got_target = env.expect.that_target(got)
1028

11-
inputs = []
29+
want_inputs = {}
1230
for i in env.ctx.attr.exec_inputs:
1331
if JavaInfo in i:
1432
for jo in i[JavaInfo].java_outputs:
15-
inputs.append(jo.compile_jar)
33+
want_inputs[_normalize_path_with_cfg(jo.compile_jar)] = True
1634
else:
17-
inputs.extend(i[DefaultInfo].files.to_list())
35+
for f in i[DefaultInfo].files.to_list():
36+
want_inputs[_normalize_path_with_cfg(f)] = True
1837
for i in env.ctx.attr.target_inputs:
1938
if JavaInfo in i:
2039
for jo in i[JavaInfo].java_outputs:
21-
inputs.append(jo.compile_jar)
40+
want_inputs[_normalize_path_with_cfg(jo.compile_jar)] = True
2241
else:
23-
inputs.extend(i[DefaultInfo].files.to_list())
42+
for f in i[DefaultInfo].files.to_list():
43+
want_inputs[_normalize_path_with_cfg(f)] = True
2444

2545
compile = got_target.action_named(env.ctx.attr.mnemonic)
2646

27-
compile.contains_at_least_inputs(inputs)
47+
got_inputs = {
48+
_normalize_path_with_cfg(f): True
49+
for f in compile.actual.inputs.to_list()
50+
}
51+
52+
env.expect.that_collection(got_inputs.keys()).contains_at_least(want_inputs.keys())
2853

2954
got_target.runfiles().contains_at_least([
3055
"/".join((env.ctx.workspace_name, f.short_path))

0 commit comments

Comments
 (0)