@@ -19,6 +19,7 @@ load(":common/cc/cc_info.bzl", "CcInfo")
1919load (":common/cc/semantics.bzl" , cc_semantics = "semantics" )
2020load (":common/java/basic_java_library.bzl" , "BASIC_JAVA_LIBRARY_IMPLICIT_ATTRS" , "basic_java_library" , "collect_deps" )
2121load (":common/java/boot_class_path_info.bzl" , "BootClassPathInfo" )
22+ load (":common/java/java_binary_deploy_jar.bzl" , "create_deploy_archive" )
2223load (":common/java/java_common.bzl" , "java_common" )
2324load (
2425 ":common/java/java_common_internal_for_builtins.bzl" ,
@@ -275,8 +276,31 @@ def basic_java_binary(
275276
276277 java_binary_info = to_java_binary_info (java_info , compilation_info )
277278
279+ internal_deploy_jar_info = InternalDeployJarInfo (
280+ java_attrs = java_attrs ,
281+ launcher_info = struct (
282+ runtime_jars = launcher_info .runtime_jars ,
283+ launcher = launcher_info .launcher ,
284+ unstripped_launcher = launcher_info .unstripped_launcher ,
285+ ),
286+ shared_archive = shared_archive ,
287+ main_class = main_class ,
288+ coverage_main_class = coverage_main_class ,
289+ strip_as_default = strip_as_default ,
290+ stamp = ctx .attr .stamp ,
291+ hermetic = hasattr (ctx .attr , "hermetic" ) and ctx .attr .hermetic ,
292+ add_exports = add_exports ,
293+ add_opens = add_opens ,
294+ manifest_lines = ctx .attr .deploy_manifest_lines ,
295+ )
296+
297+ # "temporary" workaround for https://github.com/bazelbuild/intellij/issues/5845
298+ extra_files = []
299+ if is_test_rule_class and ctx .fragments .java .auto_create_java_test_deploy_jars ():
300+ extra_files .append (_auto_create_deploy_jar (ctx , internal_deploy_jar_info ))
301+
278302 default_info = struct (
279- files = files ,
303+ files = depset ( extra_files , transitive = [ files ]) ,
280304 runfiles = runfiles ,
281305 executable = executable ,
282306 )
@@ -286,23 +310,7 @@ def basic_java_binary(
286310 "JavaInfo" : java_binary_info ,
287311 "InstrumentedFilesInfo" : target ["InstrumentedFilesInfo" ],
288312 "JavaRuntimeClasspathInfo" : java_common .JavaRuntimeClasspathInfo (runtime_classpath = java_info .transitive_runtime_jars ),
289- "InternalDeployJarInfo" : InternalDeployJarInfo (
290- java_attrs = java_attrs ,
291- launcher_info = struct (
292- runtime_jars = launcher_info .runtime_jars ,
293- launcher = launcher_info .launcher ,
294- unstripped_launcher = launcher_info .unstripped_launcher ,
295- ),
296- shared_archive = shared_archive ,
297- main_class = main_class ,
298- coverage_main_class = coverage_main_class ,
299- strip_as_default = strip_as_default ,
300- stamp = ctx .attr .stamp ,
301- hermetic = hasattr (ctx .attr , "hermetic" ) and ctx .attr .hermetic ,
302- add_exports = add_exports ,
303- add_opens = add_opens ,
304- manifest_lines = ctx .attr .deploy_manifest_lines ,
305- ),
313+ "InternalDeployJarInfo" : internal_deploy_jar_info ,
306314 }, default_info , jvm_flags
307315
308316def _collect_attrs (ctx , runtime_classpath , classpath_resources ):
@@ -490,6 +498,43 @@ def _get_validations_from_target(target):
490498 else :
491499 return depset ()
492500
501+ # TODO: bazelbuild/intellij/issues/5845 - remove this once no longer required
502+ # this need not be completely identical to the regular deploy jar since we only
503+ # care about packaging the classpath
504+ def _auto_create_deploy_jar (ctx , info ):
505+ output = ctx .actions .declare_file (ctx .label .name + "_auto_deploy.jar" )
506+ java_attrs = info .java_attrs
507+ runtime_classpath = depset (
508+ direct = info .launcher_info .runtime_jars ,
509+ transitive = [
510+ java_attrs .runtime_jars ,
511+ java_attrs .runtime_classpath_for_archive ,
512+ ],
513+ order = "preorder" ,
514+ )
515+ create_deploy_archive (
516+ ctx ,
517+ launcher = info .launcher_info .launcher ,
518+ runfiles = depset (),
519+ main_class = info .main_class ,
520+ coverage_main_class = info .coverage_main_class ,
521+ resources = java_attrs .resources ,
522+ classpath_resources = java_attrs .classpath_resources ,
523+ runtime_classpath = runtime_classpath ,
524+ manifest_lines = info .manifest_lines ,
525+ build_info_files = [],
526+ build_target = str (ctx .label ),
527+ output = output ,
528+ shared_archive = info .shared_archive ,
529+ one_version_level = ctx .fragments .java .one_version_enforcement_level ,
530+ one_version_allowlist = helper .check_and_get_one_version_attribute (ctx , "_one_version_allowlist" ),
531+ multi_release = ctx .fragments .java .multi_release_deploy_jars ,
532+ hermetic = info .hermetic ,
533+ add_exports = info .add_exports ,
534+ add_opens = info .add_opens ,
535+ )
536+ return output
537+
493538BASIC_JAVA_BINARY_ATTRIBUTES = merge_attrs (
494539 BASIC_JAVA_LIBRARY_IMPLICIT_ATTRS ,
495540 {
0 commit comments