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 | |
| 25 | srcs: [ |
| 26 | "org.jacoco.core/src/**/*.java", |
| 27 | "org.jacoco.agent/src/**/*.java", |
| 28 | "org.jacoco.agent.rt/src/**/*.java", |
| 29 | ], |
| 30 | |
Colin Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 31 | // 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 Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 39 | 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 Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 46 | // 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 Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 50 | sdk_version: "9", |
| 51 | |
Colin Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 52 | // TODO(b/69671801): there's no bytecode on the device, so these shouldn't |
| 53 | // be necessary. |
| 54 | static_libs: [ |
Haibo Huang | 9b5f0ce | 2019-05-13 16:38:59 -0700 | [diff] [blame^] | 55 | "asm-7.0", |
| 56 | "asm-commons-7.0", |
| 57 | "asm-tree-7.0", |
Colin Cross | b760c47 | 2017-11-22 13:57:52 -0800 | [diff] [blame] | 58 | ], |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Allen Hair | a0fce88 | 2019-02-25 16:39:10 -0800 | [diff] [blame] | 61 | // Generates stubs containing the classes that will be referenced by instrumented bytecode. |
| 62 | droidstubs { |
| 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. |
| 68 | java_library { |
| 69 | name: "jacoco-stubs", |
| 70 | compile_dex: true, |
| 71 | srcs: [":jacoco-stubs-gen"], |
| 72 | } |
| 73 | |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 74 | // 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 |
| 78 | java_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 Huang | 9b5f0ce | 2019-05-13 16:38:59 -0700 | [diff] [blame^] | 95 | "asm-7.0", |
| 96 | "asm-commons-7.0", |
| 97 | "asm-tree-7.0", |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 98 | "args4j-2.0.28", |
| 99 | ], |
Colin Cross | 330944d | 2019-03-22 13:39:32 -0700 | [diff] [blame] | 100 | |
| 101 | dist: { |
| 102 | targets: [ |
| 103 | "dist_files", |
| 104 | "apps_only", |
| 105 | ], |
| 106 | }, |
Colin Cross | 919bf5c | 2017-10-06 13:29:25 -0700 | [diff] [blame] | 107 | } |