Revert "Revert "Copy resources from classes.jar when using AAPT2""

This reverts commit a7e336d17a4a59d908e4bae53da2a12f455b12dc.

Reapplies I6649f7f2fbf63ff5001f4731e22960f857726c70 with fix
for jack builds.

Bug: 64272170
Test: https://android-build.googleplex.com/builds/view-workplan?viewType=Table&workplanId=L93000000088657848&nodeType=Trybot
Change-Id: Id66aebfc2c26a4467e6cf25e4372080882f0b286
Merged-In: Id66aebfc2c26a4467e6cf25e4372080882f0b286
(cherry picked from commit 6fedebf9364e5af731aafc7c1a529f2e27c6725f)
diff --git a/core/definitions.mk b/core/definitions.mk
index a36b34c..d3277b5 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2684,6 +2684,17 @@
 fi
 endef
 
+# Add resources (non .class files) from a jar to a package
+# $(1): the package file
+# $(2): the jar file
+# $(3): temporary directory
+define add-jar-resources-to-package
+  rm -rf $(3)
+  mkdir -p $(3)
+  unzip -qo $(2) -d $(3) $$(zipinfo -1 $(2) | grep -v -E "\.class$$")
+  $(JAR) uf $(1) -C $(3) .
+endef
+
 # Sign a package using the specified key/cert.
 #
 define sign-package