Skip to content
Merged
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
4 changes: 4 additions & 0 deletions scala/private/rules/scala_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ _scala_binary_attrs = {
"main_class": attr.string(mandatory = True),
"classpath_resources": attr.label_list(allow_files = True),
"jvm_flags": attr.string_list(),
"runtime_jdk": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
providers = [java_common.JavaRuntimeInfo],
),
}

_scala_binary_attrs.update(launcher_template)
Expand Down
9 changes: 9 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,17 @@ scala_specs2_junit_test(
"//test/src/main/scala/scalarules/test/twitter_scrooge:justscrooge2b_binary",
"//test/src/main/scala/scalarules/test/large_classpath:largeClasspath",
"//test:test_scala_proto_server",
"//test:scala_binary_jdk_11",
]]

# Make sure scala_binary respects runtime_jdk on bazel run
scala_binary(
name = "scala_binary_jdk_11",
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, Win! Could you see if we can add bazel run <this target> to somewhere like this as a test? https://github.com/bazelbuild/rules_scala/blob/master/test_rules_scala.sh

possibly test/shell/test_scala_binary.sh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This target is added to the list of sh_tests above, so it will be run as a test.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh ok. missed that. thank you!

srcs = ["ScalaBinaryJdk11.scala"],
main_class = "scalarules.test.ScalaBinaryJdk11",
runtime_jdk = "@bazel_tools//tools/jdk:remote_jdk11",
)

# Generate a file containing the rootpaths of a Scala binary.
genrule(
name = "rootpath-script",
Expand Down
11 changes: 11 additions & 0 deletions test/ScalaBinaryJdk11.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package scalarules.test

object ScalaBinaryJdk11 {
def main(args: Array[String]): Unit = {
val expectedMajorVersion = "11";
val version = System.getProperty("java.version");
val majorVersionMatches = version.startsWith(expectedMajorVersion + ".");
val failureMsg = "Expected major version of " + expectedMajorVersion + " but got version: " + version;
require(majorVersionMatches, failureMsg);
}
}