• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = 34,
45    build_tools_version = "34.0.0",
46)
47
48#############################
49# Load Robolectric repository
50#############################
51
52load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
53
54ROBOLECTRIC_VERSION = "4.11.1"
55
56http_archive(
57    name = "robolectric",
58    sha256 = "1ea1cfe67848decf959316e80dd69af2bbaa359ae2195efe1366cbdf3e968356",
59    strip_prefix = "robolectric-bazel-%s" % ROBOLECTRIC_VERSION,
60    urls = ["https://github.com/robolectric/robolectric-bazel/releases/download/%s/robolectric-bazel-%s.tar.gz" % (ROBOLECTRIC_VERSION, ROBOLECTRIC_VERSION)],
61)
62
63load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
64
65robolectric_repositories()
66
67#########################
68# Load Maven repositories
69#########################
70
71RULES_JVM_EXTERNAL_TAG = "4.2"
72
73RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"
74
75http_archive(
76    name = "rules_jvm_external",
77    sha256 = RULES_JVM_EXTERNAL_SHA,
78    strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
79    url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
80)
81
82load("@rules_jvm_external//:defs.bzl", "maven_install")
83
84maven_install(
85    artifacts = DAGGER_ARTIFACTS + HILT_ANDROID_ARTIFACTS + [
86        "androidx.test.ext:junit:1.1.1",
87        "androidx.test:runner:1.1.1",
88        "com.google.truth:truth:1.0.1",
89        "junit:junit:4.13",
90        "org.robolectric:robolectric:%s" % ROBOLECTRIC_VERSION,
91        "org.robolectric:annotations:%s" % ROBOLECTRIC_VERSION,
92    ],
93    repositories = DAGGER_REPOSITORIES + HILT_ANDROID_REPOSITORIES,
94)
95