Skip to content
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

Support annotation processors #62

Closed
cgrushko opened this issue Aug 30, 2017 · 4 comments
Closed

Support annotation processors #62

cgrushko opened this issue Aug 30, 2017 · 4 comments

Comments

@cgrushko
Copy link
Contributor

For example, auto_value needs to run an annotation processor as part of a build.

The BUILD file that bazel-deps produces for auto-value is something like:

java_library(
    name = "auto_value",
    visibility = [
        "//visibility:public",
    ],
    exports = [
        "//external:jar/com/google/auto/value/auto_value",
    ],
)

In order to support annotation processing, one needs to change it to

java_library(
    name = "auto_value",
    exported_plugins = [
        ":auto_value_plugin",
    ],
    visibility = [
        "//visibility:public",
    ],
    exports = [
        "//external:jar/com/google/auto/value/auto_value",
    ],
)

java_plugin(
    name = "auto_value_plugin",
    processor_class = "com.google.auto.value.processor.AutoValueProcessor",
    deps = [
        "//external:jar/com/google/auto/value/auto_value",
    ],
)

Note the exported_plugins and processor_class attributes.

Proposal:
A dependencies entry in the yaml file will contain a field named processor_class. When it's present, bazel-deps will create a BUILD file similar to the example above.

@johnynek
Copy link
Collaborator

johnynek commented Sep 1, 2017

this proposal seems fine to me. Want to start a PR?

@cgrushko
Copy link
Contributor Author

cgrushko commented Sep 1, 2017

Sure. Can you give me code pointers? Where to start modifying?

greggdonovan added a commit to greggdonovan/BUILD_file_generator that referenced this issue Oct 31, 2017
greggdonovan added a commit to greggdonovan/bazel-deps that referenced this issue Nov 2, 2017
greggdonovan added a commit to greggdonovan/bazel-deps that referenced this issue Nov 2, 2017
johnynek pushed a commit that referenced this issue Nov 10, 2017
* First try supporting annotation processors.

See discussion in #62

* - `java_plugin` visibility should be public
- use the fully qualified class name in the `java_plugin` label for uniqueness if there are more than one `annotationProcessors` defined.
- sort to `annotationProcessors` by class name to ensure the output is stable
- use a for/yield in getProcessorClasses

* Remove unused `show` parameter.

* Generate synthetic class names for annotation processors.
@greggdonovan
Copy link
Contributor

Thanks! We can close this now that #93 is merged.

greggdonovan added a commit to greggdonovan/BUILD_file_generator that referenced this issue Nov 12, 2017
…tation processors.

We can remove the buildozer rules we were using to work around this. The PR for bazeltools/bazel-deps#62 has been merged.
@cgrushko
Copy link
Contributor Author

Niiiiice :D

greggdonovan added a commit to bazelbuild/BUILD_file_generator that referenced this issue Nov 12, 2017
…tation processors. (#31)

We can remove the buildozer rules we were using to work around this. The PR for bazeltools/bazel-deps#62 has been merged.
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

No branches or pull requests

3 participants