Skip to content

Commit f8f068d

Browse files
authored
Fix #2659: Add third party wrapper libs (#2663)
* Fix broken build. Note this might be specific to Bazel 4.0, but this seems more correct anyway. * Proof-of-concept for wrapping third parties. I'm probably just going to migrate everything since I think this can be easily generalized. * Move all dependency declarations to versions.bzl. Also, automatically generate the wrapper libraries. Only constraint layout is being used currently. * Add more versions to versions.bzl. This adds more versions to a central location for management. It's not quite comprehensive, but it does provide at least a place for these versions to live as the codebase continues to change over time. * Replace artifacts with third_party references. Also, fixes some references to artifacts that weren't actually being imported via Maven. * Split prod & test deps.
1 parent 2db5e03 commit f8f068d

File tree

9 files changed

+411
-312
lines changed

9 files changed

+411
-312
lines changed

WORKSPACE

Lines changed: 17 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This file lists and imports all external dependencies needed to build Oppia Andr
55
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
66
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")
77
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
8+
load("//third_party:versions.bzl", "HTTP_DEPENDENCY_VERSIONS", "get_maven_dependencies")
89

910
# Android SDK configuration. For more details, see:
1011
# https://docs.bazel.build/versions/master/be/android.html#android_sdk_repository
@@ -15,26 +16,18 @@ android_sdk_repository(
1516
)
1617

1718
# Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external
18-
RULES_JVM_EXTERNAL_TAG = "2.9"
19-
20-
RULES_JVM_EXTERNAL_SHA = "e5b97a31a3e8feed91636f42e19b11c49487b85e5de2f387c999ea14d77c7f45"
21-
2219
http_archive(
2320
name = "rules_jvm_external",
24-
sha256 = RULES_JVM_EXTERNAL_SHA,
25-
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
26-
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
21+
sha256 = HTTP_DEPENDENCY_VERSIONS["rules_jvm"]["sha"],
22+
strip_prefix = "rules_jvm_external-%s" % HTTP_DEPENDENCY_VERSIONS["rules_jvm"]["version"],
23+
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % HTTP_DEPENDENCY_VERSIONS["rules_jvm"]["version"],
2724
)
2825

2926
# Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin.
30-
RULES_KOTLIN_VERSION = "v1.5.0-alpha-2"
31-
32-
RULES_KOTLIN_SHA = "6194a864280e1989b6d8118a4aee03bb50edeeae4076e5bc30eef8a98dcd4f07"
33-
3427
http_archive(
3528
name = "io_bazel_rules_kotlin",
36-
sha256 = RULES_KOTLIN_SHA,
37-
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % RULES_KOTLIN_VERSION],
29+
sha256 = HTTP_DEPENDENCY_VERSIONS["rules_kotlin"]["sha"],
30+
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % HTTP_DEPENDENCY_VERSIONS["rules_kotlin"]["version"]],
3831
)
3932

