OSDN Git Service

Allow java targets to support 1.8 source / target
authorNeil Fuller <nfuller@google.com>
Sat, 16 Jan 2016 03:41:26 +0000 (19:41 -0800)
committerNeil Fuller <nfuller@google.com>
Wed, 3 Feb 2016 17:08:39 +0000 (17:08 +0000)
This change enables build rules to specify:

LOCAL_JAVA_LANGUAGE_VERSION := 1.8

to enable -source 1.8 -target 1.8 for javac and
equivalent flags for Jack.

Bug: 26753820
(cherry-picked from commit cdfbe4a8522b9a13ffe6ac1f826a1d6760f87d60)

Change-Id: I361c99dd599e7b4a041f02c9562e461da2b0502e

core/clear_vars.mk
core/combo/javac.mk
core/java_common.mk

index 49e56c4..c431792 100644 (file)
@@ -337,6 +337,7 @@ LOCAL_CLANG_32:=
 LOCAL_CLANG_64:=
 LOCAL_INIT_RC_32:=
 LOCAL_INIT_RC_64:=
+LOCAL_JAVA_LANGUAGE_VERSION:=
 
 # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
 # iterate over thousands of entries every time.
index 70dae13..7f66ea8 100644 (file)
@@ -14,7 +14,7 @@ ifndef ANDROID_COMPILE_WITH_JACK
 ANDROID_COMPILE_WITH_JACK := true
 endif
 
-common_jdk_flags := -source 1.7 -target 1.7 -Xmaxerrs 9999999
+common_jdk_flags := -Xmaxerrs 9999999
 
 # Use the indexer wrapper to index the codebase instead of the javac compiler
 ifeq ($(ALTERNATE_JAVAC),)
index aee3193..34c67dc 100644 (file)
@@ -1,6 +1,14 @@
 # Common to host and target Java modules.
 
 ###########################################################
+## Java version
+###########################################################
+ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION))
+  LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+endif
+LOCAL_JAVACFLAGS += -source $(LOCAL_JAVA_LANGUAGE_VERSION) -target $(LOCAL_JAVA_LANGUAGE_VERSION)
+
+###########################################################
 ## .proto files: Compile proto files to .java
 ###########################################################
 proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
@@ -265,6 +273,8 @@ ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \
 ifdef LOCAL_JACK_ENABLED
 ifdef need_compile_java
 
+LOCAL_JACK_FLAGS += -D jack.java.source.version=$(LOCAL_JAVA_LANGUAGE_VERSION)
+
 full_static_jack_libs := \
     $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
       $(call intermediates-dir-for, \