-
Notifications
You must be signed in to change notification settings - Fork 280
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
Add SemanticDB support #1329
Add SemanticDB support #1329
Conversation
I'm opening this PR as a draft because it's not working correctly yet. I'm hitting on the following error that I don't understand:
Any advice on how to debug that? |
It's probably bootstrapping problem (can't build rules scala targets before rules scala is built). You can try doing similar thing like dependecy analyzer does using
|
A few questions:
Thanks for the effort, @olafurpg! |
@liucijus Thank you for taking a look 🙏 I'll investigate
My eventual hope is that we can add dedicated
Scala 3 has built-in support for SemanticDB with the
Good question. It should be as long as the typechecked Scala trees are reproducible (it's a bug otherwise). If you call a macro that generates non-reproducible output then the generated SemanticDB might also have minor deviations between compilations. |
We can get this working by checking Scala version in Bazel macros, like here: https://github.com/bazelbuild/rules_scala/blob/master/third_party/dependency_analyzer/src/main/BUILD#L25 |
Will having a separate target for SemanticDB output require running scalac again? I guess a configurable phase is more flexible approach as it allows to opt in features in In Bazel builds output needed by tools is usually generated using aspects. But I'm not sure if this can work with plugins, but would be a good area to research as it would be idiomatic approach. |
We must be very careful here |
I have a modified version of this PR that works (writes semanticdb output to bazel-bin) here: https://github.com/ThriveFinancial/rules_scala/tree/mpeterson/semanticdb |
hey @ricochet1k @olafurpg do either of you have plans to continue working on this? i tested out @ricochet1k's changes and they seemed to work for me - maybe we aren't too far from productionizing this as a feature, i'd be happy to pitch in as well |
This ticket can probably be closed. SemanticDB support was added in #1508 |
Description
This PR adds an flag to enable the SemanticDB compiler plugin during Scala compilation.
The SemanticDB compiler adds overhead to compilation so it should be disabled by default. The goal of this PR is to make it easy for users to dynamically enable SemanticDB in certain environments like CI via Bazel config options or system environment variables.
Motivation
SemanticDB is used by several tools like Scalafix and Metals so it would be nice to have this functionality included out-of-the-box with rules_scala. Example use-cases include