[LSC] Add LOCAL_LICENSE_KINDS to libcore

Added SPDX-license-identifier-Apache-2.0 to:
  benchmarks/Android.bp
  luni/Android.bp
  luni/src/main/native/Android.bp
  luni/src/test/annotations/Android.bp
  luni/src/test/filesystems/Android.bp
  luni/src/test/java9language/Android.bp
  luni/src/test/parameter_metadata/Android.bp
  metrictests/memory/apps/Android.bp
  metrictests/memory/host/Android.bp
  tools/upstream/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-GPL SPDX-license-identifier-GPL-2.0
    SPDX-license-identifier-LGPL SPDX-license-identifier-MIT
    SPDX-license-identifier-OpenSSL SPDX-license-identifier-Unicode-DFS
    SPDX-license-identifier-W3C legacy_unencumbered
to:
  Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-GPL-2.0
    SPDX-license-identifier-GPL-with-classpath-exception
to:
  ojluni/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL
    SPDX-license-identifier-GPL-2.0 SPDX-license-identifier-LGPL
    SPDX-license-identifier-MIT SPDX-license-identifier-W3C
to:
  expectations/Android.bp
  mmodules/core_platform_api/Android.bp
  mmodules/intracoreapi/Android.bp

Added SPDX-license-identifier-GPL-2.0
to:
  ojluni/src/main/native/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Idbba598515cdd7aaf7a244c330c11e082a36ce89
