Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ build:windows --define=protobuf_allow_msvc=true

common --enable_platform_specific_config

# Use prebuilt protoc
common --incompatible_enable_proto_toolchain_resolution
common --@com_google_protobuf//bazel/toolchains:prefer_prebuilt_protoc=true
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
14 changes: 6 additions & 8 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)
rules_java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains")
use_repo(rules_java_toolchains, "remote_java_tools")

bazel_dep(name = "protobuf", version = "33.1", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "33.4", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_jvm_external", version = "6.9")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "rules_robolectric", version = "4.14.1.2", repo_name = "robolectric")
Expand Down Expand Up @@ -54,9 +54,6 @@ python.toolchain(
python_version = "3.11",
)

# proto-related dependency setup
bazel_dep(name = "rules_proto", version = "7.1.0", repo_name = "rules_proto")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
# Maven for android_ide_common need to be separated into their own separate maven_install for now
# due to compatibility issues with newer versions.
Expand All @@ -78,8 +75,8 @@ maven.install(
# These technically aren't needed, but the protobuf version pulled
# in by these older deps has compatibility issues with the newer
# protobuf runtimes.
"com.google.protobuf:protobuf-java:4.33.1",
"com.google.protobuf:protobuf-java-util:4.33.1",
"com.google.protobuf:protobuf-java:4.33.4",
"com.google.protobuf:protobuf-java-util:4.33.4",
],
repositories = [
"https://maven.google.com",
Expand Down Expand Up @@ -117,8 +114,9 @@ maven.install(
"jakarta.inject:jakarta.inject-api:2.0.1",
"junit:junit:4.13.2",
"com.beust:jcommander:1.82",
"com.google.protobuf:protobuf-java:4.33.1",
"com.google.protobuf:protobuf-java-util:4.33.1",
# Override transitive protobuf deps to match bazel_dep protobuf version.
"com.google.protobuf:protobuf-java:4.33.4",
"com.google.protobuf:protobuf-java-util:4.33.4",
"com.google.code.findbugs:jsr305:3.0.2",
"androidx.databinding:databinding-compiler:8.7.0",
"org.ow2.asm:asm:9.6",
Expand Down
10 changes: 4 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ load("prereqs.bzl", "rules_android_prereqs")

rules_android_prereqs(dev_mode = True)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()


load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()

Expand All @@ -15,12 +19,6 @@ compatibility_proxy_repo()
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
rules_java_dependencies()

# note that the following line is what is minimally required from protobuf for the java rules
# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl
load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility

proto_bazel_features(name = "proto_bazel_features")

# register toolchains
load("@rules_java//java:repositories.bzl", "rules_java_toolchains")

Expand Down
20 changes: 7 additions & 13 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ load(
)
load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
load("@rules_proto//proto:setup.bzl", "rules_proto_setup")
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")

Expand Down Expand Up @@ -57,8 +54,8 @@ def rules_android_workspace():
# These technically aren't needed, but the protobuf version pulled
# in by these older deps has compatibility issues with the newer
# protobuf runtimes.
"com.google.protobuf:protobuf-java:4.33.1",
"com.google.protobuf:protobuf-java-util:4.33.1",
"com.google.protobuf:protobuf-java:4.33.4",
"com.google.protobuf:protobuf-java-util:4.33.4",
],
repositories = [
"https://maven.google.com",
Expand Down Expand Up @@ -94,8 +91,8 @@ def rules_android_workspace():
"jakarta.inject:jakarta.inject-api:2.0.1",
"junit:junit:4.13.2",
"com.beust:jcommander:1.82",
"com.google.protobuf:protobuf-java:4.33.1",
"com.google.protobuf:protobuf-java-util:4.33.1",
"com.google.protobuf:protobuf-java:4.33.4",
"com.google.protobuf:protobuf-java-util:4.33.4",
"com.google.code.findbugs:jsr305:3.0.2",
"androidx.databinding:databinding-compiler:8.7.0",
"org.ow2.asm:asm:9.6",
Expand Down Expand Up @@ -150,8 +147,8 @@ def rules_android_workspace():
"com.google.code.gson:gson:2.10.1", # bazel worker api
"com.google.errorprone:error_prone_annotations:2.23.0", # bazel worker api
"com.google.guava:guava:33.0.0-jre", # bazel worker api
"com.google.protobuf:protobuf-java:4.33.1", # bazel worker api
"com.google.protobuf:protobuf-java-util:4.33.1", # bazel worker api
"com.google.protobuf:protobuf-java:4.33.4", # bazel worker api
"com.google.protobuf:protobuf-java-util:4.33.4", # bazel worker api
"junit:junit:4.13.2", # bazel worker api
"org.mockito:mockito-core:5.4.0", # bazel worker api
"com.google.truth:truth:1.4.0", # bazel worker api
Expand All @@ -162,6 +159,7 @@ def rules_android_workspace():
"https://maven.google.com",
],
)

go_rules_dependencies()

_GO_TOOLCHAIN_VERSION = "1.22.4"
Expand Down Expand Up @@ -204,10 +202,6 @@ def rules_android_workspace():

robolectric_repositories()

rules_proto_dependencies()
rules_proto_toolchains()
rules_proto_setup()

py_repositories()

python_register_toolchains(
Expand Down
8 changes: 8 additions & 0 deletions examples/basicapp/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ build:windows --define=protobuf_allow_msvc=true

common --enable_platform_specific_config

# Use prebuilt protoc
common --incompatible_enable_proto_toolchain_resolution
common --@com_google_protobuf//bazel/toolchains:prefer_prebuilt_protoc=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there another way to pass this flag to the underlying proto rules/actions? This line assumes that the user's app depends on protobuf directly, which might not be the case.

# Ensure that we don't accidentally build protobuf or gRPC
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
1 change: 1 addition & 0 deletions examples/basicapp/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module(
bazel_dep(name = "rules_java", version = "9.0.3")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "protobuf", version = "33.4", repo_name = "com_google_protobuf")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Apps shouldn't need to declare dependencies that are used by the rules.


bazel_dep(
name = "rules_android",
Expand Down
7 changes: 3 additions & 4 deletions examples/basicapp/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ local_repository(
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
rules_android_prereqs()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()

Expand All @@ -19,10 +22,6 @@ compatibility_proxy_repo()
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
rules_java_dependencies()

# note that the following line is what is minimally required from protobuf for the java rules
# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl
load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility
proto_bazel_features(name = "proto_bazel_features")
# register toolchains
load("@rules_java//java:repositories.bzl", "rules_java_toolchains")
rules_java_toolchains()
Expand Down
4 changes: 2 additions & 2 deletions prereqs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def rules_android_prereqs(dev_mode = False):
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),
)

PROTOBUF_VERSION = "33.1"
PROTOBUF_HASH = "fda132cb0c86400381c0af1fe98bd0f775cb566cb247cdcc105e344e00acc30e"
PROTOBUF_VERSION = "33.4"
PROTOBUF_HASH = "bc670a4e34992c175137ddda24e76562bb928f849d712a0e3c2fb2e19249bea1"
maybe(
http_archive,
name = "com_google_protobuf",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/java/com/google/devtools/build/android/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ java_library(
"@rules_android_maven//:com_google_code_findbugs_jsr305",
"@rules_android_maven//:com_google_errorprone_error_prone_annotations",
"@rules_android_maven//:com_google_guava_guava",
"@rules_android_maven//:com_google_protobuf_protobuf_java",
"@com_google_protobuf//java/core",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need protobuf in the Maven deps if you're replacing their references with @com_google_protobuf?

":android_common_30_1_3",
":android_databinding_wrapper_lib",
":android_options_utils",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ java_library(
"@rules_android_maven//:com_google_code_findbugs_jsr305",
"@rules_android_maven//:com_google_errorprone_error_prone_annotations",
"@rules_android_maven//:com_google_guava_guava",
"@rules_android_maven//:com_google_protobuf_protobuf_java",
"@com_google_protobuf//java/core",
"@rules_android_maven//:org_ow2_asm_asm",
"@rules_android_maven//:org_ow2_asm_asm_commons",
"@rules_android_maven//:org_ow2_asm_asm_tree",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Protos of the Actions for Android rules.

load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")

package(default_visibility = ["//visibility:public"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ java_library(
srcs = glob(["*.java"]),
deps = [
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_protobuf_protobuf_java",
"@rules_android_maven//:com_google_protobuf_protobuf_java_util",
"@com_google_protobuf//java/core",
"@com_google_protobuf//java/util",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ java_library(
"//src/tools/java/com/google/devtools/build/android/sandboxedsdktoolbox/mixin",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_guava_guava",
"@rules_android_maven//:com_google_protobuf_protobuf_java",
"@com_google_protobuf//java/core",
"@rules_android_maven//:info_picocli_picocli",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ java_library(
"//src/tools/java/com/google/devtools/build/android/sandboxedsdktoolbox/mixin",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_guava_guava",
"@rules_android_maven//:com_google_protobuf_protobuf_java",
"@rules_android_maven//:com_google_protobuf_protobuf_java_util",
"@com_google_protobuf//java/core",
"@com_google_protobuf//java/util",
"@rules_android_maven//:info_picocli_picocli",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ java_test(
deps = [
"//src/tools/javatests/com/google/devtools/build/android/sandboxedsdktoolbox/utils",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_protobuf_protobuf_java_util",
"@com_google_protobuf//java/util",
"@rules_android_maven//:com_google_truth_truth",
"@rules_android_maven//:junit_junit",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ java_test(
"//src/tools/javatests/com/google/devtools/build/android/sandboxedsdktoolbox/utils",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_guava_guava",
"@rules_android_maven//:com_google_protobuf_protobuf_java",
"@com_google_protobuf//java/core",
"@rules_android_maven//:com_google_truth_truth",
"@rules_android_maven//:junit_junit",
],
Expand All @@ -31,7 +31,7 @@ java_test(
"//src/tools/javatests/com/google/devtools/build/android/sandboxedsdktoolbox/utils",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_guava_guava",
"@rules_android_maven//:com_google_protobuf_protobuf_java_util",
"@com_google_protobuf//java/util",
"@rules_android_maven//:com_google_truth_truth",
"@rules_android_maven//:junit_junit",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ java_test(
deps = [
"//src/tools/javatests/com/google/devtools/build/android/sandboxedsdktoolbox/utils",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_protobuf_protobuf_java_util",
"@com_google_protobuf//java/util",
"@rules_android_maven//:com_google_truth_truth",
"@rules_android_maven//:junit_junit",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ java_test(
"//src/tools/javatests/com/google/devtools/build/android/sandboxedsdktoolbox/utils",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_guava_guava",
"@rules_android_maven//:com_google_protobuf_protobuf_java",
"@rules_android_maven//:com_google_protobuf_protobuf_java_util",
"@com_google_protobuf//java/core",
"@com_google_protobuf//java/util",
"@rules_android_maven//:com_google_truth_truth",
"@rules_android_maven//:junit_junit",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ java_test(
deps = [
"//src/tools/javatests/com/google/devtools/build/android/sandboxedsdktoolbox/utils",
"@rules_android_maven//:com_android_tools_build_bundletool",
"@rules_android_maven//:com_google_protobuf_protobuf_java_util",
"@com_google_protobuf//java/util",
"@rules_android_maven//:com_google_truth_truth",
"@rules_android_maven//:junit_junit",
],
Expand Down