4033
# TODO(#1535): Remove once rules_kotlin is released because these lines become unnecessary
@@ -54,6 +47,7 @@ module while helping us avoid the unnecessary compilation of protoc. Referecence
5447
- https://github.com/google/startup-os/blob/5f30a62/WORKSPACE#L179-L187
5548
- https://github.com/bazelbuild/bazel/issues/7095
5649
"""
50+
5751
bind(
5852
name = "proto_compiler",
5953
actual = "//tools:protoc",
@@ -67,8 +61,8 @@ bind(
6761
# The rules_java contains the java_lite_proto_library rule used in the model module.
6862
http_archive(
6963
name = "rules_java",
70-
sha256 = "220b87d8cfabd22d1c6d8e3cdb4249abd4c93dcc152e0667db061fb1b957ee68",
71-
url = "https://github.com/bazelbuild/rules_java/releases/download/0.1.1/rules_java-0.1.1.tar.gz",
64+
sha256 = HTTP_DEPENDENCY_VERSIONS["rules_java"]["sha"],
65+
url = "https://github.com/bazelbuild/rules_java/releases/download/{0}/rules_java-{0}.tar.gz".format(HTTP_DEPENDENCY_VERSIONS["rules_java"]["version"]),
7266
)
7367

7468
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
@@ -80,9 +74,9 @@ rules_java_toolchains()
8074
# The rules_proto contains the proto_library rule used in the model module.
8175
http_archive(
8276
name = "rules_proto",
83-
sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208",
84-
strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313",
85-
urls = ["https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz"],
77+
sha256 = HTTP_DEPENDENCY_VERSIONS["rules_proto"]["sha"],
78+
strip_prefix = "rules_proto-%s" % HTTP_DEPENDENCY_VERSIONS["rules_proto"]["version"],
79+
urls = ["https://github.com/bazelbuild/rules_proto/archive/%s.tar.gz" % HTTP_DEPENDENCY_VERSIONS["rules_proto"]["version"]],
8680
)
8781

8882
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
@@ -92,15 +86,11 @@ rules_proto_dependencies()
9286
rules_proto_toolchains()
9387

9488
# Add support for Dagger
95-
DAGGER_TAG = "2.28.1"
96-
97-
DAGGER_SHA = "9e69ab2f9a47e0f74e71fe49098bea908c528aa02fa0c5995334447b310d0cdd"
98-
9989
http_archive(
10090
name = "dagger",
101-
sha256 = DAGGER_SHA,
102-
strip_prefix = "dagger-dagger-%s" % DAGGER_TAG,
103-
urls = ["https://github.com/google/dagger/archive/dagger-%s.zip" % DAGGER_TAG],
91+
sha256 = HTTP_DEPENDENCY_VERSIONS["dagger"]["sha"],
92+
strip_prefix = "dagger-dagger-%s" % HTTP_DEPENDENCY_VERSIONS["dagger"]["version"],
93+
urls = ["https://github.com/google/dagger/archive/dagger-%s.zip" % HTTP_DEPENDENCY_VERSIONS["dagger"]["version"]],
10494
)
10595

10696
load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES")
@@ -140,71 +130,9 @@ bind(
140130

141131
load("@rules_jvm_external//:defs.bzl", "maven_install")
142132

133+
# Note to developers: new dependencies should be added to //third_party:versions.bzl, not here.
143134
maven_install(
144-
artifacts = DAGGER_ARTIFACTS + [
145-
"android.arch.core:core-testing:1.1.1",
146-
"androidx.annotation:annotation:1.1.0",
147-
"androidx.appcompat:appcompat:1.0.2",
148-
"androidx.arch.core:core-testing:2.1.0",
149-
"androidx.constraintlayout:constraintlayout:1.1.3",
150-
"androidx.core:core-ktx:1.0.1",
151-
"androidx.core:core:1.0.1",
152-
"androidx.databinding:databinding-adapters:3.4.2",
153-
"androidx.databinding:databinding-common:3.4.2",
154-
"androidx.databinding:databinding-compiler:3.4.2",
155-
"androidx.databinding:databinding-runtime:3.4.2",
156-
"androidx.lifecycle:lifecycle-extensions:2.2.0",
157-
"androidx.lifecycle:lifecycle-livedata-core:2.2.0",
158-
"androidx.lifecycle:lifecycle-livedata-ktx:2.2.0",
159-
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0",
160-
"androidx.multidex:multidex-instrumentation:2.0.0",
161-
"androidx.multidex:multidex:2.0.1",
162-
"androidx.navigation:navigation-fragment:2.0.0",
163-
"androidx.navigation:navigation-fragment-ktx:2.0.0",
164-
"androidx.navigation:navigation-ui:2.0.0",
165-
"androidx.navigation:navigation-ui-ktx:2.0.0",
166-
"androidx.recyclerview:recyclerview:1.0.0",
167-
"androidx.room:room-runtime:2.2.5",
168-
"androidx.test.espresso:espresso-contrib:3.1.0",
169-
"androidx.test.espresso:espresso-core:3.2.0",
170-
"androidx.test.espresso:espresso-intents:3.1.0",
171-
"androidx.test.ext:junit:1.1.1",
172-
"androidx.test:runner:1.2.0",
173-
"androidx.viewpager:viewpager:1.0.0",
174-
"androidx.work:work-runtime:2.4.0",
175-
"androidx.work:work-runtime-ktx:2.4.0",
176-
"androidx.work:work-testing:2.4.0",
177-
"com.android.support:support-annotations:28.0.0",
178-
"com.caverock:androidsvg-aar:1.4",
179-
"com.chaos.view:pinview:1.4.4",
180-
"com.crashlytics.sdk.android:crashlytics:2.9.8",
181-
"com.github.bumptech.glide:glide:4.11.0",
182-
"com.github.bumptech.glide:mocks:4.11.0",
183-
"com.google.android:flexbox:2.0.1",
184-
"com.google.android.material:material:1.2.0-alpha02",
185-
"com.google.firebase:firebase-analytics:17.5.0",
186-
"com.google.firebase:firebase-crashlytics:17.1.1",
187-
"com.google.gms:google-services:4.3.3",
188-
"com.google.guava:guava:28.1-android",
189-
"com.google.truth:truth:0.43",
190-
"com.squareup.retrofit2:converter-gson:2.5.0",
191-
"com.squareup.retrofit2:retrofit:2.9.0",
192-
"de.hdodenhof:circleimageview:3.0.1",
193-
"io.fabric.sdk.android:fabric:1.4.7",
194-
"javax.annotation:javax.annotation-api:jar:1.3.2",
195-
"junit:junit:4.12",
196-
"nl.dionsegijn:konfetti:1.2.5",
197-
"org.jetbrains.kotlin:kotlin-reflect:1.3.41",
198-
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72",
199-
"org.jetbrains.kotlin:kotlin-test-junit:1.3.72",
200-
"org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2",
201-
"org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2",
202-
"org.jetbrains:annotations:jar:13.0",
203-
"org.mockito:mockito-core:2.19.0",
204-
"org.mockito:mockito-core:2.7.22",
205-
"org.robolectric:annotations:4.3",
206-
"org.robolectric:robolectric:4.3",
207-
],
135+
artifacts = DAGGER_ARTIFACTS + get_maven_dependencies(),
208136
repositories = DAGGER_REPOSITORIES + [
209137
"https://bintray.com/bintray/jcenter",
210138
"https://jcenter.bintray.com/",

0 commit comments

Comments
 (0)