1// 2// Copyright (C) 2012 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 17package { 18 default_team: "trendy_team_java_core_libraries", 19 default_visibility: ["//visibility:private"], 20 default_applicable_licenses: ["external_okhttp_license"], 21} 22 23// Added automatically by a large-scale-change 24// See: http://go/android-license-faq 25license { 26 name: "external_okhttp_license", 27 visibility: [":__subpackages__"], 28 license_kinds: [ 29 "SPDX-license-identifier-Apache-2.0", 30 ], 31 license_text: [ 32 "LICENSE", 33 ], 34} 35 36java_defaults { 37 name: "okhttp_errorprone_defaults", 38 errorprone: { 39 javacflags: [ 40 "-Xep:InvalidTimeZoneID:WARN", 41 "-Xep:TryFailThrowable:WARN", 42 ], 43 }, 44} 45 46// The source files that contribute to Android's core library APIs. 47filegroup { 48 name: "okhttp_api_files", 49 visibility: ["//libcore"], 50 // Use the repackaged version of android as that is what is used by Android core library 51 // APIs. 52 srcs: ["repackaged/android/src/main/java/com/android/okhttp/internalandroidapi/**/*.java"], 53} 54 55nojarjar_visibility = [ 56 "//art/build/sdk", 57 "//cts/tests/libcore/okhttp", 58] 59 60// non-jarjar'd version of okhttp to compile the tests against 61java_library { 62 name: "okhttp-nojarjar", 63 defaults: ["okhttp_errorprone_defaults"], 64 visibility: nojarjar_visibility, 65 srcs: [ 66 "android/src/main/java/**/*.java", 67 "okhttp/src/main/java/**/*.java", 68 "okhttp-urlconnection/src/main/java/**/*.java", 69 "okhttp-android-support/src/main/java/**/*.java", 70 "okio/okio/src/main/java/**/*.java", 71 ], 72 exclude_srcs: ["okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java"], 73 74 hostdex: true, 75 76 sdk_version: "none", 77 system_modules: "core-all-system-modules", 78 libs: [ 79 "conscrypt.module.intra.core.api.stubs", 80 ], 81 java_version: "1.7", 82} 83 84// The source implementation files, used to build okhttp and core-all. It is 85// used in the latter case to break the cycle where okhttp depends on core-all 86// and core-all depends on okhttp. By including the source into core-all it 87// ensures that the code can all build correctly and then that is used to build 88// the separate parts. 89filegroup { 90 name: "okhttp_impl_files", 91 visibility: ["//libcore"], 92 srcs: [ 93 // Although some of the classes in the android/ directory are already in the correct 94 // package and do not need to be moved to another package they are transformed as they 95 // reference other classes that do require repackaging. 96 "repackaged/android/src/main/java/**/*.java", 97 "repackaged/okhttp/src/main/java/**/*.java", 98 "repackaged/okhttp-urlconnection/src/main/java/**/*.java", 99 "repackaged/okhttp-android-support/src/main/java/**/*.java", 100 "repackaged/okio/okio/src/main/java/**/*.java", 101 ], 102} 103 104java_library { 105 name: "okhttp", 106 defaults: ["okhttp_errorprone_defaults"], 107 visibility: [ 108 "//art/build/apex", 109 "//art/build/sdk", 110 "//art/tools/ahat", 111 "//art/tools/fuzzer", 112 "//external/grpc-grpc-java/okhttp", 113 "//external/robolectric-shadows", 114 "//external/robolectric", 115 "//libcore:__subpackages__", 116 "//packages/modules/ArtPrebuilt", 117 ], 118 srcs: [ 119 ":okhttp_impl_files", 120 ], 121 122 hostdex: true, 123 installable: true, 124 125 optimize: { 126 enabled: true, 127 shrink: false, 128 optimize: false, 129 obfuscate: false, 130 proguard_compatibility: false, 131 ignore_warnings: false, 132 }, 133 134 sdk_version: "none", 135 system_modules: "core-all-system-modules", 136 libs: [ 137 "conscrypt.module.intra.core.api.stubs", 138 ], 139 java_version: "1.7", 140 apex_available: [ 141 "com.android.art", 142 "com.android.art.debug", 143 ], 144 min_sdk_version: "31", 145} 146 147// Java library for use on host, e.g. by robolectric. 148java_library { 149 name: "okhttp-for-host", 150 visibility: [ 151 "//art/build/sdk", 152 "//external/robolectric-shadows", 153 "//external/robolectric", 154 ], 155 static_libs: [ 156 "okhttp", 157 ], 158 sdk_version: "none", 159 system_modules: "none", 160} 161 162// Java Library for both Host and Android that does not use the repackaged okhttp libraries 163// (com.android.okhttp) and instead uses the original (com.squareup.okhttp) packages. 164// This should not end up on the bootclasspath and instead should only be used to build 165// third-party or unbundled applications or libraries that require OkHttp. 166java_library { 167 name: "okhttp-norepackage", 168 defaults: ["okhttp_errorprone_defaults"], 169 host_supported: true, 170 apex_available: [ 171 "//apex_available:platform", 172 "com.android.adservices", 173 "com.android.devicelock", 174 "com.android.extservices", 175 "com.android.ondevicepersonalization", 176 "com.android.virt", 177 ], 178 visibility: [ 179 "//art/build/sdk", 180 "//external/grpc-grpc-java/okhttp", 181 "//vendor:__subpackages__", 182 ], 183 184 srcs: [ 185 "okhttp/src/main/java/**/*.java", 186 "okhttp-urlconnection/src/main/java/**/*.java", 187 ":okhttp_version.java", 188 ], 189 190 libs: [ 191 // Building against "core_current" means that the android.util.Log API 192 // is not available. This provides stubs for it which allows the code to 193 // compile. 194 "okhttp-android-util-log", 195 ], 196 197 static_libs: [ 198 "okio-lib", 199 ], 200 201 installable: true, 202 // Build against a "core_current" as it cannot use "current" as it has to 203 // build in manifests without frameworks/base. 204 sdk_version: "core_current", 205 // Make sure that this will be added to the sdk snapshot for S. 206 min_sdk_version: "30", 207 // This jar is packaged as part of the ART module host exports, use -target 8 so that it works 208 // with old JDKs. 209 java_version: "1.8", 210} 211 212// Generate Version.java based on the version number from pom.xml. 213genrule { 214 name: "okhttp_version.java", 215 srcs: [ 216 "okhttp/src/main/java-templates/com/squareup/okhttp/internal/Version.java", 217 "okhttp/pom.xml", 218 ], 219 out: ["com/squareup/okhttp/internal/Version.java"], 220 cmd: "grep \"<version>\" $(location okhttp/pom.xml) | head -1 |" + 221 " sed -e \"s/\\s*<version>\\(.*\\)<\\/version>/\\1/\" > $(genDir)/version && " + 222 "sed -e \"s/\\$${project.version}/$$(cat $(genDir)/version)/\" " + 223 " $(location okhttp/src/main/java-templates/com/squareup/okhttp/internal/Version.java) " + 224 "> $(out)", 225} 226 227// A library to provide a stub android.util.Log symbol for 228// okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java 229java_library { 230 name: "okhttp-android-util-log", 231 host_supported: true, 232 srcs: ["okhttp-android-util-log/src/main/java/**/*.java"], 233 sdk_version: "core_current", 234} 235 236java_library { 237 name: "okhttp-tests-nojarjar", 238 defaults: ["okhttp_errorprone_defaults"], 239 visibility: nojarjar_visibility, 240 srcs: [ 241 "android/test/java/**/*.java", 242 "okhttp-android-support/src/test/java/**/*.java", 243 "okhttp-testing-support/src/main/java/**/*.java", 244 "okhttp-tests/src/test/java/**/*.java", 245 "okhttp-urlconnection/src/test/java/**/*.java", 246 "okhttp-ws/src/main/java/**/*.java", 247 "okhttp-ws-tests/src/test/java/**/*.java", 248 "okio/okio/src/test/java/**/*.java", 249 "mockwebserver/src/main/java/**/*.java", 250 "mockwebserver/src/test/java/**/*.java", 251 ], 252 // Exclude test Android currently has problems with due to @Parameterized (requires JUnit 4.11). 253 exclude_srcs: ["okhttp-tests/src/test/java/com/squareup/okhttp/WebPlatformUrlTest.java"], 254 255 sdk_version: "none", 256 system_modules: "core-all-system-modules", 257 libs: [ 258 "okhttp-nojarjar", 259 "junit", 260 "conscrypt.module.intra.core.api.stubs", 261 "bouncycastle-unbundled", 262 ], 263 264 java_version: "1.7", 265} 266