From cb7a448c056efddeb8f724aa3591e702f47cf56d Mon Sep 17 00:00:00 2001 From: James Judd Date: Sat, 27 Jul 2024 00:04:42 -0600 Subject: [PATCH] Turn back on ijars for Scala 3 --- rules/private/phases/phase_javainfo.bzl | 9 --------- rules/scala.bzl | 4 ++-- src/main/scala/BUILD | 4 ++-- tests/plugins/macros/test | 5 +---- tests/scala/BUILD | 4 ++-- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/rules/private/phases/phase_javainfo.bzl b/rules/private/phases/phase_javainfo.bzl index 098a34c7e..30c8f61ae 100644 --- a/rules/private/phases/phase_javainfo.bzl +++ b/rules/private/phases/phase_javainfo.bzl @@ -28,15 +28,6 @@ def phase_javainfo(ctx, g): if len(ctx.attr.srcs) == 0 and len(ctx.attr.resources) == 0: java_info = java_common.merge([g.classpaths.sdeps, sexports, sruntime_deps]) else: - # TODO: why do ijars break Scala 3? - # For some yet unknown reason ijars break Scala 3. - # Bazel now handles .tasty files, but the Scala 3 test fails to pass - # when this ijar is used as the compile jar. My guess is that the - # classfile format changed somehow for Scala 3 and Bazel does not yet - # handle that. - # - # In the meantime, we've added a use_ijar Scala configuration value and - # only use ijars for Scala 2 targets. compile_jar = ctx.outputs.jar if (ctx.attr.scala[_ScalaConfiguration].use_ijar): compile_jar = java_common.run_ijar( diff --git a/rules/scala.bzl b/rules/scala.bzl index d3f394ca3..58cefd131 100644 --- a/rules/scala.bzl +++ b/rules/scala.bzl @@ -501,7 +501,7 @@ configure_bootstrap_scala = rule( doc = "Scalac options that will always be enabled.", ), "use_ijar": attr.bool( - doc = "Whether to use ijars for this compiler. Scala 3 currently cannot use ijars.", + doc = "Whether to use ijars for this compiler.", default = True, ), }, @@ -535,7 +535,7 @@ _configure_zinc_scala = rule( default = "warn", ), "use_ijar": attr.bool( - doc = "Whether to use ijars for this compiler. Scala 3 currently cannot use ijars.", + doc = "Whether to use ijars for this compiler.", default = True, ), "deps_direct": attr.string(default = "error"), diff --git a/src/main/scala/BUILD b/src/main/scala/BUILD index 08663d342..b766e9959 100644 --- a/src/main/scala/BUILD +++ b/src/main/scala/BUILD @@ -96,7 +96,7 @@ configure_bootstrap_scala( compiler_classpath = compiler_classpath_3, global_scalacopts = shared_global_scalacopts, runtime_classpath = runtime_classpath_3, - use_ijar = False, + use_ijar = True, version = scala_3_version, visibility = ["//visibility:public"], ) @@ -107,7 +107,7 @@ configure_zinc_scala( compiler_classpath = compiler_classpath_3, global_scalacopts = shared_global_scalacopts, runtime_classpath = runtime_classpath_3, - use_ijar = False, + use_ijar = True, version = scala_3_version, visibility = ["//visibility:public"], ) diff --git a/tests/plugins/macros/test b/tests/plugins/macros/test index 94daecdec..bc7cbb331 100755 --- a/tests/plugins/macros/test +++ b/tests/plugins/macros/test @@ -1,9 +1,6 @@ #!/bin/bash -e . "$(dirname "$0")"/../../common.sh -# TODO: Re-enable this test once Scala 3 works with ijars -# macro = True makes you use full jars, and we're doing that -# all the time now because Scala 3 +ijar breaks. So this always passes -#bazel build :bad_compile 2>&1 | grep 'You may be missing a `macro = True` attribute.' +bazel build :bad_compile 2>&1 | grep 'You may be missing a `macro = True` attribute.' [ "$(bazel run :test_macro)" = "hello world!" ] [ "$(bazel run :test_macro_only)" = $'hello world!\nworld hello!' ] diff --git a/tests/scala/BUILD b/tests/scala/BUILD index 93db8428e..336a8b9a0 100644 --- a/tests/scala/BUILD +++ b/tests/scala/BUILD @@ -110,7 +110,7 @@ configure_bootstrap_scala( name = "bootstrap_3", compiler_classpath = compiler_classpath_3, runtime_classpath = runtime_classpath_3, - use_ijar = False, + use_ijar = True, version = scala_3_version, visibility = ["//visibility:public"], ) @@ -120,7 +120,7 @@ configure_zinc_scala( compiler_bridge = "@annex//:org_scala_lang_scala3_sbt_bridge", compiler_classpath = compiler_classpath_3, runtime_classpath = runtime_classpath_3, - use_ijar = False, + use_ijar = True, version = scala_3_version, visibility = ["//visibility:public"], )