blob: 0641bdec95db564c8e5d0c69cfee3c2d66f98412 [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
Kun Niu6cb4de22020-02-12 17:05:50 -080025 apex_available: [
26 "//apex_available:anyapex",
27 "//apex_available:platform",
28 ],
29
Colin Cross919bf5c2017-10-06 13:29:25 -070030 srcs: [
31 "org.jacoco.core/src/**/*.java",
32 "org.jacoco.agent/src/**/*.java",
33 "org.jacoco.agent.rt/src/**/*.java",
34 ],
35
Colin Crossb760c472017-11-22 13:57:52 -080036 // Some Jacoco source files depend on classes that do not exist in Android.
37 // While these classes are not executed at runtime (because we use offline
38 // instrumentation), they will cause issues when compiling them with ART
39 // during dex pre-opting. Therefore, it would prevent from applying code
40 // coverage on classes in the bootclasspath (frameworks, services, ...) or
41 // system apps.
42 // Note: we still may need to update the source code to cut dependencies in
43 // mandatory jacoco classes.
Colin Cross919bf5c2017-10-06 13:29:25 -070044 exclude_srcs: [
45 "org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java",
46 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java",
47 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java",
48 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java",
49 ],
50
Colin Crossb760c472017-11-22 13:57:52 -080051 // In order to include Jacoco in core libraries, we cannot depend on
52 // anything in the bootclasspath (or we would create dependency cycle).
53 // Therefore we compile against the SDK android.jar which gives the same
54 // APIs Jacoco depends on.
Colin Cross919bf5c2017-10-06 13:29:25 -070055 sdk_version: "9",
56
Colin Crossb760c472017-11-22 13:57:52 -080057 // TODO(b/69671801): there's no bytecode on the device, so these shouldn't
58 // be necessary.
59 static_libs: [
Haibo Huang9b5f0ce2019-05-13 16:38:59 -070060 "asm-7.0",
61 "asm-commons-7.0",
62 "asm-tree-7.0",
Colin Crossb760c472017-11-22 13:57:52 -080063 ],
Colin Cross919bf5c2017-10-06 13:29:25 -070064}
65
Allen Haira0fce882019-02-25 16:39:10 -080066// Generates stubs containing the classes that will be referenced by instrumented bytecode.
67droidstubs {
68 name: "jacoco-stubs-gen",
69 srcs: ["org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java"],
70}
71
72// A stubs target containing the parts of JaCoCo that we need to add to the hidden API whitelist.
73java_library {
74 name: "jacoco-stubs",
75 compile_dex: true,
76 srcs: [":jacoco-stubs-gen"],
77}
78
Colin Cross919bf5c2017-10-06 13:29:25 -070079// Build jacoco-cli from sources for the platform
80
81// TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with
82// what is defined in the pom.xml files, although it's probably much more trouble than it's worth
83java_library_host {
84 name: "jacoco-cli",
85
86 manifest: "org.jacoco.cli/src/MANIFEST.MF",
87
88 srcs: [
89 "org.jacoco.core/src/**/*.java",
90 "org.jacoco.report/src/**/*.java",
91 "org.jacoco.cli/src/**/*.java",
92 ],
93
94 java_resource_dirs: [
95 "org.jacoco.core/src",
96 "org.jacoco.report/src",
97 ],
98
99 static_libs: [
Haibo Huang9b5f0ce2019-05-13 16:38:59 -0700100 "asm-7.0",
101 "asm-commons-7.0",
102 "asm-tree-7.0",
Colin Cross919bf5c2017-10-06 13:29:25 -0700103 "args4j-2.0.28",
104 ],
Colin Cross330944d2019-03-22 13:39:32 -0700105
106 dist: {
107 targets: [
108 "dist_files",
109 "apps_only",
110 ],
111 },
Colin Cross919bf5c2017-10-06 13:29:25 -0700112}