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 installable: true, 62 63 apex_available: [ 64 "//apex_available:anyapex", 65 "//apex_available:platform", 66 ], 67 68 srcs: [ 69 "org.jacoco.core/src/**/*.java", 70 "org.jacoco.agent/src/**/*.java", 71 "org.jacoco.agent.rt/src/**/*.java", 72 ], 73 74 // Some Jacoco source files depend on classes that do not exist in Android. 75 // While these classes are not executed at runtime (because we use offline 76 // instrumentation), they will cause issues when compiling them with ART 77 // during dex pre-opting. Therefore, it would prevent from applying code 78 // coverage on classes in the bootclasspath (frameworks, services, ...) or 79 // system apps. 80 // Note: we still may need to update the source code to cut dependencies in 81 // mandatory jacoco classes. 82 exclude_srcs: [ 83 "org.jacoco.core/src/org/jacoco/core/runtime/ModifiedSystemClassRuntime.java", 84 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/PreMain.java", 85 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/CoverageTransformer.java", 86 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/JmxRegistration.java", 87 ], 88 89 // In order to include Jacoco in core libraries, we cannot depend on 90 // anything in the bootclasspath (or we would create dependency cycle). 91 // Therefore we compile against the SDK android.jar which gives the same 92 // APIs Jacoco depends on. 93 sdk_version: "9", 94 95 // TODO(b/69671801): there's no bytecode on the device, so these shouldn't 96 // be necessary. 97 static_libs: [ 98 "asm-9.2", 99 "asm-commons-9.2", 100 "asm-tree-9.2", 101 ], 102} 103 104// Generates stubs containing the classes that will be referenced by instrumented bytecode. 105droidstubs { 106 name: "jacoco-stubs-gen", 107 srcs: [ 108 "org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java", 109 "org.jacoco.core/src/org/jacoco/core/data/IExecutionData.java", 110 ], 111} 112 113// A stubs target containing the parts of JaCoCo that we need to add to the hidden API whitelist. 114java_library { 115 name: "jacoco-stubs", 116 compile_dex: true, 117 srcs: [":jacoco-stubs-gen"], 118} 119 120// Build jacoco-cli from sources for the platform 121 122// TODO(jeffrygaston) it'd be nice to keep the build process and/or list of source files in sync with 123// what is defined in the pom.xml files, although it's probably much more trouble than it's worth 124java_library_host { 125 name: "jacoco-cli", 126 127 manifest: "org.jacoco.cli/src/MANIFEST.MF", 128 129 srcs: [ 130 "org.jacoco.core/src/**/*.java", 131 "org.jacoco.report/src/**/*.java", 132 "org.jacoco.cli/src/**/*.java", 133 ], 134 135 java_resource_dirs: [ 136 "org.jacoco.core/src", 137 "org.jacoco.report/src", 138 ], 139 140 static_libs: [ 141 "asm-9.2", 142 "asm-commons-9.2", 143 "asm-tree-9.2", 144 "args4j-2.0.28", 145 ], 146 147 dist: { 148 targets: [ 149 "dist_files", 150 "apps_only", 151 ], 152 }, 153} 154