• 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        "//libcore",
100        "//packages/modules/ArtPrebuilt",
101    ],
102    srcs: [
103        ":okhttp_impl_files",
104    ],
105
106    hostdex: true,
107    installable: true,
108
109    sdk_version: "none",
110    system_modules: "core-all-system-modules",
111    libs: [
112        "conscrypt.module.intra.core.api",
113    ],
114    java_version: "1.7",
115    apex_available: [
116        "com.android.art",
117        "com.android.art.debug",
118    ],
119    min_sdk_version: "31",
120}
121
122// Java library for use on host, e.g. by robolectric.
123java_library {
124    name: "okhttp-for-host",
125    visibility: [
126        "//art/build/sdk",
127        "//external/robolectric-shadows",
128    ],
129    static_libs: [
130        "okhttp",
131    ],
132    sdk_version: "none",
133    system_modules: "none",
134}
135
136// Java Library for both Host and Android that does not use the repackaged okhttp libraries
137// (com.android.okhttp) and instead uses the original (com.squareup.okhttp) packages.
138// This should not end up on the bootclasspath and instead should only be used to build
139// third-party or unbundled applications or libraries that require OkHttp.
140java_library {
141    name: "okhttp-norepackage",
142    host_supported: true,
143
144    visibility: [
145        "//art/build/sdk",
146        "//external/grpc-grpc-java/okhttp",
147    ],
148
149    srcs: [
150        "okhttp/src/main/java/**/*.java",
151        "okhttp-urlconnection/src/main/java/**/*.java",
152        "okio/okio/src/main/java/**/*.java",
153        ":okhttp_version.java",
154    ],
155
156    target: {
157        host: {
158            libs: [
159                "okhttp-android-util-log",
160            ],
161        },
162    },
163
164    installable: true,
165    sdk_version: "current",
166}
167
168// Generate Version.java based on the version number from pom.xml.
169genrule {
170    name: "okhttp_version.java",
171    srcs: [
172        "okhttp/src/main/java-templates/com/squareup/okhttp/internal/Version.java",
173        "okhttp/pom.xml",
174    ],
175    out: ["com/squareup/okhttp/internal/Version.java"],
176    cmd: "grep \"<version>\" $(location okhttp/pom.xml) | head -1 |" +
177        " sed -e \"s/\\s*<version>\\(.*\\)<\\/version>/\\1/\" > $(genDir)/version && " +
178        "sed -e \"s/\\$${project.version}/$$(cat $(genDir)/version)/\" " +
179        " $(location okhttp/src/main/java-templates/com/squareup/okhttp/internal/Version.java) " +
180        "> $(out)",
181}
182
183// A library to provide a stub android.util.Log symbol for
184// okhttp/src/main/java/com/squareup/okhttp/internal/Platform.java
185java_library_host {
186    name: "okhttp-android-util-log",
187    srcs: ["okhttp-android-util-log/src/main/java/**/*.java"],
188}
189
190java_library {
191    name: "okhttp-tests-nojarjar",
192    visibility: nojarjar_visibility,
193    srcs: [
194        "android/test/java/**/*.java",
195        "okhttp-android-support/src/test/java/**/*.java",
196        "okhttp-testing-support/src/main/java/**/*.java",
197        "okhttp-tests/src/test/java/**/*.java",
198        "okhttp-urlconnection/src/test/java/**/*.java",
199        "okhttp-ws/src/main/java/**/*.java",
200        "okhttp-ws-tests/src/test/java/**/*.java",
201        "okio/okio/src/test/java/**/*.java",
202        "mockwebserver/src/main/java/**/*.java",
203        "mockwebserver/src/test/java/**/*.java",
204    ],
205    // Exclude test Android currently has problems with due to @Parameterized (requires JUnit 4.11).
206    exclude_srcs: ["okhttp-tests/src/test/java/com/squareup/okhttp/WebPlatformUrlTest.java"],
207
208    sdk_version: "none",
209    system_modules: "core-all-system-modules",
210    libs: [
211        "okhttp-nojarjar",
212        "junit",
213        "conscrypt.module.intra.core.api",
214        "bouncycastle-unbundled",
215    ],
216
217    java_version: "1.7",
218}
219