diff --git a/test/BUILD b/test/BUILD index 4c2d7a263..4e5a19397 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,5 +1,3 @@ -load("@rules_python//python:defs.bzl", "py_binary") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") load( "//scala:scala.bzl", "scala_binary", @@ -13,10 +11,18 @@ load( "scala_test", "scala_test_suite", ) +load("//scala:scala_cross_version.bzl", "repositories") load(":check_statsfile.bzl", "check_statsfile") +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_python//python:defs.bzl", "py_binary") package(default_testonly = 1) +_JUNIT_DEPS = repositories(SCALA_VERSION, [ + "@io_bazel_rules_scala_junit_junit", +]) + # The examples below show how to combine Scala and Java rules. # ScalaBinary is the Scala equivalent of JavaBinary. @@ -491,7 +497,6 @@ scala_junit_test( "//test/src/main/resources/java_sources:CompiledWithJava11", "//test/src/main/resources/java_sources:CompiledWithJava8", ], - deps = ["@io_bazel_rules_scala_junit_junit"], ) # Generate a file containing the rootpaths of a Scala binary. @@ -612,7 +617,7 @@ scala_library( scala_library( name = "customJunitRunner", srcs = ["src/main/scala/scalarules/test/junit/JunitCustomRunner.java"], - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) # make sure making a fat jar strips signatures @@ -698,7 +703,7 @@ check_statsfile("ScalaLibBinary") scala_library( name = "JunitSeparateTarget", srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitSeparateTargetTest.scala"], - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) scala_junit_test( @@ -712,7 +717,7 @@ scala_junit_test( java_library( name = "JunitJavaSeparateTarget", srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitJavaSeparateTargetTest.java"], - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) scala_junit_test( @@ -726,14 +731,14 @@ scala_junit_test( scala_library( name = "TargetWithTestThatShouldNotRun", srcs = ["src/main/scala/scalarules/test/junit/separate_target/FailingTest.scala"], - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) scala_library( name = "JunitSeparateTargetWithDependencyOnTest", srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitSeparateTargetTest.scala"], runtime_deps = [":TargetWithTestThatShouldNotRun"], - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) scala_junit_test( @@ -748,7 +753,7 @@ java_library( name = "JunitSeparateJavaTargetWithDependencyOnTest", srcs = ["src/main/scala/scalarules/test/junit/separate_target/JunitJavaSeparateTargetTest.java"], runtime_deps = [":TargetWithTestThatShouldNotRun"], - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) scala_junit_test( @@ -765,7 +770,7 @@ scala_library( "src/main/scala/scalarules/test/junit/separate_target/JunitJavaSeparateTargetTest.java", "src/main/scala/scalarules/test/junit/separate_target/SomeScalaClass.scala", ], - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) scala_junit_test( @@ -783,7 +788,7 @@ scala_library( ], # make sure java compilation toolchain matches runtime toolchain ie --target java_compile_toolchain = "@bazel_tools//tools/jdk:toolchain_java11", - deps = ["@io_bazel_rules_scala_junit_junit"], + deps = _JUNIT_DEPS, ) scala_junit_test( @@ -800,7 +805,6 @@ scala_junit_test( size = "small", srcs = ["src/main/scala/scalarules/test/junit/JunitNoTestEnvironmentTest.scala"], suffixes = ["Test"], - deps = ["@io_bazel_rules_scala_junit_junit"], ) scala_junit_test( @@ -811,7 +815,6 @@ scala_junit_test( "my_env_var": "my_value", }, suffixes = ["Test"], - deps = ["@io_bazel_rules_scala_junit_junit"], ) py_binary(