• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2016 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// Build jacoco-agent from sources for the platform
18//
19// Note: this is only intended to be used for the platform development. This is *not* intended
20// to be used in the SDK where apps can use the official jacoco release.
21package {
22    default_applicable_licenses: ["external_jacoco_license"],
23}
24
25// Added automatically by a large-scale-change that took the approach of
26// 'apply every license found to every target'. While this makes sure we respect
27// every license restriction, it may not be entirely correct.
28//
29// e.g. GPL in an MIT project might only apply to the contrib/ directory.
30//
31// Please consider splitting the single license below into multiple licenses,
32// taking care not to lose any license_kind information, and overriding the
33// default license using the 'licenses: [...]' property on targets as needed.
34//
35// For unused files, consider creating a 'fileGroup' with "//visibility:private"
36// to attach the license to, and including a comment whether the files may be
37// used in the current project.
38//
39// large-scale-change included anything that looked like it might be a license
40// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
41//
42// Please consider removing redundant or irrelevant files from 'license_text:'.
43// See: http://go/android-license-faq
44license {
45    name: "external_jacoco_license",
46    visibility: [":__subpackages__"],
47    license_kinds: [
48        "SPDX-license-identifier-Apache-2.0",
49        "SPDX-license-identifier-BSD",
50        "SPDX-license-identifier-EPL",
51        "SPDX-license-identifier-MIT",
52    ],
53    license_text: [
54        "LICENSE.md",
55        "NOTICE",
56    ],
57}
58
59java_library {
60    name: "jacocoagent",
61    host_supported: true,
62    installable: true,
63    manifest: "org.jacoco.agent/src/MANIFEST.MF",
64
65    apex_available: [
66        "//apex_available:anyapex",
67        "//apex_available:platform",
68    ],
69
70    srcs: [
71        "org.jacoco.core/src/**/*.java",
72        "org.jacoco.agent/src/**/*.java",
73        "org.jacoco.agent.rt/src/**/*.java",
74    ],
75
76    // Some Jacoco source files depend on classes that do not exist in Android.
77    // While these classes are not executed at runtime (because we use offline
78    // instrumentation), they will cause issues when compiling them with ART
79    // during dex pre-opting. Therefore, it would prevent from applying code
80    // coverage on classes in the bootclasspath (frameworks, services, ...) or
81    // system apps.
82    // Note: we still may need to update the source code to cut dependencies in
83    // mandatory jacoco classes.
84    target: {
85        android: {
86            exclude_srcs: [
87                "org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java",
88                "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java",
89                "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java",
90                "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java",
91            ],
92        },
93        host: {
94            dist: {
95                targets: [
96                    "dist_files",
97                    "apps_only",
98                ],
99            },
100        }
101    },
102
103    // In order to include Jacoco in core libraries, we cannot depend on
104    // anything in the bootclasspath (or we would create dependency cycle).
105    // Therefore we compile against the SDK android.jar which gives the same
106    // APIs Jacoco depends on.
107    sdk_version: "9",
108
109    // TODO(b/69671801): there's no bytecode on the device, so these shouldn't
110    // be necessary.
111    static_libs: [
112        "asm-9.2",
113        "asm-commons-9.2",
114        "asm-tree-9.2",
115    ],
116    errorprone: {
117        javacflags: [
118            "-Xep:EqualsHashCode:WARN",
119            "-Xep:ReturnValueIgnored:WARN",
120        ],
121    },
122}
123
124// Generates stubs containing the classes that will be referenced by instrumented bytecode.
125droidstubs {
126    name: "jacoco-stubs-gen",
127    srcs: [
128        "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java",
129        "org.jacoco.core/src/org/jacoco/core/data/IExecutionData.java",
130    ],
131}
132
133// A stubs target containing the parts of JaCoCo that we need to add to the hidden API whitelist.
134java_library {
135    name: "jacoco-stubs",
136    compile_dex: true,
137    srcs: [":jacoco-stubs-gen"],
138}
139
140// Build jacoco-cli from sources for the platform
141
142// TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
143// what is defined in the pom.xml files, although it's probably much more trouble than it's worth
144java_library_host {
145    name: "jacoco-cli",
146
147    manifest: "org.jacoco.cli/src/MANIFEST.MF",
148
149    srcs: [
150        "org.jacoco.cli/src/**/*.java",
151    ],
152
153    static_libs: [
154        "jacoco-report",
155        "jacoco-core",
156    ],
157
158    dist: {
159        targets: [
160            "dist_files",
161            "apps_only",
162        ],
163    },
164
165    // b/267831518: Pin tradefed and dependencies to Java 11.
166    java_version: "11",
167}
168
169java_library_host {
170    name: "jacoco-core",
171
172    srcs: [
173        "org.jacoco.core/src/**/*.java",
174    ],
175
176    java_resource_dirs: [
177        "org.jacoco.core/src",
178    ],
179
180    static_libs: [
181        "asm-9.2",
182        "asm-commons-9.2",
183        "asm-tree-9.2",
184        "args4j-2.0.28",
185    ],
186
187    // b/267831518: Pin tradefed and dependencies to Java 11.
188    java_version: "11",
189
190    errorprone: {
191        javacflags: [
192            "-Xep:EqualsHashCode:WARN",
193            "-Xep:ReturnValueIgnored:WARN",
194        ],
195    },
196}
197
198java_library_host {
199    name: "jacoco-report",
200
201    srcs: [
202        "org.jacoco.report/src/**/*.java",
203    ],
204
205    // b/267831518: Pin tradefed and dependencies to Java 11.
206    java_version: "11",
207
208    java_resource_dirs: [
209        "org.jacoco.report/src",
210    ],
211
212    static_libs: [
213        "jacoco-core",
214    ],
215}
216