diff --git a/core/definitions.mk b/core/definitions.mk index 80f9520d6..1300115e4 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2228,9 +2228,11 @@ endef # $(2): classpath_libs define compile-java $(hide) rm -f $@ -$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR) +$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR) $(if $(PRIVATE_SRCJARS),$(PRIVATE_SRCJAR_INTERMEDIATES_DIR)) $(hide) mkdir -p $(dir $@) -$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR) +$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR) $(if $(PRIVATE_SRCJARS),$(PRIVATE_SRCJAR_INTERMEDIATES_DIR)) +$(if $(PRIVATE_SRCJARS),\ + $(EXTRACT_SRCJARS) $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) $(PRIVATE_SRCJAR_LIST_FILE) $(PRIVATE_SRCJARS)) $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \ $(SOONG_JAVAC_WRAPPER) $(JAVAC_WRAPPER) $(1) -encoding UTF-8 \ $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ @@ -2250,6 +2252,7 @@ $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \ -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \ $(PRIVATE_JAVACFLAGS) \ \@$(PRIVATE_JAVA_SOURCE_LIST) \ + $(if $(PRIVATE_SRCJARS),\@$(PRIVATE_SRCJAR_LIST_FILE)) \ || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \ fi $(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/make/tools/java-layers.py \ @@ -2278,7 +2281,7 @@ define transform-java-to-header.jar $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \ $(JAVA) -jar $(TURBINE) \ --output $@.premerged --temp_dir $(dir $@)/classes-turbine \ - --sources \@$(PRIVATE_JAVA_SOURCE_LIST) \ + --sources \@$(PRIVATE_JAVA_SOURCE_LIST) --source_jars $(PRIVATE_SRCJARS) \ --javacopts $(PRIVATE_JAVACFLAGS) $(COMMON_JDK_FLAGS) \ $(addprefix --bootclasspath ,$(strip \ $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \ diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk index 20663d159..fc5b75c0c 100644 --- a/core/host_dalvik_java_library.mk +++ b/core/host_dalvik_java_library.mk @@ -76,6 +76,7 @@ java_sources_deps := \ $(java_sources) \ $(java_resource_sources) \ $(proto_java_sources_file_stamp) \ + $(LOCAL_SRCJARS) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(java_source_list_file): $(java_sources_deps) @@ -86,6 +87,9 @@ $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annota $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := +$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) +$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list +$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars $(full_classes_compiled_jar): \ $(java_source_list_file) \ $(java_sources_deps) \ @@ -95,6 +99,7 @@ $(full_classes_compiled_jar): \ $(annotation_processor_deps) \ $(NORMALIZE_PATH) \ $(JAR_ARGS) \ + $(EXTRACT_SRCJARS) \ | $(SOONG_JAVAC_WRAPPER) $(transform-host-java-to-dalvik-package) @@ -102,6 +107,7 @@ ifneq ($(TURBINE_ENABLED),false) $(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) $(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) +$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) $(full_classes_turbine_jar): \ $(java_source_list_file) \ $(java_sources_deps) \ diff --git a/core/host_java_library.mk b/core/host_java_library.mk index 5176f37d6..47a8b02df 100644 --- a/core/host_java_library.mk +++ b/core/host_java_library.mk @@ -63,6 +63,7 @@ java_sources_deps := \ $(java_sources) \ $(java_resource_sources) \ $(proto_java_sources_file_stamp) \ + $(LOCAL_SRCJARS) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(java_source_list_file): $(java_sources_deps) @@ -73,6 +74,9 @@ $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annota $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := +$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) +$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list +$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars $(full_classes_compiled_jar): \ $(java_source_list_file) \ $(java_sources_deps) \ @@ -82,6 +86,7 @@ $(full_classes_compiled_jar): \ $(NORMALIZE_PATH) \ $(ZIPTIME) \ $(JAR_ARGS) \ + $(EXTRACT_SRCJARS) \ | $(SOONG_JAVAC_WRAPPER) $(transform-host-java-to-package) $(remove-timestamps-from-package) diff --git a/core/java.mk b/core/java.mk index d15f4ebfc..0ac7a871d 100644 --- a/core/java.mk +++ b/core/java.mk @@ -401,6 +401,7 @@ java_sources_deps := \ $(java_resource_sources) \ $(RenderScript_file_stamp) \ $(proto_java_sources_file_stamp) \ + $(LOCAL_SRCJARS) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(java_source_list_file): $(java_sources_deps) @@ -409,6 +410,7 @@ $(java_source_list_file): $(java_sources_deps) ifneq ($(TURBINE_ENABLED),false) $(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) +$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) $(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) $(full_classes_turbine_jar): \ $(java_source_list_file) \ @@ -446,6 +448,9 @@ $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUD $(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) $(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file) $(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs) +$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) +$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list +$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars $(full_classes_compiled_jar): \ $(java_source_list_file) \ $(full_java_header_libs) \ @@ -456,6 +461,7 @@ $(full_classes_compiled_jar): \ $(annotation_processor_deps) \ $(NORMALIZE_PATH) \ $(JAR_ARGS) \ + $(EXTRACT_SRCJARS) \ | $(SOONG_JAVAC_WRAPPER) @echo "Target Java: $@ $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES)) diff --git a/core/java_common.mk b/core/java_common.mk index f9ba059ef..dea0435dc 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -188,7 +188,7 @@ endif # LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files, # but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR. # You have to set up the dependency in some other way. -need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)) +need_compile_java := $(strip $(all_java_sources)$(LOCAL_SRCJARS)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)) ifdef need_compile_java annotation_processor_flags := diff --git a/core/package_internal.mk b/core/package_internal.mk index c7392d358..858a1bfb7 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -274,7 +274,7 @@ endif # EMMA_INSTRUMENT is true ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) ifeq (true,$(EMMA_INSTRUMENT_STATIC)) -ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),) +ifneq ($(LOCAL_SRC_FILES)$(LOCAL_SRCJARS)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),) # Only add jacocoagent if the package contains some java code LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent # Exclude jacoco classes from proguard