summaryrefslogtreecommitdiff
path: root/JavaLibrary.bp
diff options
context:
space:
mode:
Diffstat (limited to 'JavaLibrary.bp')
-rw-r--r--JavaLibrary.bp579
1 files changed, 481 insertions, 98 deletions
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 378aca231a..2066c42bee 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -13,29 +13,35 @@
// limitations under the License.
//
-// Definitions for building the Java library and associated tests.
+// Definitions for building the Android core library and associated tests.
//
-// libcore is divided into modules.
+// The Android core library provides low-level APIs for use by the rest of the
+// Android software stack. It is made up of various parts, some of which can be
+// found in libcore/ and other parts that can be found in various external/
+// directories. See the "core-system-modules" definition for the parts.
+
+// libcore has some sub-directories that follow a common structure:
+// e.g. dalvik, dom, harmony-tests, json, jsr166-tests, luni, libart, ojluni,
+// support, xml, xmlpull.
//
-// The structure of each module is:
+// The structure of these is generally:
//
// src/
// main/ # To be shipped on every device.
// java/ # Java source for library code.
-// native/ # C++ source for library code.
+// native/ # C/C++ source for library code.
// resources/ # Support files.
// test/ # Built only on demand, for testing.
// java/ # Java source for tests.
-// native/ # C++ source for tests (rare).
+// native/ # C/C++ source for tests (rare).
// resources/ # Support files.
//
-// All subdirectories are optional
+// All subdirectories are optional.
build = [
"openjdk_java_files.bp",
"non_openjdk_java_files.bp",
- "annotated_java_files.bp",
]
// The Java files and their associated resources.
@@ -44,6 +50,71 @@ core_resource_dirs = [
"ojluni/src/main/resources/",
]
+// The source files that go into core-oj.
+filegroup {
+ name: "core_oj_java_files",
+ srcs: [":openjdk_java_files"],
+}
+
+// OpenJDK source is not annotated with @hide so we need this separate
+// filegroup for just the parts that contribute to the API.
+filegroup {
+ name: "core_oj_api_files",
+ srcs: [":openjdk_javadoc_files"],
+}
+
+// The source files that go into core-libart.
+filegroup {
+ name: "core_libart_java_files",
+ srcs: [
+ ":non_openjdk_java_files",
+ ":android_icu4j_src_files",
+ ],
+}
+
+// Some parts of libart are not annotated with @hide so we need this separate
+// filegroup for just the parts that contribute to the API.
+filegroup {
+ name: "core_libart_api_files",
+ srcs: [
+ ":non_openjdk_javadoc_files",
+ ":android_icu4j_src_files",
+ ],
+}
+
+// The set of files for the core library that have been marked up with @hide
+// for the public SDK APIs. Used from frameworks/base/ to indicate the source
+// files for inclusion in the public SDK docs.
+filegroup {
+ name: "core_public_api_files",
+ srcs: [
+ ":core_oj_api_files",
+ ":core_libart_api_files",
+ ":conscrypt_public_api_files",
+ ],
+}
+
+// The set of files for the core library that have been marked up with @hide and
+// API-related annotations. Note that this includes the intra-core and
+// core-platform APIs as well as the public APIs.
+//
+// Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are
+// annotated by applying annotations to the .annotated.java stubs files in
+// ojluni/annotated/mmodules and rather than in the original source. See the comments
+// in openjdk_java_files.bp for more details.
+filegroup {
+ name: "core_api_files",
+ srcs: [
+ ":apache-xml_api_files",
+ ":bouncycastle_java_files",
+ ":conscrypt_java_files",
+ ":core_oj_api_files",
+ ":core_libart_api_files",
+ ":okhttp_api_files",
+ ":openjdk_mmodule_extra_files",
+ ],
+}
+
java_defaults {
name: "libcore_java_defaults",
javacflags: [
@@ -51,10 +122,10 @@ java_defaults {
//"-Xlint:-serial,-deprecation,-unchecked",
],
dxflags: ["--core-library"],
- no_standard_libs: true,
errorprone: {
javacflags: [
"-Xep:MissingOverride:OFF", // Ignore missing @Override.
+ "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
],
},
}
@@ -63,50 +134,75 @@ java_defaults {
// Build for the target (device).
//
+// Rule generating resource lib for android_icu4j.
+// In the downstream branch master-icu-dev, the resource files are generated.
+// This rule can't be moved external/icu because soong enforces that no_standard_libs:true can only
+// be used in libcore/ or development/
+java_library {
+ name: "android_icu4j_resources_lib",
+ java_resources: [":android_icu4j_resources"],
+ no_standard_libs: true,
+ system_modules: "none",
+}
+
+// A target used to bootstrap compilation for the core library.
+// See core-all-system-modules for more details.
java_library {
name: "core-all",
defaults: ["libcore_java_defaults"],
srcs: [
- ":openjdk_java_files",
- ":non_openjdk_java_files",
- ":android_icu4j_src_files",
+ ":core_oj_java_files",
+ ":core_libart_java_files",
":openjdk_lambda_stub_files",
],
+
+ no_standard_libs: true,
+ system_modules: "none",
openjdk9: {
srcs: ["luni/src/module/java/module-info.java"],
javacflags: ["--patch-module=java.base=."],
},
- java_resource_dirs: core_resource_dirs,
- java_resources: [":android_icu4j_resources"],
-
- required: [
- "tzdata",
- "tzlookup.xml",
- ],
- system_modules: "none",
+ java_resource_dirs: core_resource_dirs,
+ static_libs: ["android_icu4j_resources_lib"],
+ java_version: "1.9",
installable: false,
}
+// A system modules definition for use by core library targets only. It only
+// contains the core-all jar, which contains the classes that end up in core-oj,
+// core-libart as well as the lambda stubs needed to compile Java lambda code.
+// It does not contain other parts of core library like conscrypt, bouncycastle,
+// etc. This system_modules definition is used to bootstrap compilation for
+// other parts of the core library like core-oj, core-libart, conscrypt,
+// bouncycastle, etc.
+//
+// If you want to compile against the entire core library implementation, for
+// example to build core library tests, see "core-system-modules" instead.
java_system_modules {
name: "core-all-system-modules",
libs: ["core-all"],
}
+// Contains the parts of core library associated with OpenJDK.
java_library {
name: "core-oj",
defaults: ["libcore_java_defaults"],
+ installable: true,
hostdex: true,
- srcs: [":openjdk_java_files"],
+ srcs: [":core_oj_java_files"],
java_resource_dirs: core_resource_dirs,
+
+ no_standard_libs: true,
libs: ["core-all"],
system_modules: "core-all-system-modules",
openjdk9: {
javacflags: ["--patch-module=java.base=."],
},
+
jacoco: {
exclude_filter: [
"java.lang.Class",
@@ -126,30 +222,28 @@ java_library {
notice: "ojluni/NOTICE",
- required: [
- "tzdata",
- "tzlookup.xml",
- ],
-
}
-// Definitions to make the core library.
+// Contains parts of core library not associated with OpenJDK. Contains not
+// just java.*, javax.* code but also android.icu.*, android.system.* and
+// various internal libcore.* packages.
java_library {
name: "core-libart",
defaults: ["libcore_java_defaults"],
+ installable: true,
hostdex: true,
- srcs: [
- ":non_openjdk_java_files",
- ":android_icu4j_src_files",
- ],
- java_resources: [":android_icu4j_resources"],
+ srcs: [":core_libart_java_files"],
+ static_libs: ["android_icu4j_resources_lib"],
+ java_version: "1.9",
+ no_standard_libs: true,
libs: ["core-all"],
system_modules: "core-all-system-modules",
openjdk9: {
javacflags: ["--patch-module=java.base=."],
},
+
jacoco: {
exclude_filter: [
"java.lang.DexCache",
@@ -158,16 +252,46 @@ java_library {
},
required: [
+ // Device files put in /system.
"tzdata",
- "tzlookup.xml",
+ "tz_version",
+ // Files used to simulate the /system and runtime APEX dir
+ // structure on host.
+ "tzdata_host",
+ "tzdata_host_runtime_apex",
+ "tzlookup.xml_host_runtime_apex",
+ "tz_version_host",
+ "tz_version_host_runtime_apex",
],
}
-// A guaranteed unstripped version of core-oj and core-libart.
+// Provided solely to contribute information about which hidden parts of the
+// core-oj API are used by apps.
+java_library {
+ name: "core-oj-hiddenapi",
+ defaults: ["libcore_java_defaults"],
+ compile_dex: true,
+
+ srcs: [":openjdk_hiddenapi_javadoc_files"],
+
+ no_standard_libs: true,
+ libs: ["core-all"],
+ system_modules: "core-all-system-modules",
+ openjdk9: {
+ javacflags: ["--patch-module=java.base=."],
+ },
+}
+
+//
+// Guaranteed unstripped versions of core-oj and core-libart.
+//
// The build system may or may not strip the core-oj and core-libart jars,
// but these will not be stripped. See b/24535627.
+//
+
java_library {
name: "core-oj-testdex",
+ installable: true,
static_libs: ["core-oj"],
no_standard_libs: true,
libs: ["core-all"],
@@ -176,15 +300,13 @@ java_library {
dex_preopt: {
enabled: false,
},
+ java_version: "1.9",
notice: "ojluni/NOTICE",
- required: [
- "tzdata",
- "tzlookup.xml",
- ],
}
java_library {
name: "core-libart-testdex",
+ installable: true,
static_libs: ["core-libart"],
no_standard_libs: true,
libs: ["core-all"],
@@ -194,23 +316,15 @@ java_library {
enabled: false,
},
notice: "ojluni/NOTICE",
- required: [
- "tzdata",
- "tzlookup.xml",
- ],
}
-// A library that exists to satisfy javac when
-// compiling source code that contains lambdas.
-java_library {
- name: "core-lambda-stubs",
- defaults: ["libcore_java_defaults"],
- srcs: [
- ":openjdk_lambda_stub_files",
- ":openjdk_lambda_duplicate_stub_files",
- ],
+java_defaults {
+ name: "core_lambda_stubs_defaults",
+ defaults: ["libcore_java_defaults"],
+ hostdex: true,
+ no_standard_libs: true,
libs: ["core-all"],
system_modules: "core-all-system-modules",
openjdk9: {
@@ -223,99 +337,368 @@ java_library {
include_srcs: true,
}
+// Creates a jar that exists to satisfy javac when compiling source code that
+// contains lambdas. This contains all classes / methods required by javac
+// when generating invoke-dynamic lambda implementation code, even those that
+// are also in the public SDK API from API level 26 onwards.
+java_library {
+ name: "core-lambda-stubs",
+ defaults: ["core_lambda_stubs_defaults"],
+ srcs: [
+ ":openjdk_lambda_stub_files",
+ ":openjdk_lambda_duplicate_stub_files",
+ ],
+}
+
+// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files
+// because those classes are also part of the core library public SDK API
+// (since API level 26).
+java_library {
+ name: "core-lambda-stubs-for-system-modules",
+ defaults: ["core_lambda_stubs_defaults"],
+ srcs: [
+ ":openjdk_lambda_stub_files",
+ ],
+}
+
+// A system modules definition containing the implementations for the various
+// parts that make up the core library.
+//
+// This system module is intended for use by tests that may need access to
+// core library internals. It should not be generally used; most of the
+// platform build should build against API stubs instead. See
+// "core-platform-api-stubs-system-modules", which is the default used by the
+// Android build.
+//
+// This module also includes lambda stubs for compiling source containing
+// Java lambdas.
java_system_modules {
name: "core-system-modules",
libs: [
"core-oj",
"core-libart",
- "core-lambda-stubs",
+ "bouncycastle",
+ "conscrypt",
+ "okhttp",
+ "apache-xml",
+ // This one is not on device but it's needed when javac compiles code
+ // containing lambdas.
+ "core-lambda-stubs-for-system-modules",
],
}
-// Build libcore test rules
+// Builds libcore test rules
java_library_static {
name: "core-test-rules",
hostdex: true,
- no_framework_libs: true,
srcs: [
"dalvik/test-rules/src/main/**/*.java",
"test-rules/src/main/**/*.java",
],
static_libs: ["junit"],
+
+ no_standard_libs: true,
+ libs: ["core-all"],
+ system_modules: "core-all-system-modules",
}
-// Make the core-tests-support library.
+// Builds the core-tests-support library used by various tests.
java_library_static {
name: "core-tests-support",
hostdex: true,
- no_framework_libs: true,
srcs: ["support/src/test/java/**/*.java"],
- libs: [
- "junit",
- "bouncycastle",
- ],
+
+ no_framework_libs: true,
+ libs: ["junit"],
static_libs: [
- "bouncycastle-bcpkix",
- "bouncycastle-ocsp",
+ "bouncycastle-unbundled",
+ "bouncycastle-bcpkix-unbundled",
+ "bouncycastle-ocsp-unbundled",
],
}
-// Make the jsr166-tests library.
-java_library_static {
+// Builds the jsr166-tests library.
+java_test {
name: "jsr166-tests",
srcs: ["jsr166-tests/src/test/java/**/*.java"],
- no_framework_libs: true,
+ no_standard_libs: true,
libs: [
+ "core-all",
"junit",
],
+ system_modules: "core-all-system-modules",
+}
+
+// Builds a library just containing files from luni/src/test/filesystems
+// for use in tests.
+java_library {
+ name: "filesystemstest",
+ compile_dex: true,
+ srcs: ["luni/src/test/filesystems/src/**/*.java"],
+ java_resource_dirs: ["luni/src/test/filesystems/resources"],
+ no_framework_libs: true,
+ errorprone: {
+ javacflags: ["-Xep:MissingOverride:OFF"],
+ },
}
-genrule {
- name: "gen-ojluni-jaif-annotated-srcs",
- tools: [
- "gen-annotated-java-files-bp",
- "soong_zip",
+// Builds a library just containing files from luni/src/test/parameter_metadata
+// for use in tests.
+java_library {
+ name: "parameter-metadata-test",
+ compile_dex: true,
+ srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
+ no_framework_libs: true,
+ javacflags: ["-parameters"],
+ errorprone: {
+ javacflags: ["-Xep:MissingOverride:OFF"],
+ },
+}
+
+// Builds the core-tests library.
+java_test {
+ name: "core-tests",
+ defaults: ["libcore_java_defaults"],
+ hostdex: true,
+ srcs: [
+ "dalvik/src/test/java/**/*.java",
+ "dalvik/test-rules/src/test/java/**/*.java",
+ "dom/src/test/java/**/*.java",
+ "harmony-tests/src/test/java/**/*.java",
+ "json/src/test/java/**/*.java",
+ "luni/src/test/java/**/*.java",
+ "test-rules/src/test/java/**/*.java",
+ "xml/src/test/java/**/*.java",
+ ],
+ exclude_srcs: [
+ "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
+ "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
],
- tool_files: [
- ":insert-annotations-to-source",
- "annotations/ojluni.jaif",
+
+ java_resource_dirs: [
+ "*/src/test/java",
+ "*/src/test/resources",
+ ],
+ exclude_java_resource_dirs: [
+ "ojluni/src/test/java",
+ "ojluni/src/test/resources",
+ ],
+
+ java_resources: [
+ ":filesystemstest",
+ ":parameter-metadata-test",
],
+
+ no_standard_libs: true,
+ libs: [
+ "core-all",
+ "okhttp",
+ "bouncycastle",
+ ],
+ system_modules: "core-all-system-modules",
+
+ static_libs: [
+ "archive-patcher",
+ "core-test-rules",
+ "core-tests-support",
+ "junit-params",
+ "mockftpserver",
+ "mockito-target",
+ "mockwebserver",
+ "nist-pkix-tests",
+ "slf4j-jdk14",
+ "sqlite-jdbc",
+ "tzdata-testing",
+ "truth-prebuilt",
+ ],
+
+ errorprone: {
+ javacflags: [
+ "-Xep:TryFailThrowable:ERROR",
+ "-Xep:ComparisonOutOfRange:ERROR",
+ ],
+ },
+
+ test_config: "AndroidTest-core-tests.xml",
+}
+
+// Builds the core-ojtests library that contains test code from OpenJDK.
+java_test {
+ name: "core-ojtests",
+ defaults: ["libcore_java_defaults"],
+ hostdex: true,
+
srcs: [
- ":annotated_ojluni_files",
+ "ojluni/src/test/java/**/*.java",
],
- cmd: "($(location gen-annotated-java-files-bp) $(location annotations/ojluni.jaif) > $(genDir)/annotated_java_files.bp.tmp) && " +
- "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " +
- "(echo -e \"********************\" >&2; " +
- " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " +
- " echo -e \"libcore/annotations/generate_annotated_java_files.py libcore/annotations/ojluni.jaif > libcore/annotated_java_files.bp\" >&2; " +
- " echo -e \"********************\" >&2; exit 1) ) && " +
- "(rm $(genDir)/annotated_java_files.bp.tmp) && " +
- "(external/annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source -d $(genDir) $(location annotations/ojluni.jaif) $(in)) && " +
- "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
- out: [
- "ojluni_jaif_annotated_srcs.srcjar",
+ java_resource_dirs: [
+ "ojluni/src/test/java",
+ "ojluni/src/test/resources",
+ ],
+
+ no_standard_libs: true,
+ libs: [
+ "core-all",
+ "okhttp",
+ "bouncycastle",
],
+ system_modules: "core-all-system-modules",
+
+ static_libs: ["testng"],
+
+ // ojluni/src/test/java/util/stream/{bootlib,boottest}
+ // contains tests that are in packages from java.base;
+ // By default, OpenJDK 9's javac will only compile such
+ // code if it's declared to also be in java.base at
+ // compile time.
+ //
+ // For now, we use --patch-module to put all sources
+ // and dependencies from this make target into java.base;
+ // other source directories in this make target are in
+ // packages not from java.base; if this becomes a problem
+ // in future, this could be addressed eg. by splitting
+ // boot{lib,test} out into a separate make target,
+ // deleting those tests or moving them to a different
+ // package.
+ patch_module: "java.base",
}
-droiddoc {
- name: "core-docs",
+// Builds the core-ojtests-public library. Excludes any private API tests.
+// Like core-ojtests but smaller.
+java_test {
+ name: "core-ojtests-public",
+ defaults: ["libcore_java_defaults"],
srcs: [
- ":openjdk_javadoc_files",
- ":non_openjdk_javadoc_files",
- ":android_icu4j_src_files_for_docs",
- ":gen-ojluni-jaif-annotated-srcs",
+ "ojluni/src/test/java/**/*.java",
],
+ // Filter out the following:
+ // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
+ // and won't actually run, and
+ // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
+ // excluding them means we don't need patch_module: "java.base"
exclude_srcs: [
- ":annotated_ojluni_files",
+ "**/DeserializeMethodTest.java",
+ "**/SerializedLambdaTest.java",
+ "ojluni/src/test/java/util/stream/boot*/**/*",
+ ],
+ java_resource_dirs: [
+ "ojluni/src/test/java",
+ "ojluni/src/test/resources",
+ // Include source code as part of JAR
+ "ojluni/src/test/dist",
],
- custom_template: "droiddoc-templates-sdk",
- hdf: [
- "android.whichdoc offline",
+
+ no_standard_libs: true,
+ libs: [
+ "core-all",
+ "bouncycastle",
+ "okhttp",
+ "testng",
],
- knowntags: [
+ system_modules: "core-all-system-modules",
+}
+
+// Exports annotated stubs source files in ojluni/annotations/sdk to make them
+// available to metalava. Used for nullability annotations in OpenJDK source.
+droiddoc_exported_dir {
+ name: "ojluni-annotated-sdk-stubs",
+ path: "ojluni/annotations/sdk",
+}
+droiddoc_exported_dir {
+ name: "ojluni-annotated-nullability-stubs",
+ path: "ojluni/annotations/sdk/nullability",
+}
+
+// Exports annotated stubs source files in ojluni/annotations/mmodules to make
+// them available to metalava. Used for core platform API and intra-code API
+// annotations in OpenJDK source.
+droiddoc_exported_dir {
+ name: "ojluni-annotated-mmodule-stubs",
+ path: "ojluni/annotations/mmodule",
+}
+
+// A file containing the list of tags that are "known" to us from the OpenJdk
+// source code and so should not cause an error or warning.
+filegroup {
+ name: "known-oj-tags",
+ srcs: [
"known_oj_tags.txt",
],
- proofread_file: "core-docs-proofread.txt",
- todo_file: "core-docs-todo.html",
- args: "-offlinemode -title \"libcore\"",
+}
+
+// Generates stubs for the parts of the public SDK API provided by the core
+// library.
+//
+// Only for use by core.current.stubs target below.
+droidstubs {
+ name: "core-current-stubs-gen",
+ srcs: [":core_api_files"],
+ java_version: "1.9",
+ installable: false,
+ no_framework_libs: true,
+ args: " --exclude-annotations "
+ + "--hide-annotation libcore.api.Hide",
+ merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
+}
+
+// A stubs target containing the parts of the public SDK API provided by the
+// core library.
+//
+// Don't use this directly, use "sdk_version: core_current".
+java_library {
+ name: "core.current.stubs",
+ srcs: [":core-current-stubs-gen"],
+ errorprone: {
+ javacflags: [
+ "-Xep:MissingOverride:OFF",
+ ],
+ },
+ openjdk9: {
+ javacflags: ["--patch-module=java.base=."],
+ },
+ no_standard_libs: true,
+ system_modules: "none",
+
+ dist: {
+ targets: [
+ "sdk",
+ "win_sdk",
+ ],
+ },
+}
+
+// Target for validating nullability annotations for correctness and
+// completeness. To check that there are no nullability errors:
+// make core-current-stubs-nullability-validation
+// To check that there are only the expected nullability warnings:
+// make core-current-stubs-nullability-validation-check-nullability-warnings
+// To update the the list of known expected nullability warnings:
+// make core-current-stubs-nullability-validation-update-nullability-warnings
+droidstubs {
+ name: "core-current-stubs-nullability-validation",
+ srcs: [":core_api_files"],
+ installable: false,
+ no_framework_libs: true,
+ annotations_enabled: true,
+ args: "--hide-annotation libcore.api.Hide " +
+ "--validate-nullability-from-merged-stubs ",
+ merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
+ merge_annotations_dirs: [
+ "metalava-manual",
+ // N.B. Stubs in this filegroup will be validated:
+ "ojluni-annotated-nullability-stubs",
+ ],
+ // The list of classes which have nullability annotations included in the source.
+ // (This is in addition to those which have annotations in the merged stubs.)
+ validate_nullability_from_list: "nullability_annotated_classes.txt",
+ // The expected set of warnings about missing annotations:
+ check_nullability_warnings: "nullability_warnings.txt",
+}
+
+// A host library containing time zone related classes. Used for
+// host-side tools and tests that have to deal with Android
+// time zone data.
+java_library_host {
+ name: "timezone-host",
+ srcs: [":timezone_host_files"],
}