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