Support <dir>:<file> for LOCAL_JAVA_RESOURCE_FILES
Support the same syntax as LOCAL_TEST_DATA for
LOCAL_JAVA_RESOURCE_FILES to allow placing files at a subdirectory
in the jar file by replacing the / before the first path element
to be included with a :.
Test: m -j checkbuild
Test: out/build-${TARGET_PRODUCT}.ninja is the same
Change-Id: I83f3d45bdd156200308dc7ed0e0fea5d895d37a6
diff --git a/core/java_common.mk b/core/java_common.mk
index dcd3603..0305eb5 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -105,12 +105,18 @@
java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
endif # LOCAL_JAVA_RESOURCE_DIRS
-LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
- java_resource_file_groups += \
- $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
- $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
- )
+ # Converts LOCAL_JAVA_RESOURCE_FILES := <file> to $(dir $(file))::$(notdir $(file))
+ # and LOCAL_JAVA_RESOURCE_FILES := <dir>:<file> to <dir>::<file>
+ java_resource_file_groups += $(strip $(foreach res,$(LOCAL_JAVA_RESOURCE_FILES), \
+ $(eval _file := $(call word-colon,2,$(res))) \
+ $(if $(_file), \
+ $(eval _base := $(call word-colon,1,$(res))), \
+ $(eval _base := $(dir $(res))) \
+ $(eval _file := $(notdir $(res)))) \
+ $(if $(filter /%,$(_base) $(_file)),$(call pretty-error,LOCAL_JAVA_RESOURCE_FILES may not include absolute paths: $(_base) $(_file))) \
+ $(patsubst %/,%,$(_base))::$(_file)))
+
endif # LOCAL_JAVA_RESOURCE_FILES
ifdef java_resource_file_groups