File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ _scala_binary_attrs = {
5252 "main_class" : attr .string (mandatory = True ),
5353 "classpath_resources" : attr .label_list (allow_files = True ),
5454 "jvm_flags" : attr .string_list (),
55+ "runtime_jdk" : attr .label (
56+ default = Label ("@bazel_tools//tools/jdk:current_java_runtime" ),
57+ providers = [java_common .JavaRuntimeInfo ],
58+ ),
5559}
5660
5761_scala_binary_attrs .update (launcher_template )
Original file line number Diff line number Diff line change @@ -471,8 +471,17 @@ scala_specs2_junit_test(
471471 "//test/src/main/scala/scalarules/test/twitter_scrooge:justscrooge2b_binary" ,
472472 "//test/src/main/scala/scalarules/test/large_classpath:largeClasspath" ,
473473 "//test:test_scala_proto_server" ,
474+ "//test:scala_binary_jdk_11" ,
474475]]
475476
477+ # Make sure scala_binary respects runtime_jdk on bazel run
478+ scala_binary (
479+ name = "scala_binary_jdk_11" ,
480+ srcs = ["ScalaBinaryJdk11.scala" ],
481+ main_class = "scalarules.test.ScalaBinaryJdk11" ,
482+ runtime_jdk = "@bazel_tools//tools/jdk:remote_jdk11" ,
483+ )
484+
476485# Generate a file containing the rootpaths of a Scala binary.
477486genrule (
478487 name = "rootpath-script" ,
Original file line number Diff line number Diff line change 1+ package scalarules .test
2+
3+ object ScalaBinaryJdk11 {
4+ def main (args : Array [String ]): Unit = {
5+ val expectedMajorVersion = " 11" ;
6+ val version = System .getProperty(" java.version" );
7+ val majorVersionMatches = version.startsWith(expectedMajorVersion + " ." );
8+ val failureMsg = " Expected major version of " + expectedMajorVersion + " but got version: " + version;
9+ require(majorVersionMatches, failureMsg);
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments