diff --git a/core/definitions.mk b/core/definitions.mk index 3da5d90d9..e8ec8a74f 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1480,7 +1480,6 @@ endef define transform-java-to-classes.jar @echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH)) -$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) endef # Override the above definitions if we want to do incremetal javac @@ -1613,12 +1612,27 @@ cp $(PRIVATE_DEX_FILE) $$_adtp_classes_dex && \ $(AAPT) add -k $@ $$_adtp_classes_dex && rm -f $$_adtp_classes_dex) endef +# Add java resources added by the current module. +# define add-java-resources-to-package $(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(dir $@)jar-arg-list) $(hide) jar uf $@ @$(dir $@)jar-arg-list @rm -f $(dir $@)jar-arg-list endef +# Add java resources carried by static Java libraries. +# +define add-carried-java-resources +$(hide) if [ -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) ] ; then \ + java_res_jar_flags=$$(find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -type f -a -not -name "*.class" \ + | sed -e "s?^$(PRIVATE_CLASS_INTERMEDIATES_DIR)/? -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ?"); \ + if [ -n "$$java_res_jar_flags" ] ; then \ + echo $$java_res_jar_flags >$(dir $@)java_res_jar_flags; \ + jar uf $@ $$java_res_jar_flags; \ + fi; \ +fi +endef + # Sign a package using the specified key/cert. # define sign-package diff --git a/core/host_java_library.mk b/core/host_java_library.mk index 6cc0b1f4e..5930da62b 100644 --- a/core/host_java_library.mk +++ b/core/host_java_library.mk @@ -82,6 +82,7 @@ $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) | $(AAPT) @echo "Host Jar: $(PRIVATE_MODULE) ($@)" $(create-empty-package) $(add-dex-to-package) + $(add-carried-java-resources) ifneq ($(extra_jar_args),) $(add-java-resources-to-package) endif diff --git a/core/java_library.mk b/core/java_library.mk index 06cdfc45e..58d9ba656 100644 --- a/core/java_library.mk +++ b/core/java_library.mk @@ -67,6 +67,7 @@ $(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(AAPT) @echo "target Jar: $(PRIVATE_MODULE) ($@)" $(create-empty-package) $(add-dex-to-package) + $(add-carried-java-resources) ifneq ($(extra_jar_args),) $(add-java-resources-to-package) endif diff --git a/core/package.mk b/core/package.mk index acb8df4ba..fac954992 100644 --- a/core/package.mk +++ b/core/package.mk @@ -376,6 +376,7 @@ endif ifneq ($(full_classes_jar),) $(add-dex-to-package) endif + $(add-carried-java-resources) ifneq ($(extra_jar_args),) $(add-java-resources-to-package) endif