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