Skip to content

Commit

Permalink
Turn back on ijars for Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
James Judd committed Jul 27, 2024
1 parent 4e4f2ab commit cb7a448
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
9 changes: 0 additions & 9 deletions rules/private/phases/phase_javainfo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions rules/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
},
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Expand All @@ -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"],
)
Expand Down
5 changes: 1 addition & 4 deletions tests/plugins/macros/test
Original file line number Diff line number Diff line change
@@ -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!' ]
4 changes: 2 additions & 2 deletions tests/scala/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Expand All @@ -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"],
)
Expand Down

0 comments on commit cb7a448

Please sign in to comment.