Skip to content
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 scala/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ toolchain_type(
scala_toolchain(
name = 'default_toolchain_impl',
scalacopts = [],
library = "//external:io_bazel_rules_scala/dependency/scala/scala_library",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this is the way to go? If I understand it correctly this still requires me to change the scala.bzl#scala_repositories method to download 2.12.

compiler = "//external:io_bazel_rules_scala/dependency/scala/scala_compiler",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using //external: dependencies instead of @io_bazel_rules_scala//dependency/scala/scala_compiler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make a more minimal change. Before toolchains, we only had bind as a tool that downstream repos could set these values and there are many interchangeable versions that work.

reflect = "//external:io_bazel_rules_scala/dependency/scala/scala_reflect",
visibility = ["//visibility:public"]
)

Expand Down
9 changes: 4 additions & 5 deletions scala/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,8 @@ def _collect_jars_from_common_ctx(ctx, extra_deps = [], extra_runtime_deps = [])
dependency_analyzer_is_off = is_dependency_analyzer_off(ctx)

# Get jars from deps
auto_deps = [ctx.attr._scalalib, ctx.attr._scalareflect]
toolchain = ctx.toolchains['@io_bazel_rules_scala//scala:toolchain_type']
auto_deps = [toolchain.library, toolchain.reflect]
deps_jars = collect_jars(ctx.attr.deps + auto_deps + extra_deps, dependency_analyzer_is_off)
(cjars, transitive_rjars, jars2labels, transitive_compile_jars) = (deps_jars.compile_jars, deps_jars.transitive_runtime_jars, deps_jars.jars2labels, deps_jars.transitive_compile_jars)

Expand Down Expand Up @@ -768,7 +769,8 @@ def _scala_binary_impl(ctx):

def _scala_repl_impl(ctx):
# need scala-compiler for MainGenericRunner below
jars = _collect_jars_from_common_ctx(ctx, extra_runtime_deps = [ctx.attr._scalacompiler])
toolchain = ctx.toolchains['@io_bazel_rules_scala//scala:toolchain_type']
jars = _collect_jars_from_common_ctx(ctx, extra_runtime_deps = [toolchain.compiler])
(cjars, transitive_rjars) = (jars.compile_jars, jars.transitive_runtime_jars)

out = _scala_binary_common(ctx, cjars, transitive_rjars, jars.transitive_compile_jars, jars.jars2labels)
Expand Down Expand Up @@ -886,9 +888,6 @@ _implicit_deps = {
"_singlejar": attr.label(executable=True, cfg="host", default=Label("@bazel_tools//tools/jdk:singlejar"), allow_files=True),
"_ijar": attr.label(executable=True, cfg="host", default=Label("@bazel_tools//tools/jdk:ijar"), allow_files=True),
"_scalac": attr.label(executable=True, cfg="host", default=Label("//src/java/io/bazel/rulesscala/scalac"), allow_files=True),
"_scalalib": attr.label(default=Label("//external:io_bazel_rules_scala/dependency/scala/scala_library"), allow_files=True),
"_scalacompiler": attr.label(default=Label("//external:io_bazel_rules_scala/dependency/scala/scala_compiler"), allow_files=True),
"_scalareflect": attr.label(default=Label("//external:io_bazel_rules_scala/dependency/scala/scala_reflect"), allow_files=True),
"_java": attr.label(executable=True, cfg="host", default=Label("@bazel_tools//tools/jdk:java"), allow_files=True),
"_zipper": attr.label(executable=True, cfg="host", default=Label("@bazel_tools//tools/zip:zipper"), allow_files=True),
"_java_toolchain": attr.label(default = Label("@bazel_tools//tools/jdk:current_java_toolchain")),
Expand Down
8 changes: 7 additions & 1 deletion scala/scala_toolchain.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
def _scala_toolchain_impl(ctx):
toolchain = platform_common.ToolchainInfo(
scalacopts = ctx.attr.scalacopts,
library = ctx.attr.library,
compiler = ctx.attr.compiler,
reflect = ctx.attr.reflect,
)
return [toolchain]

scala_toolchain = rule(
_scala_toolchain_impl,
attrs = {
'scalacopts': attr.string_list(),
'library': attr.label(allow_files=True),
'compiler': attr.label(allow_files=True),
'reflect': attr.label(allow_files=True),
}
)
)
4 changes: 1 addition & 3 deletions specs2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ java_import(
"@io_bazel_rules_scala_org_scalaz_scalaz_core//jar",
],
deps = [
"//external:io_bazel_rules_scala/dependency/scala/scala_xml",
"//external:io_bazel_rules_scala/dependency/scala/parser_combinators",
"//external:io_bazel_rules_scala/dependency/scala/scala_library",
"//external:io_bazel_rules_scala/dependency/scala/scala_reflect"
"//external:io_bazel_rules_scala/dependency/scala/scala_xml",
]
)
2 changes: 0 additions & 2 deletions test/aspect/aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def _rule_impl(ctx):
"@io_bazel_rules_scala//specs2:specs2",
"@scala//:scala-xml",
"@scala//:scala-parser-combinators",
"@scala//:scala-library",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chaoren does this mandate changes in the plugin? So that it will take these dependencies from the toolchain?

"@scala//:scala-reflect",
# From specs2/specs2_junit.bzl:specs2_junit_dependencies()
"@io_bazel_rules_scala_org_specs2_specs2_junit_2_11//jar:jar",
],
Expand Down