-
Notifications
You must be signed in to change notification settings - Fork 281
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
SemanticDB phases #952
Comments
Sounds good. |
Also if this is about metals then does this relate / duplicate #915 ? |
It's related in the sense that bloop uses SemanticDB, but this serves a different purpose: prebuilding SemanticDB files for large repos in the CI build. |
For what purpose? Asking out of curiosity of course as I’m not that familiar with SemanticDB itself. |
There's probably lots of possibilities from a tooling perspective, but one concrete thing I can think of is enabling us to apply tools like Scalafix. |
How I solved this (without direct rules_scala support):
semanticdb = "@maven//:org_scalameta_semanticdb_scalac_%s" % scala_version_suffix
semanticdb_scalaopts = [
"-Xplugin:$(location %s)" % semanticdb,
"-Yrangepos",
]
semanticdb_deps = [
semanticdb,
]
compiler_deps = semanticdb_deps
# Ensure your deps provider for the scala compiler includes the compiler deps:
declare_deps_provider(
name = "my_scala_compile_classpath_provider",
deps_id = "scala_compile_classpath",
visibility = ["//visibility:public"],
deps = [
"@maven//:org_scala_lang_scala_compiler",
"@maven//:org_scala_lang_scala_library",
"@maven//:org_scala_lang_scala_reflect",
] + compiler_deps,
)
# In your targets ensure to provide scalaopts and deps:
scala_library(
# ...
scalacopts = semanticdb_scalaopts,
deps = semanticdb_deps,
) As an extra detail, how I managed to use Scalafix after the above was applied: # Install coursier (`cs`) with whatever method.
# Install scalafix:
cs install scalafix
scalafix --version
# I wanted to use ZIO scalafix rules, so download and build ZIO scalafix rules:
git clone https://github.com/zio/zio/
cd zio
sbt scalafixRules/publishLocal
# In your repo:
# Build a deploy jar:
bazel build //some/custom/path:library_deploy.jar
# Run scalafix:
scalafix --tool-classpath $HOME/.ivy2/local/dev.zio/scalafixrules_2.13/2.0.5+38-7efadb73-SNAPSHOT/jars/scalafixrules_2.13.jar --rules Zio2Upgrade --files some/custom/path/src/main/scala/ --classpath bazel-bin/some/custom/path/library_deploy.jar |
This issue can probably be closed now. SemanticDB support was added in #1508 |
Stripe's Scala team has an intern, and this quarter we're planning work that requires SemanticDB outputs!
I believe SemanticDB support can be easily encapsulated in a new optional phase that:
This pattern was already prototyped in higherkindness/rules_scala, so I'm confident that it will work here too.
We'll circle back soon with an update once we can commit to this work.
The text was updated successfully, but these errors were encountered: