Skip to content

Commit 49fae27

Browse files
author
Stephen Twigg
committed
Using JavaProvider, requires Bazel 0.5.2
Remove scala_exports_to_java Prefer using JavaProvider over scala provider (can probably avoid using scala provider completely?)
1 parent 697f23a commit 49fae27

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

scala/scala.bzl

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,9 @@ def _collect_jars(targets):
358358
compile_jars = depset()
359359
runtime_jars = depset()
360360
for target in targets:
361-
if hasattr(target, "scala"):
362-
compile_jars += target.scala.compile_jars
363-
runtime_jars += target.scala.transitive_runtime_jars
364-
elif java_common.provider in target:
361+
if java_common.provider in target:
365362
java_provider = target[java_common.provider]
366-
# TODO(twigg): Use compile_jars when released (narrowly missed 0.5.0 :( )
367-
compile_jars += target.java.transitive_deps # java_provider.compile_jars
363+
compile_jars += java_provider.compile_jars
368364
runtime_jars += java_provider.transitive_runtime_jars
369365
else:
370366
# support http_file pointed at a jar. http_jar uses ijar,
@@ -432,10 +428,9 @@ def _lib(ctx, non_macro_lib):
432428
compile_jars = next_cjars,
433429
transitive_runtime_jars = transitive_rjars,
434430
)
435-
# TODO(twigg): Linearization is concerning here.
436431
java_provider = java_common.create_provider(
437-
compile_time_jars = scalaattr.compile_jars.to_list(),
438-
runtime_jars = scalaattr.transitive_runtime_jars.to_list(),
432+
compile_time_jars = scalaattr.compile_jars,
433+
runtime_jars = scalaattr.transitive_runtime_jars,
439434
)
440435

441436
return struct(
@@ -802,20 +797,6 @@ def scala_repositories():
802797

803798
native.bind(name = "io_bazel_rules_scala/dependency/scalatest/scalatest", actual = "@scalatest//jar")
804799

805-
# With providers changes, this is completely deprecatable once bazel release includes
806-
# fixes to java rules using JavaProvider
807-
def scala_export_to_java(name, exports, runtime_deps):
808-
jars = []
809-
for target in exports:
810-
jars.append("{}_deploy.jar".format(target))
811-
812-
native.java_import(
813-
name = name,
814-
# these are the outputs of the scala_library targets
815-
jars = jars,
816-
runtime_deps = ["//external:io_bazel_rules_scala/dependency/scala/scala_library"] + runtime_deps
817-
)
818-
819800
def _sanitize_string_for_usage(s):
820801
res_array = []
821802
for c in s:

test/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ load("//scala:scala.bzl",
55
"scala_library",
66
"scala_test",
77
"scala_macro_library",
8-
"scala_export_to_java",
98
"scala_repl",
109
"scala_test_suite",
1110
"scala_library_suite",

twitter_scrooge/twitter_scrooge.bzl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _gen_scrooge_srcjar_impl(ctx):
153153
arguments=["--jvm_flag=%s" % flag for flag in ctx.attr.jvm_flags] + ["@" + argfile.path],
154154
)
155155

156-
deps_jars = _collect_scalaattr(ctx.attr.deps)
156+
deps_jars = _collect_jars(ctx.attr.deps)
157157

158158
scalaattr = struct(
159159
outputs = None,
@@ -177,15 +177,16 @@ def _gen_scrooge_srcjar_impl(ctx):
177177
)],
178178
)
179179

180-
# TODO(twigg): Use one in scala.bzl ...
181-
def _collect_scalaattr(targets):
180+
# TODO(twigg): Use the one in scala.bzl?
181+
def _collect_jars(targets):
182182
compile_jars = depset()
183183
transitive_runtime_jars = depset()
184184

185185
for target in targets:
186-
if hasattr(target, "scala"):
187-
compile_jars += target.scala.compile_jars
188-
transitive_runtime_jars += target.scala.transitive_runtime_jars
186+
if java_common.provider in target:
187+
java_provider = target[java_common.provider]
188+
compile_jars += java_provider.compile_jars
189+
transitive_runtime_jars += java_provider.transitive_runtime_jars
189190

190191
return struct(
191192
compile_jars = compile_jars,

0 commit comments

Comments
 (0)