Skip to content

Commit 7b1d93d

Browse files
test
1 parent 4bdf33a commit 7b1d93d

File tree

13 files changed

+131
-4
lines changed

13 files changed

+131
-4
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ http_archive(
4747
],
4848
)
4949

50+
http_archive(
51+
name = "bazel_features",
52+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
53+
strip_prefix = "bazel_features-1.9.1",
54+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
55+
)
56+
57+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
58+
bazel_features_deps()
59+
5060
# See https://github.com/bazelbuild/rules_scala/releases for up to date version information.
5161
http_archive(
5262
name = "io_bazel_rules_scala",

WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
1515

1616
bazel_skylib_workspace()
1717

18+
http_archive(
19+
name = "bazel_features",
20+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
21+
strip_prefix = "bazel_features-1.9.1",
22+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
23+
)
24+
25+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
26+
27+
bazel_features_deps()
28+
1829
_build_tools_release = "5.1.0"
1930

2031
http_archive(

examples/scala3/WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ http_archive(
1111
],
1212
)
1313

14+
http_archive(
15+
name = "bazel_features",
16+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
17+
strip_prefix = "bazel_features-1.9.1",
18+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
19+
)
20+
21+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
22+
23+
bazel_features_deps()
24+
1425
local_repository(
1526
name = "io_bazel_rules_scala",
1627
path = "../..",

examples/semanticdb/WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ http_archive(
1414
],
1515
)
1616

17+
http_archive(
18+
name = "bazel_features",
19+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
20+
strip_prefix = "bazel_features-1.9.1",
21+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
22+
)
23+
24+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
25+
26+
bazel_features_deps()
27+
1728
local_repository(
1829
name = "io_bazel_rules_scala",
1930
path = "../..",

examples/testing/multi_frameworks_toolchain/WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ http_archive(
1111
],
1212
)
1313

14+
http_archive(
15+
name = "bazel_features",
16+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
17+
strip_prefix = "bazel_features-1.9.1",
18+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
19+
)
20+
21+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
22+
23+
bazel_features_deps()
24+
1425
local_repository(
1526
name = "io_bazel_rules_scala",
1627
path = "../../..",

examples/testing/scalatest_repositories/WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ http_archive(
1111
],
1212
)
1313

14+
http_archive(
15+
name = "bazel_features",
16+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
17+
strip_prefix = "bazel_features-1.9.1",
18+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
19+
)
20+
21+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
22+
23+
bazel_features_deps()
24+
1425
local_repository(
1526
name = "io_bazel_rules_scala",
1627
path = "../../..",

examples/testing/specs2_junit_repositories/WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ http_archive(
1111
],
1212
)
1313

14+
http_archive(
15+
name = "bazel_features",
16+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
17+
strip_prefix = "bazel_features-1.9.1",
18+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
19+
)
20+
21+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
22+
23+
bazel_features_deps()
24+
1425
local_repository(
1526
name = "io_bazel_rules_scala",
1627
path = "../../..",

scala/private/common_attributes.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Shared attributes for rules"""
22

3+
load("@bazel_features//:features.bzl", "bazel_features")
34
load(
45
"@io_bazel_rules_scala//scala/private:coverage_replacements_provider.bzl",
56
_coverage_replacements_provider = "coverage_replacements_provider",
@@ -48,7 +49,10 @@ common_attrs_for_plugin_bootstrapping = {
4849
default = False,
4950
mandatory = False,
5051
),
51-
}
52+
} | ({
53+
"add_exports": attr.string_list(),
54+
"add_opens": attr.string_list(),
55+
} if bazel_features.java.java_info_constructor_module_flags else {})
5256

5357
common_attrs = {}
5458

scala/private/macros/scala_repositories.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ def rules_scala_setup(scala_compiler_srcjar = None):
9292
],
9393
)
9494

95+
if not native.existing_rule("bazel_features"):
96+
http_archive(
97+
name = "bazel_features",
98+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
99+
strip_prefix = "bazel_features-1.9.1",
100+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
101+
)
102+
95103
if not native.existing_rule("rules_cc"):
96104
http_archive(
97105
name = "rules_cc",

scala/private/phases/phase_compile.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# DOCUMENT THIS
55
#
6+
load("@bazel_features//:features.bzl", "bazel_features")
67
load(
78
"@io_bazel_rules_scala//scala/private:paths.bzl",
89
_get_files_with_extension = "get_files_with_extension",
@@ -298,7 +299,7 @@ def _create_scala_compilation_provider(ctx, ijar, source_jar, deps_providers):
298299
runtime_deps = []
299300
if hasattr(ctx.attr, "runtime_deps"):
300301
runtime_deps = [dep[JavaInfo] for dep in ctx.attr.runtime_deps]
301-
return JavaInfo(
302+
kwargs = dict(
302303
output_jar = ctx.outputs.jar,
303304
compile_jar = ijar,
304305
source_jar = source_jar,
@@ -308,6 +309,13 @@ def _create_scala_compilation_provider(ctx, ijar, source_jar, deps_providers):
308309
neverlink = ctx.attr.neverlink,
309310
)
310311

312+
# The JavaInfo constructor's add_exports and add_opens flags were added in Bazel 7:
313+
# https://github.com/bazelbuild/bazel/issues/20033
314+
if bazel_features.java.java_info_constructor_module_flags:
315+
kwargs["add_exports"] = getattr(ctx.attr, "add_exports", [])
316+
kwargs["add_opens"] = getattr(ctx.attr, "add_opens", [])
317+
return JavaInfo(**kwargs)
318+
311319
def _pack_source_jar(ctx, scala_srcs, input_srcjars):
312320
# https://github.com/bazelbuild/bazel/blob/ff6c0333e4f957bb9f7ab5401b01dbf3e9b515b1/src/main/java/com/google/devtools/build/lib/rules/java/JavaInfoBuildHelper.java#L180-L183
313321
# java_common.pack_sources checks for no srcs and only a single input jar

0 commit comments

Comments
 (0)