@@ -41,8 +41,10 @@ def phase_compile_library(ctx, p):
41
41
return _phase_compile_default (ctx , p , args )
42
42
43
43
def phase_compile_library_for_plugin_bootstrapping (ctx , p ):
44
+ is_scala_2 = ctx .toolchains ["@io_bazel_rules_scala//scala:toolchain_type" ].scala_version .startswith ("2." )
45
+
44
46
args = struct (
45
- buildijar = ctx .attr .build_ijar ,
47
+ buildijar = ctx .attr .build_ijar and is_scala_2 ,
46
48
)
47
49
return _phase_compile_default (ctx , p , args )
48
50
@@ -102,13 +104,11 @@ def phase_compile_common(ctx, p):
102
104
return _phase_compile_default (ctx , p )
103
105
104
106
def _phase_compile_default (ctx , p , _args = struct ()):
105
- buildijar_default_value = True if ctx .toolchains ["@io_bazel_rules_scala//scala:toolchain_type" ].scala_version .startswith ("2." ) else False
106
-
107
107
return _phase_compile (
108
108
ctx ,
109
109
p ,
110
110
_args .srcjars if hasattr (_args , "srcjars" ) else depset (),
111
- _args . buildijar if hasattr (_args , "buildijar" ) else buildijar_default_value ,
111
+ not hasattr (_args , "buildijar" ) or _args . buildijar ,
112
112
_args .implicit_junit_deps_needed_for_java_compilation if hasattr (_args , "implicit_junit_deps_needed_for_java_compilation" ) else [],
113
113
unused_dependency_checker_ignored_targets = _args .unused_dependency_checker_ignored_targets if hasattr (_args , "unused_dependency_checker_ignored_targets" ) else [],
114
114
)
@@ -228,12 +228,7 @@ def _compile_or_empty(
228
228
229
229
# build ijar if needed
230
230
if buildijar :
231
- ijar = java_common .run_ijar (
232
- ctx .actions ,
233
- jar = ctx .outputs .jar ,
234
- target_label = ctx .label ,
235
- java_toolchain = specified_java_compile_toolchain (ctx ),
236
- )
231
+ ijar = _build_ijar (ctx )
237
232
else :
238
233
# macro code needs to be available at compile-time,
239
234
# so set ijar == jar
@@ -266,6 +261,30 @@ def _compile_or_empty(
266
261
merged_provider = merged_provider ,
267
262
)
268
263
264
+ def _build_ijar (ctx ):
265
+ if ctx .toolchains ["@io_bazel_rules_scala//scala:toolchain_type" ].scala_version .startswith ("2." ):
266
+ return java_common .run_ijar (
267
+ ctx .actions ,
268
+ jar = ctx .outputs .jar ,
269
+ target_label = ctx .label ,
270
+ java_toolchain = specified_java_compile_toolchain (ctx ),
271
+ )
272
+
273
+ output = ctx .actions .declare_file ("{}-ijar.jar" .format (ctx .label .name ))
274
+ arguments = ctx .actions .args ()
275
+ arguments .add (ctx .outputs .jar )
276
+ arguments .add (output )
277
+
278
+ ctx .actions .run (
279
+ arguments = [arguments ],
280
+ executable = ctx .executable ._dottyijar ,
281
+ inputs = [ctx .outputs .jar ],
282
+ mnemonic = "DottyIjar" ,
283
+ outputs = [output ],
284
+ )
285
+
286
+ return output
287
+
269
288
def _build_nosrc_jar (ctx ):
270
289
resources = [s + ":" + t for t , s in _resource_paths (ctx .files .resources , ctx .attr .resource_strip_prefix )]
271
290
0 commit comments