1// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15java_binary_host {
16    name: "metalava",
17    srcs: [
18        "src/main/java/**/*.java",
19        "src/main/java/**/*.kt",
20    ],
21    java_resource_dirs: ["src/main/resources/"],
22    static_libs: [
23        "kotlin-reflect",
24        "metalava-tools-common-m2-deps",
25        "metalava-gradle-plugin-deps",
26    ],
27    manifest: "manifest.txt",
28    target: {
29        host: {
30            dist: {
31                targets: ["sdk"],
32            },
33        },
34    },
35    visibility: [
36        // Metalava is linked by //vendor/xts/gts-tests/hostsidetests/api, but because it's a
37        // make project, soong's visibility won't apply. Soong also won't let you specify a
38        // subpackage of //vendor/ here. So let's just make it private.
39        // When //vendor/xts/gts-tests/hostsidetests/api migrates to Android.bp, we need to
40        // open metalava to //vendor:__subpackages__.
41        "//visibility:private",
42    ],
43}
44
45java_library {
46    name: "stub-annotations",
47    host_supported: true,
48    srcs: [
49        "stub-annotations/src/main/java/**/*.java",
50    ],
51    // Allow core_current to use stub-annotations.
52    sdk_version: "28",
53    target: {
54        host: {
55            dist: {
56                targets: ["sdk"],
57            },
58        },
59    },
60}
61
62genrule {
63    name: "private-stub-annotations",
64    tools: [
65        "soong_zip",
66        "metalava",
67    ],
68    srcs: [
69        "stub-annotations/src/main/java/**/*.java",
70    ],
71    cmd: "($(location metalava) --no-banner --copy-annotations tools/metalava/stub-annotations " +
72        "$(genDir)/private-stub-annotations) && ($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
73    out: [
74        "private-stub-annotations.srcjar",
75    ],
76}
77
78java_library {
79    name: "private-stub-annotations-jar",
80    host_supported: true,
81    srcs: [
82        ":private-stub-annotations",
83    ],
84    sdk_version: "core_current",
85    // private-stub-annotations-jar ends up in android.jar in the SDK and should
86    // use -target 8.
87    java_version: "1.8",
88}
89
90droiddoc_exported_dir {
91    name: "metalava-manual",
92    path: "manual",
93}
94