xref: /aosp_15_r20/external/nullaway/Android.bp (revision f50c306653bc89b8210ce6c9e0b0b44fc134bc03)
1*f50c3066SAndroid Build Coastguard Worker//
2*f50c3066SAndroid Build Coastguard Worker// Copyright (C) 2022 The Android Open Source Project
3*f50c3066SAndroid Build Coastguard Worker//
4*f50c3066SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
5*f50c3066SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
6*f50c3066SAndroid Build Coastguard Worker// You may obtain a copy of the License at
7*f50c3066SAndroid Build Coastguard Worker//
8*f50c3066SAndroid Build Coastguard Worker//      http://www.apache.org/licenses/LICENSE-2.0
9*f50c3066SAndroid Build Coastguard Worker//
10*f50c3066SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
11*f50c3066SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
12*f50c3066SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*f50c3066SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
14*f50c3066SAndroid Build Coastguard Worker// limitations under the License.
15*f50c3066SAndroid Build Coastguard Worker//
16*f50c3066SAndroid Build Coastguard Worker
17*f50c3066SAndroid Build Coastguard Worker// Build NullAway from sources for the platform
18*f50c3066SAndroid Build Coastguard Worker//
19*f50c3066SAndroid Build Coastguard Worker// Note: this is only intended to be used for the platform development. This is *not* intended
20*f50c3066SAndroid Build Coastguard Worker// to be used in the SDK where apps can use the official jacoco release.
21*f50c3066SAndroid Build Coastguard Workerpackage {
22*f50c3066SAndroid Build Coastguard Worker    default_applicable_licenses: ["external_nullaway_license"],
23*f50c3066SAndroid Build Coastguard Worker}
24*f50c3066SAndroid Build Coastguard Worker
25*f50c3066SAndroid Build Coastguard Worker// See: http://go/android-license-faq
26*f50c3066SAndroid Build Coastguard Workerlicense {
27*f50c3066SAndroid Build Coastguard Worker    name: "external_nullaway_license",
28*f50c3066SAndroid Build Coastguard Worker    visibility: [":__subpackages__"],
29*f50c3066SAndroid Build Coastguard Worker    license_kinds: [
30*f50c3066SAndroid Build Coastguard Worker        "SPDX-license-identifier-Apache-2.0",
31*f50c3066SAndroid Build Coastguard Worker        "SPDX-license-identifier-GPL-2.0-with-classpath-exception",
32*f50c3066SAndroid Build Coastguard Worker        "SPDX-license-identifier-MIT",
33*f50c3066SAndroid Build Coastguard Worker    ],
34*f50c3066SAndroid Build Coastguard Worker    license_text: [
35*f50c3066SAndroid Build Coastguard Worker        "LICENSE.txt",
36*f50c3066SAndroid Build Coastguard Worker        "LICENSE",
37*f50c3066SAndroid Build Coastguard Worker        "NOTICE",
38*f50c3066SAndroid Build Coastguard Worker    ],
39*f50c3066SAndroid Build Coastguard Worker}
40*f50c3066SAndroid Build Coastguard Worker
41*f50c3066SAndroid Build Coastguard Workerjava_plugin {
42*f50c3066SAndroid Build Coastguard Worker    name: "nullaway_plugin",
43*f50c3066SAndroid Build Coastguard Worker
44*f50c3066SAndroid Build Coastguard Worker    static_libs: [
45*f50c3066SAndroid Build Coastguard Worker        "nullaway_lib",
46*f50c3066SAndroid Build Coastguard Worker    ],
47*f50c3066SAndroid Build Coastguard Worker}
48*f50c3066SAndroid Build Coastguard Worker
49*f50c3066SAndroid Build Coastguard Workerjava_library_host {
50*f50c3066SAndroid Build Coastguard Worker    name: "nullaway_lib",
51*f50c3066SAndroid Build Coastguard Worker
52*f50c3066SAndroid Build Coastguard Worker    srcs: [
53*f50c3066SAndroid Build Coastguard Worker        "nullaway/src/**/*.java",
54*f50c3066SAndroid Build Coastguard Worker        ":nullaway_fake_contract_annotation",
55*f50c3066SAndroid Build Coastguard Worker    ],
56*f50c3066SAndroid Build Coastguard Worker
57*f50c3066SAndroid Build Coastguard Worker    exclude_srcs: ["nullaway/src/test/**/*.java"],
58*f50c3066SAndroid Build Coastguard Worker
59*f50c3066SAndroid Build Coastguard Worker    static_libs: [
60*f50c3066SAndroid Build Coastguard Worker        "guava",
61*f50c3066SAndroid Build Coastguard Worker        "//external/error_prone:error_prone_checkerframework_dataflow_nullaway",
62*f50c3066SAndroid Build Coastguard Worker        "//external/error_prone:error_prone_core",
63*f50c3066SAndroid Build Coastguard Worker        "nullaway_annotations",
64*f50c3066SAndroid Build Coastguard Worker    ],
65*f50c3066SAndroid Build Coastguard Worker
66*f50c3066SAndroid Build Coastguard Worker    libs: [
67*f50c3066SAndroid Build Coastguard Worker        "auto_service_annotations",
68*f50c3066SAndroid Build Coastguard Worker        "auto_value_annotations",
69*f50c3066SAndroid Build Coastguard Worker    ],
70*f50c3066SAndroid Build Coastguard Worker
71*f50c3066SAndroid Build Coastguard Worker    plugins: [
72*f50c3066SAndroid Build Coastguard Worker        "auto_service_plugin",
73*f50c3066SAndroid Build Coastguard Worker        "auto_value_plugin",
74*f50c3066SAndroid Build Coastguard Worker    ],
75*f50c3066SAndroid Build Coastguard Worker
76*f50c3066SAndroid Build Coastguard Worker    javacflags: [
77*f50c3066SAndroid Build Coastguard Worker        "--add-modules=jdk.compiler",
78*f50c3066SAndroid Build Coastguard Worker        "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
79*f50c3066SAndroid Build Coastguard Worker        "--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
80*f50c3066SAndroid Build Coastguard Worker        "--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
81*f50c3066SAndroid Build Coastguard Worker        "--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
82*f50c3066SAndroid Build Coastguard Worker        "--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
83*f50c3066SAndroid Build Coastguard Worker        "--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
84*f50c3066SAndroid Build Coastguard Worker        "--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
85*f50c3066SAndroid Build Coastguard Worker        "--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
86*f50c3066SAndroid Build Coastguard Worker    ],
87*f50c3066SAndroid Build Coastguard Worker}
88*f50c3066SAndroid Build Coastguard Worker
89*f50c3066SAndroid Build Coastguard Worker// Nullaway depends on the Contract annotation, but we don't have it imported into android.
90*f50c3066SAndroid Build Coastguard Worker// Create a fake stub annotation to use instead.
91*f50c3066SAndroid Build Coastguard Workergenrule {
92*f50c3066SAndroid Build Coastguard Worker    name: "nullaway_fake_contract_annotation",
93*f50c3066SAndroid Build Coastguard Worker    out: ["org/jetbrains/annotations/Contract.java"],
94*f50c3066SAndroid Build Coastguard Worker    cmd: "echo 'package org.jetbrains.annotations;' >> $(out) && " +
95*f50c3066SAndroid Build Coastguard Worker        "echo 'import java.lang.annotation.*;' >> $(out) && " +
96*f50c3066SAndroid Build Coastguard Worker        "echo '@Retention(RetentionPolicy.CLASS)' >> $(out) && " +
97*f50c3066SAndroid Build Coastguard Worker        "echo '@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})' >> $(out) && " +
98*f50c3066SAndroid Build Coastguard Worker        "echo 'public @interface Contract {' >> $(out) && " +
99*f50c3066SAndroid Build Coastguard Worker        "echo '  String value() default \"\";' >> $(out) && " +
100*f50c3066SAndroid Build Coastguard Worker        "echo '}' >> $(out)",
101*f50c3066SAndroid Build Coastguard Worker    visibility: ["//visibility:private"],
102*f50c3066SAndroid Build Coastguard Worker}
103*f50c3066SAndroid Build Coastguard Worker
104*f50c3066SAndroid Build Coastguard Workerjava_library {
105*f50c3066SAndroid Build Coastguard Worker    name: "nullaway_annotations",
106*f50c3066SAndroid Build Coastguard Worker    host_supported: true,
107*f50c3066SAndroid Build Coastguard Worker
108*f50c3066SAndroid Build Coastguard Worker    srcs: [
109*f50c3066SAndroid Build Coastguard Worker        "annotations/src/**/*.java"
110*f50c3066SAndroid Build Coastguard Worker    ],
111*f50c3066SAndroid Build Coastguard Worker}
112