xref: /aosp_15_r20/external/caliper/Android.bp (revision e13194474f9b0035ae014b3193027641ae2d48fb)
1// Copyright (C) 2015 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
15// build caliper host jar
16// ============================================================
17
18package {
19    default_applicable_licenses: ["external_caliper_license"],
20}
21
22// Added automatically by a large-scale-change that took the approach of
23// 'apply every license found to every target'. While this makes sure we respect
24// every license restriction, it may not be entirely correct.
25//
26// e.g. GPL in an MIT project might only apply to the contrib/ directory.
27//
28// Please consider splitting the single license below into multiple licenses,
29// taking care not to lose any license_kind information, and overriding the
30// default license using the 'licenses: [...]' property on targets as needed.
31//
32// For unused files, consider creating a 'fileGroup' with "//visibility:private"
33// to attach the license to, and including a comment whether the files may be
34// used in the current project.
35//
36// large-scale-change included anything that looked like it might be a license
37// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
38//
39// Please consider removing redundant or irrelevant files from 'license_text:'.
40// See: http://go/android-license-faq
41license {
42    name: "external_caliper_license",
43    visibility: [":__subpackages__"],
44    license_kinds: [
45        "SPDX-license-identifier-Apache-2.0",
46        "SPDX-license-identifier-CDDL",
47        "SPDX-license-identifier-CDDL-1.0",
48        "SPDX-license-identifier-GPL",
49        "SPDX-license-identifier-GPL-2.0",
50        "SPDX-license-identifier-LGPL",
51    ],
52    license_text: [
53        "COPYING",
54        "NOTICE",
55    ],
56}
57
58java_library_host {
59    name: "caliper",
60
61    srcs: ["caliper/src/main/java/**/*.java"],
62    java_resource_dirs: ["caliper/src/main/resources"],
63
64    static_libs: [
65        "apache-commons-math",
66        "caliper-prebuilts",
67        "dagger2",
68        "gson",
69        "guava",
70        "jsr330",
71    ],
72
73    // Use Dagger2 annotation processor
74    plugins: ["dagger2-compiler"],
75
76    java_version: "1.8",
77}
78
79// build caliper target api jar
80// ============================================================
81// This contains just those classes needed for benchmarks to compile.
82
83java_library {
84    name: "caliper-api-target",
85    installable: true,
86
87    srcs: [
88        "caliper/src/main/java/com/google/caliper/AfterExperiment.java",
89        "caliper/src/main/java/com/google/caliper/BeforeExperiment.java",
90        "caliper/src/main/java/com/google/caliper/Param.java",
91        "caliper/src/main/java/com/google/caliper/All.java",
92        "caliper/src/main/java/com/google/caliper/Benchmark.java",
93    ],
94    sdk_version: "core_current",
95
96    java_version: "1.8",
97}
98
99// build caliper tests
100// ============================================================
101// vogar --expectations $ANDROID_BUILD_TOP/external/caliper/expectations/knownfailures.txt \
102//        --test-only \
103//        --classpath $ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/caliper-tests_intermediates/javalib.jar \
104//        com.google.caliper
105
106java_test_host {
107    name: "caliper-tests",
108
109    srcs: ["caliper/src/test/java/**/*.java"],
110    java_resource_dirs: ["caliper/src/test/resources"],
111
112    static_libs: [
113        "caliper",
114        "junit",
115        "mockito",
116    ],
117    // Avoid the tests running as unit tests. They have some jar requirement that doesn't currently
118    // quite work in CI.
119    test_options: {
120        unit_test: false,
121    },
122
123    // Use Dagger2 annotation processor
124    plugins: ["dagger2-compiler"],
125
126    java_version: "1.8",
127}
128
129// build caliper examples
130// ============================================================
131
132java_library_host {
133    name: "caliper-examples",
134
135    srcs: ["examples/src/main/java/**/*.java"],
136
137    static_libs: [
138        "caliper",
139        "junit",
140        "mockito",
141    ],
142
143    java_version: "1.8",
144
145    errorprone: {
146        javacflags: [
147            "-Xep:ReturnValueIgnored:WARN",
148        ],
149    },
150}
151
152// Build host dependencies.
153// ============================================================
154
155java_import_host {
156    name: "caliper-prebuilts",
157    jars: [
158        "lib/java-allocation-instrumenter-2.0.jar",
159        "lib/jersey-client-1.11.jar",
160        "lib/jersey-core-1.11.jar",
161        "lib/joda-time-2.1.jar",
162        "lib/jsr311-api-1.1.1.jar",
163    ],
164}
165