Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 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 | |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 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. |
Colin Cross | f4e43e6 | 2017-10-09 12:39:29 -0700 | [diff] [blame] | 21 | java_library { |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 22 | name: "jacocoagent", |
Colin Cross | 730cc26 | 2018-07-12 10:38:52 -0700 | [diff] [blame] | 23 | installable: true, |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 24 | |
Kun Niu | 6cb4de2 | 2020-02-12 17:05:50 -0800 | [diff] [blame] | 25 | apex_available: [ |
| 26 | "//apex_available:anyapex", |
| 27 | "//apex_available:platform", |
| 28 | ], |
| 29 | |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 30 | srcs: [ |
| 31 | "org.jacoco.core/src/**/*.java", |
| 32 | "org.jacoco.agent/src/**/*.java", |
| 33 | "org.jacoco.agent.rt/src/**/*.java", |
| 34 | ], |
| 35 | |
Colin Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 36 | // 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 Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 44 | 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 Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 51 | // 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 Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 55 | sdk_version: "9", |
| 56 | |
Colin Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 57 | // TODO(b/69671801): there's no bytecode on the device, so these shouldn't |
| 58 | // be necessary. |
| 59 | static_libs: [ |
Haibo Huang | 9b5f0ce | 2019-05-13 16:38:59 -0700 | [diff] [blame] | 60 | "asm-7.0", |
| 61 | "asm-commons-7.0", |
| 62 | "asm-tree-7.0", |
Colin Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 63 | ], |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Allen Hair | a0fce88 | 2019-02-25 16:39:10 -0800 | [diff] [blame] | 66 | // Generates stubs containing the classes that will be referenced by instrumented bytecode. |
| 67 | droidstubs { |
| 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. |
| 73 | java_library { |
| 74 | name: "jacoco-stubs", |
| 75 | compile_dex: true, |
| 76 | srcs: [":jacoco-stubs-gen"], |
| 77 | } |
| 78 | |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 79 | // 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 |
| 83 | java_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 Huang | 9b5f0ce | 2019-05-13 16:38:59 -0700 | [diff] [blame] | 100 | "asm-7.0", |
| 101 | "asm-commons-7.0", |
| 102 | "asm-tree-7.0", |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 103 | "args4j-2.0.28", |
| 104 | ], |
Colin Cross | 330944d | 2019-03-22 13:39:32 -0700 | [diff] [blame] | 105 | |
| 106 | dist: { |
| 107 | targets: [ |
| 108 | "dist_files", |
| 109 | "apps_only", |
| 110 | ], |
| 111 | }, |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 112 | } |