Merge "Add rule to enable running Jetifier within Make against Java modules"

This commit is contained in:
TreeHugger Robot 2018-02-20 23:35:10 +00:00 committed by Android (Google) Code Review
commit 0710ca2056
5 changed files with 53 additions and 4 deletions

View File

@ -135,6 +135,7 @@ LOCAL_JAVA_LAYERS_FILE:=
LOCAL_JAVA_LIBRARIES:=
LOCAL_JAVA_RESOURCE_DIRS:=
LOCAL_JAVA_RESOURCE_FILES:=
LOCAL_JETIFIER_ENABLED:=
LOCAL_JNI_SHARED_LIBRARIES:=
LOCAL_JNI_SHARED_LIBRARIES_ABI:=
LOCAL_LDFLAGS:=

View File

@ -676,6 +676,8 @@ RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation
FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
FINDBUGS := $(FINDBUGS_DIR)/findbugs
JETIFIER := prebuilts/sdk/tools/jetifier/jetifier-standalone/bin/jetifier-standalone
# Tool to merge AndroidManifest.xmls
ANDROID_MANIFEST_MERGER_CLASSPATH := \
prebuilts/gradle-plugin/com/android/tools/build/manifest-merger/26.0.0-beta2/manifest-merger-26.0.0-beta2.jar \

View File

@ -97,10 +97,16 @@ $(full_classes_combined_jar): $(full_classes_compiled_jar) \
$(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \
-stripDir META-INF -zipToNotStrip $< $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
#######################################
LOCAL_JETIFIER_INPUT_FILE := $(full_classes_combined_jar)
include $(BUILD_SYSTEM)/jetifier.mk
#######################################
# Run jarjar if necessary, otherwise just copy the file.
ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
$(full_classes_jarjar_jar): $(LOCAL_JETIFIER_OUTPUT_FILE) $(LOCAL_JARJAR_RULES) | $(JARJAR)
@echo JarJar: $@
$(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
else
@ -108,9 +114,9 @@ full_classes_jarjar_jar := $(full_classes_combined_jar)
endif
#######################################
LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jarjar_jar)
#######################################
include $(BUILD_SYSTEM)/jacoco.mk
#######################################

View File

@ -557,11 +557,17 @@ else
full_classes_jarjar_jar := $(full_classes_processed_jar)
endif
$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
#######################################
LOCAL_JETIFIER_INPUT_FILE := $(full_classes_jarjar_jar)
LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar)
include $(BUILD_SYSTEM)/jetifier.mk
#######################################
$(eval $(call copy-one-file,$(LOCAL_JETIFIER_OUTPUT_FILE),$(full_classes_jar)))
#######################################
LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar)
include $(BUILD_SYSTEM)/jacoco.mk
#######################################

34
core/jetifier.mk Normal file
View File

@ -0,0 +1,34 @@
#
# Copyright (C) 2018 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file sets up the running of Jetifier
# now add the rule to run jetifier
ifeq ($(strip $(LOCAL_JETIFIER_ENABLED)),true)
my_jetifier_input_path := $(LOCAL_JETIFIER_INPUT_FILE)
my_files := $(intermediates.COMMON)/jetifier
my_jetifier_output_path := $(my_files)/classes-jetifier.jar
$(my_jetifier_output_path) : $(my_jetifier_input_path) $(JETIFIER)
rm -rf $@
$(JETIFIER) -outputfile $@ -i $<
LOCAL_JETIFIER_OUTPUT_FILE := $(my_jetifier_output_path)
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_JETIFIER_OUTPUT_FILE)
else
LOCAL_JETIFIER_OUTPUT_FILE := $(LOCAL_JETIFIER_INPUT_FILE)
endif