bazel-contrib / bazel-contrib/rules_jvm
Having a rule with a `plugin` defined, but not using a valid `#gazelle:java_annotation_processor_plugin` deletes the plugin
- Dominant language
- Go
- Stars
- 54
- Forks
- 98
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 7
Description
I copied the `java/gazelle/testdata/annotation_processor` directory to a `java/gazelle/testdata/plugins` directory, then replaced the contents of `BUILD.in` with the following. Note, we've deleted the existing `# gazelle:java_annotation_processor_plugin` from the `BUILD.in`
```
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
java_library(
name = "example",
srcs = ["Main.java"],
plugins = ["@maven//:com_google_auto_value_auto_value__java_plugin__com_google_auto_value_processor_AutoValueProcessor"],
visibility = ["//:__subpackages__"],
deps = ["@maven//:com_google_auto_value_auto_value_annotations"],
)
java_binary(
name = "Main",
main_class = "com.example.Main",
visibility = ["//visibility:public"],
runtime_deps = [":example"],
)
```
then run `bazel test //java/gazelle/testdata:plugins`
The test fails, where one of the changes is the `plugins` from the `java_library` has been removed entirely. This behavior starts in release 0.30.0, and has been tested in main with the same results.
What should happen: The `plugin` attribute should be unchanged.
Contributor guide
Research direction
Start by comparing java/gazelle/testdata/annotation_processor with the copied plugins testdata and its BUILD.in, then run bazel test //java/gazelle/testdata:plugins to reproduce the removed plugins attribute. Trace the Gazelle processing entry point responsible for java_library plugins. Done means a rule with an invalid or absent java_annotation_processor_plugin directive preserves its plugins attribute.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100