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

Add SemanticDB support #1329

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ specs2_junit_repositories()
register_toolchains("//testing:testing_toolchain")

load("//scala/scalafmt:scalafmt_repositories.bzl", "scalafmt_default_config", "scalafmt_repositories")
load("//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories")

scalafmt_default_config()

scalafmt_repositories()

semanticdb_repositories()

MAVEN_SERVER_URLS = default_maven_server_urls()

# needed for the cross repo proto test
Expand Down
4 changes: 4 additions & 0 deletions examples/testing/scalatest_repositories/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "
scalatest_repositories()

scalatest_toolchain()

load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories")

semanticdb_repositories()
7 changes: 7 additions & 0 deletions scala/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ declare_deps_provider(
visibility = ["//visibility:public"],
deps = ["@io_bazel_rules_scala_scala_parser_combinators"],
)

declare_deps_provider(
name = "semanticdb_scalac_provider",
deps_id = "semanticdb_scalac",
visibility = ["//visibility:public"],
deps = ["@org_scalameta_semanticdb_scalac"],
)
5 changes: 5 additions & 0 deletions scala/private/common_attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ common_attrs.update({
"_dependency_analyzer_plugin": attr.label(
default = Label(
"@io_bazel_rules_scala//third_party/dependency_analyzer/src/main:dependency_analyzer",
), allow_files = [".jar"], mandatory = False,
),
"_semanticdb_scalac_plugin": attr.label(
default = Label(
"@io_bazel_rules_scala//scala/private/toolchain_deps:semanticdb_scalac",
),
allow_files = [".jar"],
mandatory = False,
Expand Down
1 change: 1 addition & 0 deletions scala/private/dependency.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def new_dependency_info(
unused_deps_mode = unused_deps_mode,
strict_deps_mode = strict_deps_mode,
use_analyzer = is_strict_deps_on or is_unused_deps_on,
use_semanticdb_scalac = True,
)

# TODO(https://github.com/bazelbuild/rules_scala/issues/987): Clariy the situation
Expand Down
2 changes: 2 additions & 0 deletions scala/private/rule_impls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def compile_scala(
plugins = _collect_plugin_paths(plugins)
if dependency_info.use_analyzer:
plugins = depset(transitive = [plugins, ctx.attr._dependency_analyzer_plugin.files])
if dependency_info.use_semanticdb_scalac and False:
plugins = depset(transitive = [plugins, ctx.attr._semanticdb_scalac_plugin.files])

toolchain = ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"]
compiler_classpath_jars = cjars if dependency_info.dependency_mode == "direct" else transitive_compile_jars
Expand Down
6 changes: 6 additions & 0 deletions scala/private/toolchain_deps/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ common_toolchain_deps(
deps_id = "parser_combinators",
visibility = ["//visibility:public"],
)

common_toolchain_deps(
name = "semanticdb_scalac",
deps_id = "semanticdb_scalac",
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions scala/scala_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ scala_toolchain = rule(
"scalacopts": attr.string_list(),
"dep_providers": attr.label_list(
default = [
"@io_bazel_rules_scala//scala:semanticdb_scalac_provider",
"@io_bazel_rules_scala//scala:scala_xml_provider",
"@io_bazel_rules_scala//scala:parser_combinators_provider",
"@io_bazel_rules_scala//scala:scala_compile_classpath_provider",
Expand Down
Empty file added scala/semanticdb/BUILD
Empty file.
16 changes: 16 additions & 0 deletions scala/semanticdb/semanticdb_repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load(
"//scala:scala_cross_version.bzl",
_default_maven_server_urls = "default_maven_server_urls",
)
load("//third_party/repositories:repositories.bzl", "repositories")


def semanticdb_repositories(
maven_servers = _default_maven_server_urls(),
overriden_artifacts = {}):
repositories(
for_artifact_ids = ["org_scalameta_semanticdb_scalac"],
maven_servers = maven_servers,
fetch_sources = False,
overriden_artifacts = overriden_artifacts,
)
4 changes: 4 additions & 0 deletions third_party/repositories/scala_2_11.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ artifacts = {
"@io_bazel_rules_scala_scala_library",
],
},
"org_scalameta_semanticdb_scalac": {
"artifact": "org.scalameta:semanticdb-scalac_2.11.12:4.4.31",
"sha256": "d61eb07ff182173c8b30b7caa4bba2bd04fd2c921552ad1c550073f1f0262ed7",
},
"org_scalameta_fastparse": {
"artifact": "org.scalameta:fastparse_2.11:1.0.1",
"sha256": "49ecc30a4b47efc0038099da0c97515cf8f754ea631ea9f9935b36ca7d41b733",
Expand Down
4 changes: 4 additions & 0 deletions third_party/repositories/scala_2_12.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ artifacts = {
"@io_bazel_rules_scala_scala_library",
],
},
"org_scalameta_semanticdb_scalac": {
"artifact": "org.scalameta:semanticdb-scalac_2.12.14:4.4.31",
"sha256": "8a6d71f1611ede0fdc435a851fdd67ccb64c68b80b2153fce4a389eb33ed7416",
},
"org_scalameta_fastparse": {
"artifact": "org.scalameta:fastparse_2.12:1.0.1",
"sha256": "387ced762e93915c5f87fed59d8453e404273f49f812d413405696ce20273aa5",
Expand Down
4 changes: 4 additions & 0 deletions third_party/repositories/scala_2_13.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ artifacts = {
"@io_bazel_rules_scala_scala_library",
],
},
"org_scalameta_semanticdb_scalac": {
"artifact": "org.scalameta:semanticdb-scalac_2.13.6:4.4.31",
"sha256": "09f270c275701cfba93620ddd5c0b287a5c123cf528e837c518d5b5dd85efff0",
},
"org_scalameta_fastparse": {
"artifact": "org.scalameta:fastparse_2.13:1.0.1",
"sha256": "b43b99244d5b51948daf1467083b3850dc2727c604de98dc426dec14244fd18e",
Expand Down