blob: c6b0855c4123f9c31a5099571a13042d57a4905e [file] [log] [blame]
// Copyright (C) 2007 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.
//
// Definitions for building the Java library and associated tests.
//
// 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 these is generally:
//
// src/
// main/ # To be shipped on every device.
// java/ # Java 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/C++ source for tests (rare).
// resources/ # Support files.
//
// All subdirectories are optional.
build = [
"openjdk_java_files.bp",
"non_openjdk_java_files.bp",
]
// The Java files and their associated resources.
core_resource_dirs = [
"luni/src/main/java",
"ojluni/src/main/resources/",
]
java_defaults {
name: "libcore_java_defaults",
javacflags: [
//"-Xlint:all",
//"-Xlint:-serial,-deprecation,-unchecked",
],
dxflags: ["--core-library"],
errorprone: {
javacflags: [
"-Xep:MissingOverride:OFF", // Ignore missing @Override.
"-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
],
},
}
//
// Build for the target (device).
//
java_library {
name: "core-all",
defaults: ["libcore_java_defaults"],
srcs: [
":openjdk_java_files",
":non_openjdk_java_files",
":android_icu4j_src_files",
":core_simple_mmodule_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",
],
installable: false,
}
java_system_modules {
name: "core-all-system-modules",
libs: ["core-all"],
}
java_library {
name: "core-oj",
defaults: ["libcore_java_defaults"],
installable: true,
hostdex: true,
srcs: [":openjdk_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",
"java.lang.Long",
"java.lang.Number",
"java.lang.Object",
"java.lang.String",
"java.lang.invoke.MethodHandle",
"java.lang.ref.Reference",
"java.lang.reflect.Proxy",
"java.util.AbstractMap",
"java.util.HashMap",
"java.util.HashMap$Node",
"java.util.Map",
],
},
notice: "ojluni/NOTICE",
required: [
"tzdata",
"tzlookup.xml",
],
}
// Definitions to make the core library.
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"],
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",
"dalvik.system.ClassExt",
],
},
required: [
"tzdata",
"tzlookup.xml",
],
}
// A guaranteed unstripped version 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"],
system_modules: "core-all-system-modules",
dxflags: ["--core-library"],
dex_preopt: {
enabled: false,
},
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"],
system_modules: "core-all-system-modules",
dxflags: ["--core-library"],
dex_preopt: {
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",
],
no_standard_libs: true,
libs: ["core-all"],
system_modules: "core-all-system-modules",
openjdk9: {
javacflags: ["--patch-module=java.base=."],
},
notice: "ojluni/NOTICE",
installable: false,
include_srcs: true,
}
java_system_modules {
name: "core-system-modules",
libs: [
"core-oj",
"core-libart",
"core-lambda-stubs",
],
}
// Build 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"],
}
// Make the core-tests-support library.
java_library_static {
name: "core-tests-support",
hostdex: true,
no_framework_libs: true,
srcs: ["support/src/test/java/**/*.java"],
libs: [
"junit",
"bouncycastle",
],
static_libs: [
"bouncycastle-bcpkix",
"bouncycastle-ocsp",
],
}
// Make the jsr166-tests library.
java_test {
name: "jsr166-tests",
srcs: ["jsr166-tests/src/test/java/**/*.java"],
no_framework_libs: true,
libs: [
"junit",
],
}
// Build 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"],
},
}
// Build 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"],
},
}
// Make the core-tests library.
java_test {
name: "core-tests",
defaults: ["libcore_java_defaults"],
hostdex: true,
no_framework_libs: 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",
"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",
],
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",
],
libs: [
"okhttp",
"bouncycastle",
],
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",
],
errorprone: {
javacflags: [
"-Xep:TryFailThrowable:ERROR",
"-Xep:ComparisonOutOfRange:ERROR",
],
},
}
// Make the core-ojtests library.
java_test {
name: "core-ojtests",
defaults: ["libcore_java_defaults"],
hostdex: true,
no_framework_libs: true,
srcs: [
"ojluni/src/test/java/**/*.java",
],
java_resource_dirs: [
"ojluni/src/test/java",
"ojluni/src/test/resources",
],
libs: [
"okhttp",
"bouncycastle",
],
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",
}
// Make the core-ojtests-public library. Excludes any private API tests.
java_test {
name: "core-ojtests-public",
defaults: ["libcore_java_defaults"],
no_framework_libs: true,
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: [
"**/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",
],
libs: [
"bouncycastle",
"okhttp",
"testng",
],
}
// Make the annotated stubs in ojluni/annotations available to metalava:
droiddoc_exported_dir {
name: "ojluni-annotated-stubs",
path: "ojluni/annotations",
}
//
// Local droiddoc for faster libcore testing
//
// Run with:
// mm -j32 core-docs
//
// Main output:
// ../out/soong/.intermediates/libcore/core-docs/android_common/out/reference/packages.html
//
// All text for proofreading (or running tools over):
// ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt
//
// TODO list of missing javadoc, etc:
// ../out/soong/.intermediates/libcore/core-docs/android_common/out/core-docs-todo.html
//
droiddoc {
name: "core-docs",
srcs: [
":openjdk_javadoc_files",
":non_openjdk_javadoc_files",
":android_icu4j_src_files_for_docs",
],
custom_template: "droiddoc-templates-sdk",
hdf: [
"android.whichdoc offline",
],
knowntags: [
"known_oj_tags.txt",
],
proofread_file: "core-docs-proofread.txt",
todo_file: "core-docs-todo.html",
metalava_enabled: true,
args: " --exclude-annotations --generate-documentation -offlinemode -title \"libcore\"",
}
droiddoc {
name: "metalava-dokka-core-docs",
srcs: [
":openjdk_javadoc_files",
":non_openjdk_javadoc_files",
":android_icu4j_src_files_for_docs",
],
metalava_enabled: true,
dokka_enabled: true,
args: "--generate-documentation"
}
filegroup {
name: "known-oj-tags",
srcs: [
"known_oj_tags.txt",
],
}
droiddoc {
name: "core-current-stubs-gen-docs",
srcs: [
":openjdk_javadoc_files",
":non_openjdk_javadoc_files",
":android_icu4j_src_files_for_docs",
],
installable: false,
no_framework_libs: true,
metalava_enabled: true,
args: " --exclude-annotations",
}
java_library_static {
name: "core.current.stubs",
srcs: [
":core-current-stubs-gen-docs",
],
errorprone: {
javacflags: [
"-Xep:MissingOverride:OFF",
],
},
openjdk9: {
javacflags: ["--patch-module=java.base=."],
},
no_standard_libs: true,
system_modules: "none",
}
//
// Targets related to core mmodule APIs / dependencies.
//
// Generates stub source files for the {public SDK API + intra-core mmodule API}
// of core-all.
droiddoc {
name: "core-all-mmodule-stubs-docs",
srcs: [
":openjdk_javadoc_files",
":non_openjdk_javadoc_files",
":android_icu4j_src_files_for_docs",
":core_simple_mmodule_java_files",
],
installable: false,
no_framework_libs: true,
metalava_enabled: true,
args: "-nodocs -stubsourceonly -showAnnotation libcore.mmodule.IntraCoreMModuleApi",
}
// A library containing the {public SDK API + intra-core mmodule API} stubs for
// core-all.
java_library {
name: "core-all.mmodule.stubs",
srcs: [
":core-all-mmodule-stubs-docs",
],
no_framework_libs: true,
no_standard_libs: true,
libs: ["core-all"],
system_modules: "core-all-system-modules",
openjdk9: {
javacflags: ["--patch-module=java.base=."],
},
}