GithubHelp home page GithubHelp logo

Comments (6)

johnynek avatar johnynek commented on June 15, 2024

can you give some links here? There are plugins for the scala compiler you mean?

from rules_scala.

johnynek avatar johnynek commented on June 15, 2024

can't you use scalaopts https://github.com/bazelbuild/rules_scala/blob/master/scala/scala.bzl#L274

and pass -Psomeplugin:opts?

from rules_scala.

smparkes avatar smparkes commented on June 15, 2024

http://bazel.io/docs/be/java.html#java_plugin
https://github.com/google/auto/tree/master/service

It's actually java annotation processing. And, yeah, scala and java have different concepts of annotation plugins.

In this particular case, I think it'd be possible to add a javac step to make things work though that won't work for other annotation processors / plugins.

I might be able to play with this in a couple of weeks ...

from rules_scala.

johnynek avatar johnynek commented on June 15, 2024

from what I can see, those have to be applied with javac. I guess if you have the annotation in scope when you compile, scalac won't complain, then you need a step where javac is called on the resulting jar with the plugin and I guess a new jar is produced?

from rules_scala.

smparkes avatar smparkes commented on June 15, 2024

Okay, I've looked into this a bit more. I created this issue before I really understood how JSR 269 annotation processing works.

It is possible to do this, along the lines of what you mention: the only diff is you have to explode the jar and pass all the classes to javac, along with -proc:only, rather than pass in the intact jar.

But that seems like it's going too far. This isn't a bazel issue, it's a java vs. scala issue. And if we did this, it would only work for this one kind of annotation processing, since arbitrary JSR 269 annotation processors can do things that wouldn't work for this.

I think the right answer is to just create a native java class. In my case, I just extend a scala class, e.g.,

@AutoService(Configurator.class)
public class JavaLogbackConfigurator extends LogbackConfigurator {}

This seems like a perfectly reasonable approach.

It's a little kludgy right now since we have to do the java_import trampoline to get scala libraries into java builds but there's another issue for that ...

from rules_scala.

johnynek avatar johnynek commented on June 15, 2024

ok. So this adds to the need to solve #18

from rules_scala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.