Skip to content

Propagate testonly attribute to generated plugins #1142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rdesgroppes
Copy link
Contributor

@rdesgroppes rdesgroppes commented May 16, 2024

"Generate java_plugin targets for annotation processors" (#1102) brought a much-appreciated improvement by synthesizing a frequently repeated pattern. However, it doesn't work for annotation processor-related artifacts whose testonly attribute is set to True:

ERROR: /path/to/external/maven/BUILD:12345:12: in java_plugin rule @@maven//:group_artifact__java_plugin__package_Class: non-test target '@@maven//:group_artifact__java_plugin__package_Class' depends on testonly target '@@maven//:group_artifact' and doesn't have testonly attribute set

The present change aims at covering the use case by taking a Java Microbenchmark Harness-based target as a practical example.

As a side note, one may run the example as follows:

bazel run //tests/integration/plugin_targets:ClassUsingTestOnlyAnnotationProcessor

or, without bzlmod:

bazel run --enable_bzlmod=false //tests/integration/plugin_targets:ClassUsingTestOnlyAnnotationProcessor

@rdesgroppes rdesgroppes force-pushed the regis/propagate-testonly-attribute-to-generated-plugins branch from c1e040b to 06ca170 Compare May 16, 2024 17:57
@rdesgroppes rdesgroppes force-pushed the regis/propagate-testonly-attribute-to-generated-plugins branch 5 times, most recently from 92eb596 to c85e899 Compare May 16, 2024 20:23
"Generate java_plugin targets for annotation processors" (bazel-contrib#1102) brought
a much-appreciated improvement by synthesizing a frequently repeated
pattern. However, it doesn't work for annotation processor-related
artifacts whose `testonly` attribute is set to `True`:
> ERROR: /path/to/external/maven/BUILD:12345:12: in java_plugin rule
> @@maven//:group_artifact__java_plugin__package_Class: non-test target
> '@@maven//:group_artifact__java_plugin__package_Class' depends on
> testonly target '@@maven//:group_artifact' and doesn't have testonly
> attribute set

The present change aims at covering the use case by taking a
[Java Microbenchmark Harness](https://github.com/openjdk/jmh)-based
target as a practical example.

As a side note, one may run the example as follows:
```shell
bazel run //tests/integration/plugin_targets:ClassUsingTestOnlyAnnotationProcessor
```
or, without `bzlmod`:
```shell
bazel run --enable_bzlmod=false //tests/integration/plugin_targets:ClassUsingTestOnlyAnnotationProcessor
```
@rdesgroppes rdesgroppes force-pushed the regis/propagate-testonly-attribute-to-generated-plugins branch from c85e899 to 5645664 Compare May 17, 2024 05:36
Copy link
Contributor

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

Thanks! This LGTM, but unfortunately I'm not an owner of the repo - hopefully someone else will come and approve/merge soon!

@jin jin merged commit d3af1e6 into bazel-contrib:master May 17, 2024
@rdesgroppes rdesgroppes deleted the regis/propagate-testonly-attribute-to-generated-plugins branch May 17, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants