Skip to content

Commit 6a1d6bb

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

File tree

5 files changed

+41
-13
lines changed

5 files changed

+41
-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: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,49 @@ 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] == "external":
16+
return "(source) " + file.short_path
17+
if segments[0] == "bazel-out":
18+
# not exactly reliable, but the current test rules perform several transitions making it
19+
# difficult to validate if a file is actually where it should be.
20+
if "exec" in segments[1]:
21+
return "(exec) " + file.short_path
22+
return "(target) " + file.short_path
23+
824
def _action(env, got):
925
got_target = env.expect.that_target(got)
1026

11-
inputs = []
27+
want_inputs = {}
1228
for i in env.ctx.attr.exec_inputs:
1329
if JavaInfo in i:
1430
for jo in i[JavaInfo].java_outputs:
15-
inputs.append(jo.compile_jar)
31+
want_inputs[_normalize_path_with_cfg(jo.compile_jar)] = True
1632
else:
17-
inputs.extend(i[DefaultInfo].files.to_list())
33+
for f in i[DefaultInfo].files.to_list():
34+
want_inputs[_normalize_path_with_cfg(f)] = True
1835
for i in env.ctx.attr.target_inputs:
1936
if JavaInfo in i:
2037
for jo in i[JavaInfo].java_outputs:
21-
inputs.append(jo.compile_jar)
38+
want_inputs[_normalize_path_with_cfg(jo.compile_jar)] = True
2239
else:
23-
inputs.extend(i[DefaultInfo].files.to_list())
40+
for f in i[DefaultInfo].files.to_list():
41+
want_inputs[_normalize_path_with_cfg(f)] = True
2442

2543
compile = got_target.action_named(env.ctx.attr.mnemonic)
2644

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

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

0 commit comments

Comments
 (0)