Replace some uses of zip with merge_zips, soong_zip, and zip2zip
zip maintains permissions when adding files to zips, which causes
the final jars and apks to change based on the umask of the build.
Move some of the rules that were using zip to soong_zip instead.
Since soong_zip doesn't support adding files to existing zips,
create a new zip file for each part of the package creation
process and then merge them together at the end with merge_zips.
Bug: 69500920
Test: m checkbuild
Change-Id: Id253df776ce19ec4cac3a36fa470a50461ea3cad
diff --git a/core/java_library.mk b/core/java_library.mk
index b9abbe4..5716f4c 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -65,10 +65,14 @@
$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
+$(common_javalib.jar): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP)
$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN)
@echo "target Jar: $(PRIVATE_MODULE) ($@)"
- $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@.tmp)
- $(call add-dex-to-package,$@.tmp)
+ rm -rf $@.parts && mkdir -p $@.parts
+ $(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE))
+ $(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE))
+ $(MERGE_ZIPS) -j $@.tmp $@.parts/dex.zip $@.parts/res.zip
+ rm -rf $@.parts
$(hide) $(ZIPTIME) $@.tmp
$(call commit-change-for-toc,$@)
ifeq (true, $(LOCAL_UNCOMPRESS_DEX))