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