Skip to content

Commit

Permalink
Updated the bazelbuild/rules_scala compatibility rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaden Peterson committed Aug 27, 2024
1 parent 0d588cd commit 5da6365
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 74 deletions.
7 changes: 1 addition & 6 deletions rules/rules_scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ emulate_rules_scala_repository = repository_rule(
implementation = _emulate_rules_scala_repository_impl,
)

def emulate_rules_scala(scala, scalatest, extra_deps = []):
native.bind(
name = "scala_annex/compat/rules_scala/scala",
actual = scala,
)

def emulate_rules_scala(scalatest, extra_deps = []):
native.bind(
name = "scala_annex/compat/rules_scala/extra_deps",
actual = "@io_bazel_rules_scala//scala:extra_deps",
Expand Down
139 changes: 72 additions & 67 deletions rules/rules_scala/private/compat.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ load(

_extra_deps = ["//external:scala_annex/compat/rules_scala/extra_deps"]

_scala = "//external:scala_annex/compat/rules_scala/scala"

_scalatest_deps = ["//external:scala_annex/compat/rules_scala/scalatest_dep"]

def scala_library(
Expand All @@ -33,20 +31,21 @@ def scala_library(
tags = [],
visibility = None,
# rules_scala common attributes
srcs = [],
deps = [],
plugins = [],
runtime_deps = [],
data = [],
resources = [],
resource_strip_prefix = None,
resource_jars = [],
scalacopts = [],
deps = [],
javac_jvm_flags = [],
javacopts = [],
jvm_flags = [],
scalac_jvm_flags = [],
javac_jvm_flags = [],
plugins = [],
print_compile_time = False,
resource_jars = [],
resource_strip_prefix = None,
resources = [],
runtime_deps = [],
scala_toolchain_name = None,
scalac_jvm_flags = [],
scalacopts = [],
srcs = [],
# library only attributes
main_class = None,
exports = [],
Expand Down Expand Up @@ -80,13 +79,13 @@ def scala_library(
name = name,
srcs = srcs,
deps_used_whitelist = _extra_deps,
exports = exports,
macro = not _use_ijar,
scala = _scala,
runtime_deps = runtime_deps,
scala_toolchain_name = scala_toolchain_name,
scalacopts = scalacopts,
tags = tags,
visibility = visibility,
exports = exports,
runtime_deps = runtime_deps,
deps = deps + _extra_deps,
)

Expand All @@ -96,41 +95,43 @@ def scala_macro_library(
tags = [],
visibility = None,
# rules_scala common attributes
srcs = [],
deps = [],
plugins = [],
runtime_deps = [],
data = [],
resources = [],
resource_strip_prefix = None,
resource_jars = [],
scalacopts = [],
deps = [],
javac_jvm_flags = [],
javacopts = [],
jvm_flags = [],
scalac_jvm_flags = [],
javac_jvm_flags = [],
plugins = [],
print_compile_time = False,
resource_jars = [],
resource_strip_prefix = None,
resources = [],
runtime_deps = [],
scala_toolchain_name = None,
scalac_jvm_flags = [],
scalacopts = [],
srcs = [],
# library only attributes
main_class = None,
exports = []):
return scala_library(
name,
tags,
visibility,
srcs,
deps,
plugins,
runtime_deps,
data,
resources,
resource_strip_prefix,
resource_jars,
scalacopts,
deps,
javac_jvm_flags,
javacopts,
jvm_flags,
scalac_jvm_flags,
javac_jvm_flags,
plugins,
print_compile_time,
resource_jars,
resource_strip_prefix,
resources,
runtime_deps,
scala_toolchain_name,
scalac_jvm_flags,
scalacopts,
srcs,
main_class,
exports,
False, # _use_ijar
Expand All @@ -142,20 +143,21 @@ def scala_binary(
tags = [],
visibility = None,
# rules_scala common attributes
srcs = [],
deps = [],
plugins = [],
runtime_deps = [],
data = [],
resources = [],
resource_strip_prefix = None,
resource_jars = [],
scalacopts = [],
deps = [],
javac_jvm_flags = [],
javacopts = [],
jvm_flags = [],
scalac_jvm_flags = [],
javac_jvm_flags = [],
plugins = [],
print_compile_time = False,
resource_jars = [],
resource_strip_prefix = None,
resources = [],
runtime_deps = [],
scala_toolchain_name = None,
scalac_jvm_flags = [],
scalacopts = [],
srcs = [],
# binary only attributes
main_class = None,
classpath_resources = [],
Expand Down Expand Up @@ -192,9 +194,9 @@ def scala_binary(
srcs = srcs,
deps_used_whitelist = _extra_deps,
main_class = main_class,
scala = _scala,
tags = tags,
runtime_deps = runtime_deps,
scala_toolchain_name = scala_toolchain_name,
tags = tags,
deps = deps + _extra_deps,
)

Expand All @@ -204,20 +206,21 @@ def scala_test(
tags = [],
visibility = None,
# rules_scala common attributes
srcs = [],
deps = [],
plugins = [],
runtime_deps = [],
data = [],
resources = [],
resource_strip_prefix = None,
resource_jars = [],
scalacopts = [],
deps = [],
javac_jvm_flags = [],
javacopts = [],
jvm_flags = [],
scalac_jvm_flags = [],
javac_jvm_flags = [],
plugins = [],
print_compile_time = False,
resource_jars = [],
resource_strip_prefix = None,
resources = [],
runtime_deps = [],
scala_toolchain_name = None,
scalac_jvm_flags = [],
scalacopts = [],
srcs = [],
# test only attributes
suites = [],
colors = None,
Expand Down Expand Up @@ -260,39 +263,41 @@ def scala_test(
srcs = srcs,
deps_used_whitelist = _extra_deps,
frameworks = ["org.scalatest.tools.Framework"],
scala = _scala,
tags = tags,
runtime_deps = runtime_deps,
scala_toolchain_name = scala_toolchain_name,
tags = tags,
deps = deps + _scalatest_deps + _extra_deps,
)

def scala_test_suite(
name,
srcs = [],
deps = [],
runtime_deps = [],
colors = True,
data = [],
deps = [],
full_stacktraces = True,
jvm_flags = [],
resources = [],
runtime_deps = [],
scala_toolchain_name = None,
scalacopts = [],
jvm_flags = [],
visibility = None,
size = None,
colors = True,
full_stacktraces = True):
visibility = None):
tests = []
for src in srcs:
test_name = "%s_test_suite_%s" % (name, _safe_name(src))
scala_test(
name = test_name,
size = size,
srcs = [src],
colors = colors,
full_stacktraces = full_stacktraces,
jvm_flags = jvm_flags,
resources = resources,
runtime_deps = runtime_deps,
scala_toolchain_name = scala_toolchain_name,
scalacopts = scalacopts,
size = size,
visibility = visibility,
runtime_deps = runtime_deps,
deps = deps,
)
tests.append(test_name)
Expand Down
1 change: 0 additions & 1 deletion tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ emulate_rules_scala(
"@annex//:org_scala_lang_scala_reflect",
"@annex_test//:org_scala_lang_modules_scala_xml_2_13",
],
scala = "@//scala:2_13",
scalatest = "@scalatest_2_13//jar",
)

Expand Down

0 comments on commit 5da6365

Please sign in to comment.