rules_scala icon indicating copy to clipboard operation
rules_scala copied to clipboard

support for java_plugins within scala_library rules

Open softprops opened this issue 8 years ago • 11 comments
trafficstars

The built in java_library rule has support for java_plugins by way of the plugins attribute. scala_library also has a plugins attribute but I believe its only intended for scalac plugins, as one would expect.

Since the scala rules support compiling both java and scala sources, has anyone here had experience with integrating java a annotation processor with scala rules. If not, does anyone here have pointers on where to look?

softprops avatar Oct 10 '17 17:10 softprops

I have never done this. I know nothing about it.

johnynek avatar Oct 10 '17 17:10 johnynek

Lol. I'll poke around the community.

softprops avatar Oct 10 '17 17:10 softprops

Haven't been keeping a close eye on recent changes but it looks like javac is now invoked by the new java_common.compile api here (which is neat!). It looks like there's an interface for threading through javac plugins to the new common compile interface here but the 'plugins' argument isn't provided by the scala rules. I guess there'd need to be some way to capture that in thread it all the way through.

softprops avatar Oct 10 '17 17:10 softprops

Sounds like it's simple a matter of adding another attribute (javac_plugins?) and passing it around. Note that currently you should probably support both strict deps off (default) and strict deps on since we're working hard on ironing the strict deps issues to make it the default and only one. You can see many examples in the e2e for reference.

On Tue, Oct 10, 2017 at 8:32 PM doug tangren [email protected] wrote:

Haven't been keeping a close eye on recent changes but it looks like javac is now invoked by the new java_common.compile api here https://github.com/bazelbuild/rules_scala/blob/master/scala/scala.bzl#L303 (which is neat!). It looks like there's an interface for threading through javac plugins to the new common compile interface here https://docs.bazel.build/versions/master/skylark/lib/java_common.html#compile but the 'plugins' argument isn't provided by the scala rules. I guess there'd need to be some way to capture that in thread it all the way through.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/rules_scala/issues/299#issuecomment-335549409, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUIF61pQaNUBbq-ZZ0GcCy0QliwlxCBks5sq6oqgaJpZM4P0Rbn .

ittaiz avatar Oct 10 '17 18:10 ittaiz

Sounds like it's simple a matter of adding another attribute (javac_plugins?) and passing it around

That'd be my guess.

I found another way to accomplish what I was trying to do so feel free to close this if you'd like. It may be helpful to leave it open as a trail for others to find if they run into a similar situation. I think adding and forwarding along javac_plugins could make for a nice beginner contributor task.

softprops avatar Oct 10 '17 18:10 softprops

I'm good with keeping this open and we indeed want to have a much parity as we can with the java rules. Can you share how you solved your problem in case it will help others coming here?

On Tue, Oct 10, 2017 at 9:10 PM doug tangren [email protected] wrote:

Sounds like it's simple a matter of adding another attribute (javac_plugins?) and passing it around

That'd be my guess.

I found another way to accomplish what I was trying to do so feel free to close this if you'd like. It may be helpful to leave it open as a trail for others to find if they run into a similar situation. I think adding and forwarding along javac_plugins could make for a nice beginner contributor task.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/bazelbuild/rules_scala/issues/299#issuecomment-335560268, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUIF8nT54Q_wEem2Bowm9ZLYQ-OY9-vks5sq7MogaJpZM4P0Rbn .

ittaiz avatar Oct 10 '17 18:10 ittaiz

@softprops What was the workaround you tried ?

subramaniamr avatar Aug 01 '18 08:08 subramaniamr

I punted for now

softprops avatar Aug 07 '18 03:08 softprops

@subramaniamr the feature really looks simple to implement (mainly need an example of a plugin for the test). As we said before it's about adding another attribute of java_plugins (default value of empty) and passing it to java_common.compile call (it doesn't pass it today which defaults to empty). Production code wise we're talking about a few lines of code to change. Any chance you're willing to send a PR for this?

ittaiz avatar Aug 07 '18 05:08 ittaiz

I have a local version of the 'javac_plugins' working, will submit a PR , once we figure out our Corp policy for contributing back.

rahul-nitkkr avatar Aug 07 '18 10:08 rahul-nitkkr

is there any way now to use java_plugins with scala_library?

kusaeva avatar Apr 30 '25 10:04 kusaeva