@@ -403,7 +403,7 @@ def collect_java_providers_of(deps):
403403 providers .append (dep [JavaInfo ])
404404 return providers
405405
406- def _compile_or_empty (
406+ def compile_or_empty (
407407 ctx ,
408408 manifest ,
409409 jars ,
@@ -548,7 +548,7 @@ def _create_scala_compilation_provider(ctx, ijar, source_jar, deps_providers):
548548 runtime_deps = runtime_deps ,
549549 )
550550
551- def _build_deployable (ctx , jars_list ):
551+ def build_deployable (ctx , jars_list ):
552552 # This calls bazels singlejar utility.
553553 # For a full list of available command line options see:
554554 # https://github.com/bazelbuild/bazel/blob/master/src/java_tools/singlejar/java/com/google/devtools/build/singlejar/SingleJar.java#L311
@@ -795,129 +795,12 @@ def collect_jars_from_common_ctx(
795795 deps_providers = deps_providers ,
796796 )
797797
798- def _lib (
799- ctx ,
800- base_classpath ,
801- non_macro_lib ,
802- unused_dependency_checker_mode ,
803- unused_dependency_checker_ignored_targets ):
804- # Build up information from dependency-like attributes
805-
806- # This will be used to pick up srcjars from non-scala library
807- # targets (like thrift code generation)
808- srcjars = collect_srcjars (ctx .attr .deps )
809-
810- unused_dependency_checker_is_off = unused_dependency_checker_mode == "off"
811- jars = collect_jars_from_common_ctx (
812- ctx ,
813- base_classpath ,
814- unused_dependency_checker_is_off = unused_dependency_checker_is_off ,
815- )
816-
817- (cjars , transitive_rjars ) = (jars .compile_jars , jars .transitive_runtime_jars )
818-
819- write_manifest (ctx )
820- outputs = _compile_or_empty (
821- ctx ,
822- ctx .outputs .manifest ,
823- cjars ,
824- srcjars ,
825- non_macro_lib ,
826- jars .transitive_compile_jars ,
827- jars .jars2labels .jars_to_labels ,
828- [],
829- unused_dependency_checker_ignored_targets = [
830- target .label
831- for target in base_classpath + ctx .attr .exports +
832- unused_dependency_checker_ignored_targets
833- ],
834- unused_dependency_checker_mode = unused_dependency_checker_mode ,
835- deps_providers = jars .deps_providers ,
836- )
837-
838- transitive_rjars = depset (outputs .full_jars , transitive = [transitive_rjars ])
839-
840- _build_deployable (ctx , transitive_rjars .to_list ())
841-
842- # Using transitive_files since transitive_rjars a depset and avoiding linearization
843- runfiles = ctx .runfiles (
844- transitive_files = transitive_rjars ,
845- collect_data = True ,
846- )
847-
848- # Add information from exports (is key that AFTER all build actions/runfiles analysis)
849- # Since after, will not show up in deploy_jar or old jars runfiles
850- # Notice that compile_jars is intentionally transitive for exports
851- exports_jars = collect_jars (ctx .attr .exports )
852- transitive_rjars = depset (
853- transitive = [transitive_rjars , exports_jars .transitive_runtime_jars ],
854- )
855-
856- source_jars = _pack_source_jars (ctx ) + outputs .source_jars
857-
858- scalaattr = create_scala_provider (
859- class_jar = outputs .class_jar ,
860- compile_jars = depset (
861- outputs .ijars ,
862- transitive = [exports_jars .compile_jars ],
863- ),
864- deploy_jar = ctx .outputs .deploy_jar ,
865- full_jars = outputs .full_jars ,
866- ijar = outputs .ijar ,
867- source_jars = source_jars ,
868- statsfile = ctx .outputs .statsfile ,
869- transitive_runtime_jars = transitive_rjars ,
870- )
871-
872- return struct (
873- files = depset ([ctx .outputs .jar ] + outputs .full_jars ), # Here is the default output
874- instrumented_files = outputs .coverage .instrumented_files ,
875- jars_to_labels = jars .jars2labels ,
876- providers = [outputs .merged_provider , jars .jars2labels ] + outputs .coverage .providers ,
877- runfiles = runfiles ,
878- scala = scalaattr ,
879- )
880-
881798def get_unused_dependency_checker_mode (ctx ):
882799 if ctx .attr .unused_dependency_checker_mode :
883800 return ctx .attr .unused_dependency_checker_mode
884801 else :
885802 return ctx .toolchains ["@io_bazel_rules_scala//scala:toolchain_type" ].unused_dependency_checker_mode
886803
887- def scala_library_impl (ctx ):
888- if ctx .attr .jvm_flags :
889- print ("'jvm_flags' for scala_library is deprecated. It does nothing today and will be removed from scala_library to avoid confusion." )
890- scalac_provider = get_scalac_provider (ctx )
891- unused_dependency_checker_mode = get_unused_dependency_checker_mode (ctx )
892- return _lib (
893- ctx ,
894- scalac_provider .default_classpath ,
895- True ,
896- unused_dependency_checker_mode ,
897- ctx .attr .unused_dependency_checker_ignored_targets ,
898- )
899-
900- def scala_library_for_plugin_bootstrapping_impl (ctx ):
901- scalac_provider = get_scalac_provider (ctx )
902- return _lib (
903- ctx ,
904- scalac_provider .default_classpath ,
905- True ,
906- unused_dependency_checker_ignored_targets = [],
907- unused_dependency_checker_mode = "off" ,
908- )
909-
910- def scala_macro_library_impl (ctx ):
911- scalac_provider = get_scalac_provider (ctx )
912- unused_dependency_checker_mode = get_unused_dependency_checker_mode (ctx )
913- return _lib (
914- ctx ,
915- scalac_provider .default_macro_classpath ,
916- False , # don't build the ijar for macros
917- unused_dependency_checker_mode ,
918- ctx .attr .unused_dependency_checker_ignored_targets ,
919- )
920-
921804# Common code shared by all scala binary implementations.
922805def scala_binary_common (
923806 ctx ,
@@ -933,7 +816,7 @@ def scala_binary_common(
933816 implicit_junit_deps_needed_for_java_compilation = [],
934817 runfiles_ext = []):
935818 write_manifest (ctx )
936- outputs = _compile_or_empty (
819+ outputs = compile_or_empty (
937820 ctx ,
938821 ctx .outputs .manifest ,
939822 cjars ,
@@ -949,7 +832,7 @@ def scala_binary_common(
949832 ) # no need to build an ijar for an executable
950833 rjars = depset (outputs .full_jars , transitive = [rjars ])
951834
952- _build_deployable (ctx , rjars .to_list ())
835+ build_deployable (ctx , rjars .to_list ())
953836
954837 runfiles = ctx .runfiles (
955838 transitive_files = depset (
@@ -959,7 +842,7 @@ def scala_binary_common(
959842 collect_data = True ,
960843 )
961844
962- source_jars = _pack_source_jars (ctx ) + outputs .source_jars
845+ source_jars = pack_source_jars (ctx ) + outputs .source_jars
963846
964847 scalaattr = create_scala_provider (
965848 class_jar = outputs .class_jar ,
@@ -1009,7 +892,7 @@ def _pack_source_jar(ctx):
1009892
1010893 return scala_source_jar
1011894
1012- def _pack_source_jars (ctx ):
895+ def pack_source_jars (ctx ):
1013896 source_jar = _pack_source_jar (ctx )
1014897 #_pack_source_jar may return None if java_common.pack_sources returned None (and it can)
1015898 return [source_jar ] if source_jar else []
0 commit comments