blob: 0689525b2e526639408185742706e43403e622ac [file] [log] [blame]
Colin Cross919bf5c2017-10-06 13:29:25 -07001//
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
Colin Cross919bf5c2017-10-06 13:29:25 -070017// 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.
Colin Crossf4e43e62017-10-09 12:39:29 -070021java_library {
Colin Cross919bf5c2017-10-06 13:29:25 -070022 name: "jacocoagent",
Colin Cross730cc262018-07-12 10:38:52 -070023 installable: true,
Colin Cross919bf5c2017-10-06 13:29:25 -070024
25 srcs: [
26 "org.jacoco.core/src/**/*.java",
27 "org.jacoco.agent/src/**/*.java",
28 "org.jacoco.agent.rt/src/**/*.java",
29 ],
30
Colin Crossb760c472017-11-22 13:57:52 -080031 // Some Jacoco source files depend on classes that do not exist in Android.
32 // While these classes are not executed at runtime (because we use offline
33 // instrumentation), they will cause issues when compiling them with ART
34 // during dex pre-opting. Therefore, it would prevent from applying code
35 // coverage on classes in the bootclasspath (frameworks, services, ...) or
36 // system apps.
37 // Note: we still may need to update the source code to cut dependencies in
38 // mandatory jacoco classes.
Colin Cross919bf5c2017-10-06 13:29:25 -070039 exclude_srcs: [
40 "org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java",
41 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java",
42 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java",
43 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java",
44 ],
45
Colin Crossb760c472017-11-22 13:57:52 -080046 // In order to include Jacoco in core libraries, we cannot depend on
47 // anything in the bootclasspath (or we would create dependency cycle).
48 // Therefore we compile against the SDK android.jar which gives the same
49 // APIs Jacoco depends on.
Colin Cross919bf5c2017-10-06 13:29:25 -070050 sdk_version: "9",
51
Colin Crossb760c472017-11-22 13:57:52 -080052 // TODO(b/69671801): there's no bytecode on the device, so these shouldn't
53 // be necessary.
54 static_libs: [
Haibo Huang9b5f0ce2019-05-13 16:38:59 -070055 "asm-7.0",
56 "asm-commons-7.0",
57 "asm-tree-7.0",
Colin Crossb760c472017-11-22 13:57:52 -080058 ],
Colin Cross919bf5c2017-10-06 13:29:25 -070059}
60
Allen Haira0fce882019-02-25 16:39:10 -080061// Generates stubs containing the classes that will be referenced by instrumented bytecode.
62droidstubs {
63 name: "jacoco-stubs-gen",
64 srcs: ["org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java"],
65}
66
67// A stubs target containing the parts of JaCoCo that we need to add to the hidden API whitelist.
68java_library {
69 name: "jacoco-stubs",
70 compile_dex: true,
71 srcs: [":jacoco-stubs-gen"],
72}
73
Colin Cross919bf5c2017-10-06 13:29:25 -070074// Build jacoco-cli from sources for the platform
75
76// TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
77// what is defined in the pom.xml files, although it's probably much more trouble than it's worth
78java_library_host {
79 name: "jacoco-cli",
80
81 manifest: "org.jacoco.cli/src/MANIFEST.MF",
82
83 srcs: [
84 "org.jacoco.core/src/**/*.java",
85 "org.jacoco.report/src/**/*.java",
86 "org.jacoco.cli/src/**/*.java",
87 ],
88
89 java_resource_dirs: [
90 "org.jacoco.core/src",
91 "org.jacoco.report/src",
92 ],
93
94 static_libs: [
Haibo Huang9b5f0ce2019-05-13 16:38:59 -070095 "asm-7.0",
96 "asm-commons-7.0",
97 "asm-tree-7.0",
Colin Cross919bf5c2017-10-06 13:29:25 -070098 "args4j-2.0.28",
99 ],
Colin Cross330944d2019-03-22 13:39:32 -0700100
101 dist: {
102 targets: [
103 "dist_files",
104 "apps_only",
105 ],
106 },
Colin Cross919bf5c2017-10-06 13:29:25 -0700107}