Add LOCAL_SRCJARS support
Allow java modules to take jars containing .java files as an input.
For turbine, pass them directly to turbine. For javac, extract them
to a directory and pass a list of the files to javac.
Bug: 73885582
Test: m checkbuild
Change-Id: Ib4351a5b4b165a55e5fb02ee2680466db368983a
diff --git a/core/java.mk b/core/java.mk
index d15f4eb..0ac7a87 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -401,6 +401,7 @@
$(java_resource_sources) \
$(RenderScript_file_stamp) \
$(proto_java_sources_file_stamp) \
+ $(LOCAL_SRCJARS) \
$(LOCAL_ADDITIONAL_DEPENDENCIES)
$(java_source_list_file): $(java_sources_deps)
@@ -409,6 +410,7 @@
ifneq ($(TURBINE_ENABLED),false)
$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
+$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
$(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
$(full_classes_turbine_jar): \
$(java_source_list_file) \
@@ -446,6 +448,9 @@
$(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
$(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file)
$(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs)
+$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
+$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list
+$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
$(full_classes_compiled_jar): \
$(java_source_list_file) \
$(full_java_header_libs) \
@@ -456,6 +461,7 @@
$(annotation_processor_deps) \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \
+ $(EXTRACT_SRCJARS) \
| $(SOONG_JAVAC_WRAPPER)
@echo "Target Java: $@
$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))