Avoid feeding D8 with dex files.
Some test targets include dex files as resource to be loaded
at runtime. This is an issue since full D8 also take dex files
as input.
This CL extracts only the class files and feed that to D8 instead
of the whole jar.
Test: USE_D8_DESUGAR=true m checkbuild tests
Bug: 69329508
Change-Id: I52d80ec01933573f18eb497472a80b6a649c9dae
diff --git a/core/definitions.mk b/core/definitions.mk
index e350bd0..87deecb 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2415,13 +2415,15 @@
define transform-classes-d8.jar-to-dex
@echo "target Dex: $(PRIVATE_MODULE)"
@mkdir -p $(dir $@)
-$(hide) rm -f $(dir $@)classes*.dex
+$(hide) rm -rf $(dir $@)classes*.dex $(dir $@)*.class $(dir $@)d8_input
+$(hide) unzip -qq -d $(dir $@)d8_input $< "*.class"
$(hide) $(DX_COMMAND) \
--output $(dir $@) \
--min-api $(PRIVATE_MIN_SDK_VERSION) \
$(subst --no-locals, --release, \
$(filter-out --core-library --multi-dex,$(PRIVATE_DX_FLAGS))) \
- $<
+ $$(find $(dir $@)d8_input -name *.class | sort)
+$(hide) rm -fr $(dir $@)d8_input
endef
# Create a mostly-empty .jar file that we'll add to later.