diff --git a/Android.bp b/Android.bp
index 5ce2666..0ce778c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -14,6 +14,47 @@
 
 package {
     default_visibility: ["//visibility:private"],
+    default_applicable_licenses: ["libcore_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'filegroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+//
+// large-scale-change included anything that looked like it might be a license
+// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
+//
+// Please consider removing redundant or irrelevant files from 'license_text:'.
+// http://go/android-license-faq
+license {
+    name: "libcore_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-GPL",
+        "SPDX-license-identifier-GPL-2.0",
+        "SPDX-license-identifier-LGPL",
+        "SPDX-license-identifier-MIT",
+        "SPDX-license-identifier-OpenSSL",
+        "SPDX-license-identifier-Unicode-DFS",
+        "SPDX-license-identifier-W3C",
+        "legacy_unencumbered",
+    ],
+    license_text: [
+        "LICENSE",
+        "NOTICE",
+    ],
 }
 
 build = [
diff --git a/benchmarks/Android.bp b/benchmarks/Android.bp
index 4f2f157..8548176 100644
--- a/benchmarks/Android.bp
+++ b/benchmarks/Android.bp
@@ -12,6 +12,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_license"],
+}
+
 java_test {
     name: "benchmarks",
     srcs: ["src/**/*.java"],
diff --git a/expectations/Android.bp b/expectations/Android.bp
index f1ce17e..2aadab9 100644
--- a/expectations/Android.bp
+++ b/expectations/Android.bp
@@ -12,6 +12,19 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_license":
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-GPL
+    //   SPDX-license-identifier-GPL-2.0
+    //   SPDX-license-identifier-LGPL
+    //   SPDX-license-identifier-MIT
+    //   SPDX-license-identifier-W3C
+    default_applicable_licenses: ["libcore_license"],
+}
+
 expectations_visibility = [
     "//art/build/sdk",
     "//cts/tests/libcore:__subpackages__",
diff --git a/luni/Android.bp b/luni/Android.bp
new file mode 100644
index 0000000..ef9ab60
--- /dev/null
+++ b/luni/Android.bp
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2021 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.
+
+package {
+    default_applicable_licenses: ["libcore_luni_license"],
+}
+
+// Added automatically by a large-scale-change
+// http://go/android-license-faq
+license {
+    name: "libcore_luni_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+    ],
+    license_text: [
+        "license.html",
+    ],
+}
diff --git a/luni/src/main/native/Android.bp b/luni/src/main/native/Android.bp
index d7247f6..1f69c67 100644
--- a/luni/src/main/native/Android.bp
+++ b/luni/src/main/native/Android.bp
@@ -12,6 +12,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_luni_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_luni_license"],
+}
+
 filegroup {
     name: "luni_native_srcs",
     visibility: [
diff --git a/luni/src/test/annotations/Android.bp b/luni/src/test/annotations/Android.bp
index 437d7c4..ae79505 100644
--- a/luni/src/test/annotations/Android.bp
+++ b/luni/src/test/annotations/Android.bp
@@ -17,6 +17,14 @@
 //
 // Included as a resource by //libcore:core-tests and loaded into its own
 // class loader by libcore.java.lang.reflect.annotations.RetentionPolicyTest.
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_luni_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_luni_license"],
+}
+
 java_library {
     name: "annotations-test",
     visibility: [
diff --git a/luni/src/test/filesystems/Android.bp b/luni/src/test/filesystems/Android.bp
index 83cb936..3910028 100644
--- a/luni/src/test/filesystems/Android.bp
+++ b/luni/src/test/filesystems/Android.bp
@@ -16,6 +16,14 @@
 //
 // Included as a resource by //libcore:core-tests and loaded into its own
 // class loader by libcore.java.nio.file.FileSystemsTest.
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_luni_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_luni_license"],
+}
+
 java_library {
     name: "filesystemstest",
     visibility: [
diff --git a/luni/src/test/java9language/Android.bp b/luni/src/test/java9language/Android.bp
index dddc184..5c10041 100644
--- a/luni/src/test/java9language/Android.bp
+++ b/luni/src/test/java9language/Android.bp
@@ -15,6 +15,14 @@
 // Android tests related to Java 9 language features.
 
 // Use jarjar to repackage Java9LanguageFeatures, to be used in tests below.
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_luni_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_luni_license"],
+}
+
 java_library {
     name: "core-java-9-language-features-repackaged-for-test",
     hostdex: true,
diff --git a/luni/src/test/parameter_metadata/Android.bp b/luni/src/test/parameter_metadata/Android.bp
index 0eec841..d5ec1c7 100644
--- a/luni/src/test/parameter_metadata/Android.bp
+++ b/luni/src/test/parameter_metadata/Android.bp
@@ -19,6 +19,14 @@
 //
 // Included as a resource by //libcore:core-tests and loaded into its own
 // class loader by libcore.java.lang.reflect.ParameterTest.
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_luni_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_luni_license"],
+}
+
 java_library {
     name: "parameter-metadata-test",
     visibility: [
diff --git a/metrictests/memory/apps/Android.bp b/metrictests/memory/apps/Android.bp
index 480886e..4c13689 100644
--- a/metrictests/memory/apps/Android.bp
+++ b/metrictests/memory/apps/Android.bp
@@ -12,6 +12,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_license"],
+}
+
 android_test_helper_app {
     name: "LibcoreHeapDumper",
     sdk_version: "current",
diff --git a/metrictests/memory/host/Android.bp b/metrictests/memory/host/Android.bp
index beed9e1..ece6c22 100644
--- a/metrictests/memory/host/Android.bp
+++ b/metrictests/memory/host/Android.bp
@@ -12,6 +12,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_license"],
+}
+
 java_test_host {
     name: "libcore-memory-metrics-tests",
     srcs: ["src/**/*.java"],
diff --git a/mmodules/core_platform_api/Android.bp b/mmodules/core_platform_api/Android.bp
index 46c68f8..00e8017 100644
--- a/mmodules/core_platform_api/Android.bp
+++ b/mmodules/core_platform_api/Android.bp
@@ -28,6 +28,19 @@
 //
 // TODO(b/161973015): Remove the legacy/stable distinction once no longer useful.
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_license":
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-GPL
+    //   SPDX-license-identifier-GPL-2.0
+    //   SPDX-license-identifier-LGPL
+    //   SPDX-license-identifier-MIT
+    //   SPDX-license-identifier-W3C
+    default_applicable_licenses: ["libcore_license"],
+}
+
 java_defaults {
     name: "art-module-platform-api-defaults",
     srcs: [
diff --git a/mmodules/intracoreapi/Android.bp b/mmodules/intracoreapi/Android.bp
index 72d5fbf..1d4877a 100644
--- a/mmodules/intracoreapi/Android.bp
+++ b/mmodules/intracoreapi/Android.bp
@@ -13,6 +13,19 @@
 // limitations under the License.
 
 // Referenced implicitly from art.module.intra.core.api.
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_license":
+    //   SPDX-license-identifier-Apache-2.0
+    //   SPDX-license-identifier-GPL
+    //   SPDX-license-identifier-GPL-2.0
+    //   SPDX-license-identifier-LGPL
+    //   SPDX-license-identifier-MIT
+    //   SPDX-license-identifier-W3C
+    default_applicable_licenses: ["libcore_license"],
+}
+
 filegroup {
     name: "art.module.intra.core.api.api.public.latest",
     srcs: [
diff --git a/ojluni/Android.bp b/ojluni/Android.bp
index 7611937..12ae7d7 100644
--- a/ojluni/Android.bp
+++ b/ojluni/Android.bp
@@ -16,6 +16,38 @@
 // directory, detect that it is a GPL license and then copy all the files
 // from this directory and its subdirectories in to the
 // ${OUT}/obj/PACKAGING/gpl_source_intermediates/gpl_source.tgz file.
+package {
+    default_applicable_licenses: ["libcore_ojluni_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'filegroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// http://go/android-license-faq
+license {
+    name: "libcore_ojluni_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-GPL-2.0",
+        "SPDX-license-identifier-GPL-with-classpath-exception",
+    ],
+    license_text: [
+        "NOTICE",
+    ],
+}
+
 phony {
     name: "ojluni-phony",
 
diff --git a/ojluni/src/main/native/Android.bp b/ojluni/src/main/native/Android.bp
index 45a5c98..162a73c 100644
--- a/ojluni/src/main/native/Android.bp
+++ b/ojluni/src/main/native/Android.bp
@@ -12,6 +12,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_ojluni_license":
+    //   SPDX-license-identifier-GPL-2.0
+    default_applicable_licenses: ["libcore_ojluni_license"],
+}
+
 filegroup {
     name: "libopenjdk_native_srcs",
     visibility: [
diff --git a/tools/upstream/Android.bp b/tools/upstream/Android.bp
index dd01c30..63a88e2 100644
--- a/tools/upstream/Android.bp
+++ b/tools/upstream/Android.bp
@@ -16,6 +16,14 @@
 
 //#############################################################
 
+package {
+    // http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // the below license kinds from "libcore_license":
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["libcore_license"],
+}
+
 java_library_host {
     name: "libcore-compare-upstreams",
     srcs: ["src/main/java/**/*.java"],