Skip to content

Commit 6971eb5

Browse files
Chang-EricDagger Team
authored andcommitted
Add a processor_compat.bzl helper macro
RELNOTES=n/a PiperOrigin-RevId: 746223546
1 parent b3cb10f commit 6971eb5

5 files changed

Lines changed: 37 additions & 9 deletions

File tree

hilt-android-testing/main/java/dagger/hilt/android/testing/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ android_library(
4242
testonly = 1,
4343
srcs = ["HiltAndroidTest.java"],
4444
exported_plugins = [
45-
"//hilt-compiler/main/java/dagger/hilt/processor/internal/root:component_tree_deps_plugin",
45+
"//hilt-compiler/main/java/dagger/hilt/processor/internal/root:component_tree_deps_processor",
4646
"//hilt-compiler/main/java/dagger/hilt/processor/internal/root:root_plugin",
4747
"//hilt-compiler/main/java/dagger/hilt/android/processor/internal/androidentrypoint:plugin",
4848
"//hilt-compiler/main/java/dagger/hilt/android/processor/internal/viewmodel:validation_plugin",

hilt-android/main/java/dagger/hilt/android/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ android_library(
6666
exported_plugins = [
6767
"//hilt-compiler/main/java/dagger/hilt/android/processor/internal/androidentrypoint:plugin",
6868
"//hilt-compiler/main/java/dagger/hilt/android/processor/internal/viewmodel:validation_plugin",
69-
"//hilt-compiler/main/java/dagger/hilt/processor/internal/root:component_tree_deps_plugin",
69+
"//hilt-compiler/main/java/dagger/hilt/processor/internal/root:component_tree_deps_processor",
7070
"//hilt-compiler/main/java/dagger/hilt/processor/internal/root:root_plugin",
7171
],
7272
exports = [

hilt-compiler/main/java/dagger/hilt/processor/internal/root/BUILD

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
# Annotation processor for Hilt.
1717

1818
load("@rules_java//java:defs.bzl", "java_library", "java_plugin")
19+
load("//tools:processor_compat.bzl", "compat_processor_plugin")
1920

2021
package(default_visibility = ["//:src"])
2122

22-
java_plugin(
23-
name = "component_tree_deps_plugin",
23+
compat_processor_plugin(
24+
name = "component_tree_deps_processor",
2425
generates_api = 1,
25-
processor_class = "dagger.hilt.processor.internal.root.ComponentTreeDepsProcessor",
26-
deps = [
27-
":component_tree_deps_processor_lib",
28-
],
26+
processor_base_name = "ComponentTreeDeps",
27+
processor_lib_dep = ":component_tree_deps_processor_lib",
2928
)
3029

3130
java_library(

tools/bazel_compat.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 202 The Dagger Authors.
1+
# Copyright (C) 2025 The Dagger Authors.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

tools/processor_compat.bzl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (C) 2025 The Dagger Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Description:
16+
# Macros for processor plugins.
17+
18+
load("@rules_java//java:defs.bzl", "java_plugin")
19+
20+
def compat_processor_plugin(name, processor_base_name, processor_lib_dep, generates_api = False):
21+
pkgs = native.package_name().split("/")
22+
pkg = ".".join(pkgs[pkgs.index("java") + 1:])
23+
24+
java_plugin(
25+
name = name,
26+
generates_api = generates_api,
27+
processor_class = pkg + "." + processor_base_name + "Processor",
28+
deps = [processor_lib_dep],
29+
)

0 commit comments

Comments
 (0)