Run jetifier against prebuilts directly rather than classes.jar

It turns out that the resource files inside the .aar files may
need rewriting too

Bug: 72552006
Test: Set LOCAL_JETIFIED_ENABLED for a prebuilt and built it
      See also one of the patches after this one and its topic
      which contains a sample for testing
Change-Id: I89d0b4aa8d5c6ae3abc2344dd05222cf9672d5c0
This commit is contained in:
Jeff Gaston 2018-02-27 14:05:40 -05:00
parent 0835594a6f
commit ed170e7296
4 changed files with 15 additions and 15 deletions

View File

@ -97,16 +97,10 @@ $(full_classes_combined_jar): $(full_classes_compiled_jar) \
$(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \
-stripDir META-INF -zipToNotStrip $< $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
#######################################
LOCAL_JETIFIER_INPUT_FILE := $(full_classes_combined_jar)
include $(BUILD_SYSTEM)/jetifier.mk
#######################################
# Run jarjar if necessary, otherwise just copy the file.
ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
$(full_classes_jarjar_jar): $(LOCAL_JETIFIER_OUTPUT_FILE) $(LOCAL_JARJAR_RULES) | $(JARJAR)
$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
@echo JarJar: $@
$(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
else

View File

@ -559,13 +559,7 @@ else
full_classes_jarjar_jar := $(full_classes_processed_jar)
endif
#######################################
LOCAL_JETIFIER_INPUT_FILE := $(full_classes_jarjar_jar)
include $(BUILD_SYSTEM)/jetifier.mk
#######################################
$(eval $(call copy-one-file,$(LOCAL_JETIFIER_OUTPUT_FILE),$(full_classes_jar)))
$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
#######################################
LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar)

View File

@ -20,7 +20,7 @@
ifeq ($(strip $(LOCAL_JETIFIER_ENABLED)),true)
my_jetifier_input_path := $(LOCAL_JETIFIER_INPUT_FILE)
my_files := $(intermediates.COMMON)/jetifier
my_jetifier_output_path := $(my_files)/classes-jetifier.jar
my_jetifier_output_path := $(my_files)/jetified-$(notdir $(my_jetifier_input_path))
$(my_jetifier_output_path) : $(my_jetifier_input_path) $(JETIFIER)
rm -rf $@

View File

@ -571,6 +571,12 @@ else # ! prebuilt_module_is_dex_javalib
my_src_aar := $(filter %.aar, $(my_prebuilt_src_file))
ifneq ($(my_src_aar),)
# This is .aar file, archive of classes.jar and Android resources.
# run Jetifier if needed
LOCAL_JETIFIER_INPUT_FILE := $(my_src_aar)
include $(BUILD_SYSTEM)/jetifier.mk
my_src_aar := $(LOCAL_JETIFIER_OUTPUT_FILE)
my_src_jar := $(intermediates.COMMON)/aar/classes.jar
my_src_proguard_options := $(intermediates.COMMON)/aar/proguard.txt
@ -582,6 +588,12 @@ $(my_src_jar) : $(my_src_aar)
$(hide) touch $@
# Make sure the proguard file exists and has a new timestamp.
$(hide) touch $(dir $@)/proguard.txt
else
# run Jetifier if needed
LOCAL_JETIFIER_INPUT_FILE := $(my_src_jar)
include $(BUILD_SYSTEM)/jetifier.mk
my_src_jar := $(LOCAL_JETIFIER_OUTPUT_FILE)
endif