Skip to content

Commit

Permalink
extra javac opts should override default ones (#1613)
Browse files Browse the repository at this point in the history
* extra javac opts should override default ones

* add test
  • Loading branch information
thomasbao12 authored Sep 11, 2024
1 parent 2d90d53 commit e53a43b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions scala/private/rule_impls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,9 @@ def compile_java(ctx, source_jars, source_files, output, extra_javac_opts, provi
output = output,
javac_opts = expand_location(
ctx,
extra_javac_opts +
java_common.default_javac_opts(
java_toolchain = java_toolchain,
),
) + extra_javac_opts,
),
deps = providers_of_dependencies,
#exports can be empty since the manually created provider exposes exports
Expand Down
8 changes: 8 additions & 0 deletions test/shell/test_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@ java_toolchain_javacopts_are_used(){
--verbose_failures //test_expect_failure/compilers_javac_opts:can_configure_jvm_flags_for_javac_via_javacopts
}

java_toolchain_javacopts_can_be_overridden(){
action_should_fail_with_message \
"invalid target release: InvalidTarget" \
build \
--verbose_failures //test_expect_failure/compilers_javac_opts:can_override_default_toolchain_flags_for_javac_via_javacopts
}

$runner test_scalaopts_from_scala_toolchain
$runner java_toolchain_javacopts_are_used
$runner java_toolchain_javacopts_can_be_overridden
6 changes: 6 additions & 0 deletions test_expect_failure/compilers_javac_opts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ scala_library(
name = "can_configure_jvm_flags_for_javac_via_javacopts",
srcs = ["WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java"],
)

scala_library(
name = "can_override_default_toolchain_flags_for_javac_via_javacopts",
srcs = ["WillNotCompileSinceJavaToolchainAddsAnInvalidJvmFlag.java"],
javacopts = ["-target InvalidTarget"],
)

0 comments on commit e53a43b

Please sign in to comment.