diff --git a/core/build-system.html b/core/build-system.html index 95f35ce82..e72e1411b 100644 --- a/core/build-system.html +++ b/core/build-system.html @@ -707,6 +707,11 @@ example.

them here. For example:

LOCAL_JAVACFLAGS += -Xlint:deprecation

+

LOCAL_ERROR_PRONE_FLAGS

+

If you have additional flags to pass into the error prone compiler, add +them here. For example:

+

LOCAL_ERROR_PRONE_FLAGS += -Xep:ClassCanBeStatic:ERROR

+

LOCAL_JAVA_LIBRARIES

When linking Java apps and libraries, LOCAL_JAVA_LIBRARIES specifies which sets of java classes to include. Currently there are diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 85431f565..3619106fa 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -68,6 +68,7 @@ LOCAL_DROIDDOC_USE_STANDARD_DOCLET:= LOCAL_DX_FLAGS:= LOCAL_EMMA_COVERAGE_FILTER:= LOCAL_EMMA_INSTRUMENT:= +LOCAL_ERROR_PRONE_FLAGS:= LOCAL_EXPORT_CFLAGS:= LOCAL_EXPORT_C_INCLUDE_DEPS:= LOCAL_EXPORT_C_INCLUDE_DIRS:= diff --git a/core/host_java_library.mk b/core/host_java_library.mk index 3e70eba4e..f1da55391 100644 --- a/core/host_java_library.mk +++ b/core/host_java_library.mk @@ -58,6 +58,11 @@ include $(BUILD_SYSTEM)/java_common.mk # Run build/tools/java-layers.py for more details. layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) +# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS +ifeq ($(RUN_ERROR_PRONE),true) +LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS) +endif + $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS) $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := diff --git a/core/java.mk b/core/java.mk index bbbec0a3d..f7f7eee41 100644 --- a/core/java.mk +++ b/core/java.mk @@ -418,6 +418,12 @@ $(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE # This intentionally depends on java_sources, not all_java_sources. # Deps for generated source files must be handled separately, # via deps on the target that generates the sources. + +# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS +ifeq ($(RUN_ERROR_PRONE),true) +LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS) +endif + $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS) $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES) $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)