summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2011-12-15 16:36:55 -0800
committerYing Wang <wangying@google.com>2011-12-15 16:36:55 -0800
commit5758b8ed96783861c72b94a822c0ed581f414388 (patch)
tree5399ec6f281fc3ca327d864cbc507883c78c19b4 /core
parentbf6c611cae9c8c3540bed07cd3864026a48ca229 (diff)
downloadbuild-5758b8ed96783861c72b94a822c0ed581f414388.zip
build-5758b8ed96783861c72b94a822c0ed581f414388.tar.gz
build-5758b8ed96783861c72b94a822c0ed581f414388.tar.bz2
Remove the R/Manifest classes when building the static Java library
Bug: 5448433 Instead of deferring the removal to building the app. In that case any R/Manifest classes in any static Java libraries will be deleted, no matter if they are generated from Android resource, or just source R.java/Manifest.java in the source tree by accident. Change-Id: I656f45e3cbc3796c5d4832363231480b3f1dc5b8
Diffstat (limited to 'core')
-rw-r--r--core/definitions.mk8
-rw-r--r--core/host_java_library.mk2
-rw-r--r--core/java.mk1
-rw-r--r--core/static_java_library.mk8
4 files changed, 15 insertions, 4 deletions
diff --git a/core/definitions.mk b/core/definitions.mk
index 60cd063..b7a74b6 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1408,9 +1408,6 @@ endef
# For a list of jar files, unzip them to a specified directory,
# but make sure that no META-INF files come along for the ride.
-# We also remove any R.class/Manifest.class from the jar files;
-# R/Manifest class for the static Java libraries should be
-# re-generate in the app module instead.
#
# $(1): files to unzip
# $(2): destination directory
@@ -1424,7 +1421,6 @@ define unzip-jar-files
unzip -qo $$f -d $(2); \
(cd $(2) && rm -rf META-INF); \
done
- # $(hide) find $(2) -name 'R.class' -o -name 'R$$*.class' -o -name 'Manifest.class' -o -name 'Manifest$$*.class' | xargs rm -rf
endef
# Common definition to invoke javac on the host and target.
@@ -1464,6 +1460,10 @@ $(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; the
fi
$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list
$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+$(if $(PRIVATE_JAR_EXCLUDE_FILES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
+ -name $(word 1, $(PRIVATE_JAR_EXCLUDE_FILES)) \
+ $(addprefix -o -name , $(wordlist 2, 999, $(PRIVATE_JAR_EXCLUDE_FILES))) \
+ | xargs rm -rf)
$(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \
$@ $(PRIVATE_JAR_MANIFEST) -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .
endef
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 322d10f..6cc0b1f 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -52,6 +52,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): \
$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
$(transform-host-java-to-package)
@@ -87,6 +88,7 @@ endif
else
$(LOCAL_BUILT_MODULE): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
+$(LOCAL_BUILT_MODULE): PRIVATE_JAR_EXCLUDE_FILES :=
$(LOCAL_BUILT_MODULE): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
$(transform-host-java-to-package)
endif # LOCAL_BUILD_HOST_DEX
diff --git a/core/java.mk b/core/java.mk
index 47f7b41..e726bb0 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -249,6 +249,7 @@ ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
# Deps for generated source files must be handled separately,
# via deps on the target that generates the sources.
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file) \
$(RenderScript_file_stamp) $(proto_java_sources_file_stamp)
$(transform-java-to-classes.jar)
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index 3a1925d..d317691 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -34,6 +34,13 @@ all_resources := $(strip \
) \
) \
))
+
+ifneq (,$(all_resources))
+# Those files will be excluded from the built jar.
+# The R/Manifest classes should be re-generated in the app Module instead.
+# Use '' and $ escape because they will be passed to bash.
+LOCAL_JAR_EXCLUDE_FILES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class'
+endif
endif
include $(BUILD_SYSTEM)/java_library.mk
@@ -93,3 +100,4 @@ endif
endif # $(all_resources) not empty
LOCAL_IS_STATIC_JAVA_LIBRARY :=
+LOCAL_JAR_EXCLUDE_FILES :=