Skip to content

Commit fbb5843

Browse files
ahumeskycopybara-github
authored andcommitted
Add android_gmaven_r8 to bazel's WORKSPACE file so that it overrides the version of R8 that might come from android_remote_tools.WORKSPACE in a released version of bazel used to run the test (which would be potentially out of date with respect to the source code). Also merge this with android_gmaven_r8_for_testing since they would be redundant.
RELNOTES: None. PiperOrigin-RevId: 529830525 Change-Id: Ic5c18ce5beb7fb915b084dc19590a05b04675548
1 parent cfe0181 commit fbb5843

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

WORKSPACE

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
workspace(name = "io_bazel")
22

3-
load("//tools/build_defs/repo:http.bzl", "http_archive", "http_jar")
4-
load("//:distdir.bzl", "dist_http_archive", "distdir_tar")
3+
load("//tools/build_defs/repo:http.bzl", "http_archive")
4+
load("//:distdir.bzl", "dist_http_archive", "distdir_tar", "dist_http_jar")
55
load("//:distdir_deps.bzl", "DIST_DEPS")
66
load("//:repositories.bzl", "embedded_jdk_repositories")
77

@@ -262,21 +262,16 @@ distdir_tar(
262262
name = "test_WORKSPACE_files",
263263
archives = [
264264
"android_tools_pkg-0.28.0.tar",
265-
"r8-8.0.40.jar",
266265
],
267266
dirname = "test_WORKSPACE/distdir",
268267
dist_deps = {dep: attrs for dep, attrs in DIST_DEPS.items() if "test_WORKSPACE_files" in attrs["used_in"]},
269268
sha256 = {
270269
"android_tools_pkg-0.28.0.tar": "db3b02421ae974e0b33573f3e4f658d5f89cc9a0b42baae0ba2ac08e25c0720a",
271-
"r8-8.0.40.jar": "ab1379835c7d3e5f21f80347c3c81e2f762e0b9b02748ae5232c3afa14adf702",
272270
},
273271
urls = {
274272
"android_tools_pkg-0.28.0.tar": [
275273
"https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.28.0.tar",
276274
],
277-
"r8-8.0.40.jar": [
278-
"https://maven.google.com/com/android/tools/r8/8.0.40/r8-8.0.40.jar",
279-
],
280275
},
281276
)
282277

@@ -298,12 +293,13 @@ http_archive(
298293
url = "https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.28.0.tar",
299294
)
300295

301-
# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_remote_tools.WORKSPACE
302-
# and tools/android/android_extensions.bzl
303-
http_jar(
304-
name = "android_gmaven_r8_for_testing",
305-
sha256 = "ab1379835c7d3e5f21f80347c3c81e2f762e0b9b02748ae5232c3afa14adf702",
306-
url = "https://maven.google.com/com/android/tools/r8/8.0.40/r8-8.0.40.jar",
296+
# This is here to override the android_gmaven_r8 rule from
297+
# src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_remote_tools.WORKSPACE
298+
# so that tests like src/test/java/com/google/devtools/build/android/r8:AllTests
299+
# use the most recent version of R8 rather than the one might be referenced in a released
300+
# version of bazel that might have an outdated android_remote_tools.WORKSPACE relative to the tests.
301+
dist_http_jar(
302+
name = "android_gmaven_r8",
307303
)
308304

309305
dist_http_archive(

distdir.bzl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""Defines a repository rule that generates an archive consisting of the specified files to fetch"""
1515

1616
load("//:distdir_deps.bzl", "DEPS_BY_NAME")
17-
load("//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
17+
load("//tools/build_defs/repo:http.bzl", "http_archive", "http_file", "http_jar")
1818

1919
_BUILD = """
2020
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
@@ -115,3 +115,21 @@ def dist_http_file(name, **kwargs):
115115
urls = info["urls"],
116116
**kwargs
117117
)
118+
119+
def dist_http_jar(name, **kwargs):
120+
"""Wraps http_jar, providing attributes like sha and urls from the central list.
121+
122+
dist_http_jar wraps an http_jar invocation, but looks up relevant attributes
123+
from distdir_deps.bzl so the user does not have to specify them.
124+
125+
Args:
126+
name: repo name
127+
**kwargs: see http_jar for allowed args.
128+
"""
129+
info = DEPS_BY_NAME[name]
130+
http_jar(
131+
name = name,
132+
sha256 = info["sha256"],
133+
urls = info["urls"],
134+
**kwargs
135+
)

distdir_deps.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,17 @@ DIST_DEPS = {
288288
# Build time dependencies for testing and packaging
289289
#
290290
###################################################
291+
"android_gmaven_r8": {
292+
"archive": "r8-8.0.40.jar",
293+
"sha256": "ab1379835c7d3e5f21f80347c3c81e2f762e0b9b02748ae5232c3afa14adf702",
294+
"urls": [
295+
"https://maven.google.com/com/android/tools/r8/8.0.40/r8-8.0.40.jar",
296+
],
297+
"used_in": [
298+
"test_WORKSPACE_files",
299+
],
300+
"package_version": "8.0.40",
301+
},
291302
"bazel_skylib": {
292303
"archive": "bazel-skylib-1.3.0.tar.gz",
293304
"sha256": "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",

src/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ release_archive(
559559
filegroup(
560560
name = "test_repos",
561561
srcs = [
562-
"@android_gmaven_r8_for_testing//jar:file",
562+
"@android_gmaven_r8//jar:file",
563563
"@android_tools_for_testing//:WORKSPACE",
564564
"@bazel_skylib//:WORKSPACE",
565565
"@com_google_protobuf//:WORKSPACE",

src/test/shell/testenv.sh.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ EOF
272272

273273
repos=(
274274
"android_tools_for_testing"
275-
"android_gmaven_r8_for_testing"
275+
"android_gmaven_r8"
276276
"bazel_skylib"
277277
"bazel_toolchains"
278278
"com_google_protobuf"

0 commit comments

Comments
 (0)