Skip to content

Commit

Permalink
Merge #231 by ted-xie: Copy maven artifact list to MODULE.bazel
Browse files Browse the repository at this point in the history
Also adds a consistency check between defs.bzl and MODULE.bazel for the Maven artifacts.

Disables the Maven lockfile for WORKSPACE mode due to bazel-contrib/rules_jvm_external#1134.

Ultimately, this is a workaround to
bazel-contrib/rules_jvm_external#1132.
Closes #231

COPYBARA_INTEGRATE_REVIEW=#231 from ted-xie:maven_changes 643e5f1
PiperOrigin-RevId: 633334440
Change-Id: I9de06529495846e3a72a50d394cdf90f6335923b
  • Loading branch information
ted-xie authored and copybara-github committed May 13, 2024
1 parent 25dedbe commit 77b8786
Show file tree
Hide file tree
Showing 5 changed files with 4,322 additions and 3,701 deletions.
32 changes: 27 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolc
use_repo(rules_java_toolchains, "remote_java_tools")

bazel_dep(name = "protobuf", version = "3.19.0", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_jvm_external", version = "4.5")
bazel_dep(name = "rules_jvm_external", version = "6.1")
bazel_dep(name = "bazel_skylib", version = "1.0.3")
bazel_dep(name = "rules_robolectric", version = "4.11.1", repo_name = "robolectric")

Expand Down Expand Up @@ -60,13 +60,35 @@ bazel_dep(name = "rules_proto", version = "5.3.0-21.7", repo_name = "rules_proto
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "rules_android_maven",
# To generate the maven lockfile, run this command:
# bazel run --noenable_bzlmod @rules_android_maven//:pin
lock_file = "//:rules_android_maven_install.json",
artifacts = [
"androidx.privacysandbox.tools:tools:1.0.0-alpha06",
"androidx.privacysandbox.tools:tools-apigenerator:1.0.0-alpha06",
"androidx.privacysandbox.tools:tools-apipackager:1.0.0-alpha06",
"androidx.test:core:1.6.0-alpha01",
"androidx.test.ext:junit:1.2.0-alpha01",
"com.android.tools.build:apksig:8.3.0-alpha18",
"com.android.tools.build:bundletool:1.15.5",
"com.android.tools:desugar_jdk_libs_minimal:2.0.4",
"com.android.tools:desugar_jdk_libs_configuration_minimal:2.0.4",
"com.android.tools:desugar_jdk_libs_nio:2.0.4",
"com.android.tools:desugar_jdk_libs_configuration_nio:2.0.4",
"com.android.tools.build:gradle:8.2.0-alpha15",
"org.bouncycastle:bcprov-jdk18on:1.77",
"org.hamcrest:hamcrest-core:2.2",
"org.robolectric:robolectric:4.10.3",
"com.google.guava:guava:32.1.2-jre",
"com.google.protobuf:protobuf-java-util:3.9.2",
"com.google.truth:truth:1.1.5",
"info.picocli:picocli:4.7.4",
"junit:junit:4.13.2",
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
# To generate, run:
# REPIN=1 bazelisk run --enable_bzlmod @rules_android_maven//:pin
lock_file = "//:rules_android_maven_install.json"
)
use_repo(
maven,
Expand Down Expand Up @@ -109,4 +131,4 @@ git_override(

android_sdk_repository_extension = use_extension("//rules/android_sdk_repository:rule.bzl", "android_sdk_repository_extension")
use_repo(android_sdk_repository_extension, "androidsdk")
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")
6 changes: 5 additions & 1 deletion defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ def rules_android_workspace():
"junit:junit:4.13.2",
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
# To generate:
# REPIN=1 bazelisk run --noenable_bzlmod @unpinned_rules_android_maven//:pin
# maven_install_json = "//:rules_android_maven_install.json",
# NOTE: above lockfile currently disabled due to https://github.com/bazelbuild/rules_jvm_external/issues/1134.
)

go_rules_dependencies()
Expand Down
5 changes: 5 additions & 0 deletions kokoro/presubmit/presubmit_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ function main() {
# Go to rules_android workspace and run relevant tests.
cd "${KOKORO_ARTIFACTS_DIR}/git/rules_android"

# Maven artifact consistency test
# The sed commands in the `<()` blocks extract the artifacts list from maven_install.
# `diff -w` compares the two files without whitespaces.
diff -w <(sed -n '/artifacts =/{:start /]/!{N;b start};/.*/p}' defs.bzl) <(sed -n '/artifacts =/{:start /]/!{N;b start};/.*/p}' MODULE.bazel)

# Sync with bzlmod disabled to sniff out WORKSPACE issues
"$bazel" sync --noenable_bzlmod > /dev/null
# Run with bzlmod enabled to catch missing bzlmod deps.
Expand Down
9 changes: 6 additions & 3 deletions prereqs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ def rules_android_prereqs(dev_mode = False):
sha256 = "4da3761f6855ad916568e2bfe86213ba6d2637f56b8360538a7fb6125abf6518",
)

RULES_JVM_EXTERNAL_TAG = "6.1"
RULES_JVM_EXTERNAL_SHA = "08ea921df02ffe9924123b0686dc04fd0ff875710bfadb7ad42badb931b0fd50"

maybe(
http_archive,
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-fa73b1a8e4846cee88240d0019b8f80d39feb1c3",
sha256 = "7e13e48b50f9505e8a99cc5a16c557cbe826e9b68d733050cd1e318d69f94bb5",
url = "https://github.com/bazelbuild/rules_jvm_external/archive/fa73b1a8e4846cee88240d0019b8f80d39feb1c3.zip",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG)
)

maybe(
Expand Down
Loading

0 comments on commit 77b8786

Please sign in to comment.