-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathrepositories.bzl
127 lines (113 loc) · 4.94 KB
/
repositories.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")
load("@com_google_api_generator_properties//:dependencies.properties.bzl", "PROPERTIES")
def com_google_api_generator_repositories():
# Import dependencies shared between Gradle and Bazel (i.e. maven dependencies)
for name, artifact in PROPERTIES.items():
_maybe(
jvm_maven_import_external,
name = name,
strip_repo_prefix = "maven.",
artifact = _fix_bazel_artifact_format(artifact),
server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"],
licenses = ["notice", "reciprocal"],
)
# Import Bazel-only dependencies (Gradle version will import maven artifacts of same
# version, while Bazel will depend on Bazel workspaces). The versions are shared in the
# properties file.
_protobuf_version = PROPERTIES["version.com_google_protobuf"]
_maybe(
http_archive,
name = "com_google_protobuf",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v%s.zip" % _protobuf_version],
strip_prefix = "protobuf-%s" % _protobuf_version,
)
_maybe(
jvm_maven_import_external,
name = "google_java_format_all_deps",
artifact = "com.google.googlejavaformat:google-java-format:jar:all-deps:%s" % PROPERTIES["version.google_java_format"],
server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"],
licenses = ["notice", "reciprocal"],
)
_maybe(
http_archive,
name = "bazel_skylib",
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
)
_maybe(
http_archive,
name = "com_google_googleapis",
strip_prefix = "googleapis-dbdd8ddeb6d9556952aa8784d9e48f2566c9911a",
urls = [
"https://github.com/googleapis/googleapis/archive/dbdd8ddeb6d9556952aa8784d9e48f2566c9911a.zip",
],
)
_maybe(
native.bind,
name = "guava",
actual = "@com_google_guava_guava//jar",
)
_maybe(
native.bind,
name = "gson",
actual = "@com_google_code_gson_gson//jar",
)
_maybe(
jvm_maven_import_external,
name = "error_prone_annotations_maven",
artifact = "com.google.errorprone:error_prone_annotations:2.3.2",
server_urls = ["https://repo.maven.apache.org/maven2/", "http://repo1.maven.org/maven2/"],
licenses = ["notice", "reciprocal"],
)
_maybe(
native.bind,
name = "error_prone_annotations",
actual = "@error_prone_annotations_maven//jar",
)
_api_common_java_version = PROPERTIES["version.com_google_api_common_java"]
_maybe(
jvm_maven_import_external,
name = "com_google_api_api_common",
artifact = "com.google.api:api-common:%s" % _api_common_java_version,
server_urls = ["https://repo.maven.apache.org/maven2/"],
)
# grpc-proto doesn't have releases, so we use hashes instead.
_io_grpc_proto_prefix = "0020624375a8ee4c7dd9b3e513e443b90bc28990" # Aug. 20, 2020.
_maybe(
http_archive,
name = "io_grpc_proto",
urls = ["https://github.com/grpc/grpc-proto/archive/%s.zip" % _io_grpc_proto_prefix],
strip_prefix = "grpc-proto-%s" % _io_grpc_proto_prefix,
)
def _maybe(repo_rule, name, strip_repo_prefix = "", **kwargs):
if not name.startswith(strip_repo_prefix):
return
repo_name = name[len(strip_repo_prefix):]
if repo_name in native.existing_rules():
return
repo_rule(name = repo_name, **kwargs)
def _fix_bazel_artifact_format(artifact_id):
# Fix the artifact id format discrepancy between Bazel & Gradle.
# This is relevant only when classifier is specified explicitly.
# Bazel format: groupId:artifactId:jar:classifier:version
# Gradle format: groupId:artifactId:version:classifier
ids = artifact_id.split(":")
if len(ids) != 4:
return artifact_id
return "%s:%s:%s:%s:%s" % (ids[0], ids[1], "jar", ids[3], ids[2])