xref: /aosp_15_r20/external/dagger2/examples/bazel/WORKSPACE (revision f585d8a307d0621d6060bd7e80091fdcbf94fe27)
1# Copyright (C) 2020 The Dagger Authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# Description:
16#   Defines the Bazel workspace rules for the Dagger examples.
17
18########################
19# Load Dagger repository
20########################
21
22# In a real project, this repository would use `http_archive` to link to a
23# tagged, released version of the Dagger, but we use `local_repository` so that
24# CI testing can test local changes to workspace_defs.bzl.
25local_repository(
26    name = "dagger",
27    path = "../../",
28)
29
30load(
31    "@dagger//:workspace_defs.bzl",
32    "DAGGER_ARTIFACTS",
33    "DAGGER_REPOSITORIES",
34    "HILT_ANDROID_ARTIFACTS",
35    "HILT_ANDROID_REPOSITORIES",
36)
37
38#########################
39# Load Android repository
40#########################
41
42android_sdk_repository(
43    name = "androidsdk",
44    api_level = 32,
45    build_tools_version = "32.0.0",
46)
47
48#############################
49# Load Robolectric repository
50#############################
51
52load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
53
54http_archive(
55    name = "robolectric",
56    strip_prefix = "robolectric-bazel-4.1",
57    urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.1.tar.gz"],
58)
59
60load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
61
62robolectric_repositories()
63
64#########################
65# Load Maven repositories
66#########################
67
68RULES_JVM_EXTERNAL_TAG = "4.2"
69
70RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"
71
72http_archive(
73    name = "rules_jvm_external",
74    sha256 = RULES_JVM_EXTERNAL_SHA,
75    strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
76    url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
77)
78
79load("@rules_jvm_external//:defs.bzl", "maven_install")
80
81maven_install(
82    artifacts = DAGGER_ARTIFACTS + HILT_ANDROID_ARTIFACTS + [
83        "androidx.test.ext:junit:1.1.1",
84        "androidx.test:runner:1.1.1",
85        "com.google.truth:truth:1.0.1",
86        "junit:junit:4.13",
87        "org.robolectric:robolectric:4.1",
88        "org.robolectric:annotations:4.1",
89    ],
90    repositories = DAGGER_REPOSITORIES + HILT_ANDROID_REPOSITORIES,
91)
92