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 sdk_version: "none", 126 system_modules: "core-all-system-modules", 127 libs: [ 128 "conscrypt.module.intra.core.api.stubs", 129 ], 130 java_version: "1.7", 131 apex_available: [ 132 "com.android.art", 133 "com.android.art.debug", 134 ], 135 min_sdk_version: "31", 136} 137 138// Java library for use on host, e.g. by robolectric. 139java_library { 140 name: "okhttp-for-host", 141 visibility: [ 142 "//art/build/sdk", 143 "//external/robolectric-shadows", 144 "//external/robolectric", 145 ], 146 static_libs: [ 147 "okhttp", 148 ], 149 sdk_version: "none", 150 system_modules: "none", 151} 152 153// Java Library for both Host and Android that does not use the repackaged okhttp libraries 154// (com.android.okhttp) and instead uses the original (com.squareup.okhttp) packages. 155// This should not end up on the bootclasspath and instead should only be used to build 156// third-party or unbundled applications or libraries that require OkHttp. 157java_library { 158 name: "okhttp-norepackage", 159 defaults: ["okhttp_errorprone_defaults"], 160 host_supported: true, 161 apex_available: [ 162 "//apex_available:platform", 163 "com.android.adservices", 164 "com.android.devicelock", 165 "com.android.extservices", 166 "com.android.ondevicepersonalization", 167 "com.android.virt", 168 ], 169 visibility: [ 170 "//art/build/sdk", 171 "//external/grpc-grpc-java/okhttp", 172 "//vendor:__subpackages__", 173 ], 174 175 srcs: [ 176 "okhttp/src/main/java/**/*.java", 177 "okhttp-urlconnection/src/main/java/**/*.java", 178 ":okhttp_version.java", 179 ], 180 181 libs: [ 182 // Building against "core_current" means that the android.util.Log API 183 // is not available. This provides stubs for it which allows the code to 184 // compile. 185 "okhttp-android-util-log", 186 ], 187 188 static_libs: [ 189 "okio-lib", 190 ], 191 192 installable: true, 193 // Build against a "core_current" as it cannot use "current" as it has to 194 // build in manifests without frameworks/base. 195 sdk_version: "core_current", 196 // Make sure that this will be added to the sdk snapshot for S. 197 min_sdk_version: "30", 198 // This jar is packaged as part of the ART module host exports, use -target 8 so that it works 199 // with old JDKs. 200 java_version: "1.8", 201} 202 203// Generate Version.java based on the version number from pom.xml. 204genrule { 205 name: "okhttp_version.java", 206 srcs: [ 207 "okhttp/src/main/java-templates/com/squareup/okhttp/internal/Version.java", 208 "okhttp/pom.xml", 209 ], 210 out: ["com/squareup/okhttp/internal/Version.java"], 211 cmd: "grep \"<version>\" $(location okhttp/pom.xml) | head -1 |" + 212 " sed -e \"s/\\s*<version>\\(.*\\)<\\/version>/\\1/\" > $(genDir)/version && " + 213 "sed -e \"s/\\$${project.version}/$$(cat $(genDir)/version)/\" " + 214 " $(location okhttp/src/main/java-templates/com/squareup/okhttp/internal/Version.java) " + 215 "> $(out)", 216} 217 218// A library to provide a stub android.util.Log symbol for 219// okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java 220java_library { 221 name: "okhttp-android-util-log", 222 host_supported: true, 223 srcs: ["okhttp-android-util-log/src/main/java/**/*.java"], 224 sdk_version: "core_current", 225} 226 227java_library { 228 name: "okhttp-tests-nojarjar", 229 defaults: ["okhttp_errorprone_defaults"], 230 visibility: nojarjar_visibility, 231 srcs: [ 232 "android/test/java/**/*.java", 233 "okhttp-android-support/src/test/java/**/*.java", 234 "okhttp-testing-support/src/main/java/**/*.java", 235 "okhttp-tests/src/test/java/**/*.java", 236 "okhttp-urlconnection/src/test/java/**/*.java", 237 "okhttp-ws/src/main/java/**/*.java", 238 "okhttp-ws-tests/src/test/java/**/*.java", 239 "okio/okio/src/test/java/**/*.java", 240 "mockwebserver/src/main/java/**/*.java", 241 "mockwebserver/src/test/java/**/*.java", 242 ], 243 // Exclude test Android currently has problems with due to @Parameterized (requires JUnit 4.11). 244 exclude_srcs: ["okhttp-tests/src/test/java/com/squareup/okhttp/WebPlatformUrlTest.java"], 245 246 sdk_version: "none", 247 system_modules: "core-all-system-modules", 248 libs: [ 249 "okhttp-nojarjar", 250 "junit", 251 "conscrypt.module.intra.core.api.stubs", 252 "bouncycastle-unbundled", 253 ], 254 255 java_version: "1.7", 256} 257