From d68f0a9e5f1b364c0ee4e33ccf252d07dae9cdef Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 29 Jun 2020 16:18:45 -0400 Subject: [PATCH 001/106] Working on having one module build with bazel --- BUILD.bazel | 0 WORKSPACE | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 BUILD.bazel create mode 100644 WORKSPACE diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 00000000000..e69de29bb2d diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000000..e69de29bb2d From 37a13f8dbd2a4e92e5602614ae3cbef64a4ea238 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 16 Jul 2020 15:58:49 -0400 Subject: [PATCH 002/106] Created initial app-level WORKSPACE file --- WORKSPACE | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index e69de29bb2d..566de006eb8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -0,0 +1,85 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") + +android_sdk_repository( + name = "androidsdk", + api_level = 28, + build_tools_version = "28.0.2", +) + +#Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external +RULES_JVM_EXTERNAL_TAG = "2.9" +RULES_JVM_EXTERNAL_SHA = "e5b97a31a3e8feed91636f42e19b11c49487b85e5de2f387c999ea14d77c7f45" +http_archive( + name = "rules_jvm_external", + strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, + sha256 = RULES_JVM_EXTERNAL_SHA, + url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, +) + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +# Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin. +RULES_KOTLIN_VERSION = "legacy-1.3.0-rc4" +RULES_KOTLIN_SHA = "fe32ced5273bcc2f9e41cea65a28a9184a77f3bc30fea8a5c47b3d3bfc801dff" +http_archive( + name = "io_bazel_rules_kotlin", + urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], + type = "zip", + strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, + sha256 = RULES_KOTLIN_SHA, +) + +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") +kotlin_repositories() +kt_register_toolchains() + +#Add support for Dagger: https://github.com/google/dagger +DAGGER_TAG = "2.28.1" +DAGGER_SHA = "9e69ab2f9a47e0f74e71fe49098bea908c528aa02fa0c5995334447b310d0cdd" +http_archive( + name = "dagger", + strip_prefix = "dagger-dagger-%s" % DAGGER_TAG, + sha256 = DAGGER_SHA, + urls = ["https://github.com/google/dagger/archive/dagger-%s.zip" % DAGGER_TAG], +) + +load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") + +#Add support for Retrofit +jvm_maven_import_external( + name = "retrofit", + artifact = "com.squareup.retrofit2:retrofit:2.9.0", + server_urls = ["http://central.maven.org/maven2"], + licenses = ["notice"], # Apache 2.0 +) + +#Add support for Data-binding +bind( + name = "databinding_annotation_processor", + actual = "//tools/android:compiler_annotation_processor", +) + +maven_install( + artifacts = DAGGER_ARTIFACTS + [ + "com.android.databinding:adapters:3.4.2", + "com.android.databinding:library:3.4.2", + "com.android.databinding:baseLibrary:3.4.2", + "com.android.support:support-annotations:28.0.0", + "com.crashlytics.sdk.android:crashlytics:2.9.8", + "io.fabric.sdk.android:fabric:1.4.7", + "com.squareup.retrofit2:retrofit:2.9.0", + "com.squareup.retrofit2:converter-gson:2.5.0", + "com.google.gms:google-services:4.3.3", + ], + repositories = DAGGER_REPOSITORIES + [ + "https://jcenter.bintray.com/", + "https://maven.google.com", + "https://repo1.maven.org/maven2", + "https://maven.fabric.io/public", + "https://bintray.com/bintray/jcenter", + ], +) + +#TODO: Add tools_android with the following change: +#https://github.com/bazelbuild/tools_android/commit/58d67fd54a3b7f5f1e6ddfa865442db23a60e1b6 \ No newline at end of file From f522846e2497e99fbb5c5340156a59495e2c2c58 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 16 Jul 2020 17:27:30 -0400 Subject: [PATCH 003/106] Added proto_library rule to build model app module --- WORKSPACE | 50 -------------------------------- model/src/main/proto/BUILD.bazel | 19 ++++++++++++ model/src/main/proto/WORKSPACE | 16 ++++++++++ 3 files changed, 35 insertions(+), 50 deletions(-) create mode 100644 model/src/main/proto/BUILD.bazel create mode 100644 model/src/main/proto/WORKSPACE diff --git a/WORKSPACE b/WORKSPACE index 566de006eb8..e31343d7647 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -33,53 +33,3 @@ http_archive( load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") kotlin_repositories() kt_register_toolchains() - -#Add support for Dagger: https://github.com/google/dagger -DAGGER_TAG = "2.28.1" -DAGGER_SHA = "9e69ab2f9a47e0f74e71fe49098bea908c528aa02fa0c5995334447b310d0cdd" -http_archive( - name = "dagger", - strip_prefix = "dagger-dagger-%s" % DAGGER_TAG, - sha256 = DAGGER_SHA, - urls = ["https://github.com/google/dagger/archive/dagger-%s.zip" % DAGGER_TAG], -) - -load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") - -#Add support for Retrofit -jvm_maven_import_external( - name = "retrofit", - artifact = "com.squareup.retrofit2:retrofit:2.9.0", - server_urls = ["http://central.maven.org/maven2"], - licenses = ["notice"], # Apache 2.0 -) - -#Add support for Data-binding -bind( - name = "databinding_annotation_processor", - actual = "//tools/android:compiler_annotation_processor", -) - -maven_install( - artifacts = DAGGER_ARTIFACTS + [ - "com.android.databinding:adapters:3.4.2", - "com.android.databinding:library:3.4.2", - "com.android.databinding:baseLibrary:3.4.2", - "com.android.support:support-annotations:28.0.0", - "com.crashlytics.sdk.android:crashlytics:2.9.8", - "io.fabric.sdk.android:fabric:1.4.7", - "com.squareup.retrofit2:retrofit:2.9.0", - "com.squareup.retrofit2:converter-gson:2.5.0", - "com.google.gms:google-services:4.3.3", - ], - repositories = DAGGER_REPOSITORIES + [ - "https://jcenter.bintray.com/", - "https://maven.google.com", - "https://repo1.maven.org/maven2", - "https://maven.fabric.io/public", - "https://bintray.com/bintray/jcenter", - ], -) - -#TODO: Add tools_android with the following change: -#https://github.com/bazelbuild/tools_android/commit/58d67fd54a3b7f5f1e6ddfa865442db23a60e1b6 \ No newline at end of file diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel new file mode 100644 index 00000000000..a572d2469b8 --- /dev/null +++ b/model/src/main/proto/BUILD.bazel @@ -0,0 +1,19 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") + +proto_library( + name = "proto_lib", + srcs = ["event_logger.proto", + "example.proto", + "exploration.proto", + "interaction_object.proto", + "onboarding.proto", + "profile.proto", + "question.proto", + "subtitled_html.proto", + "topic.proto", + "thumbnail.proto", + "translation.proto", + "voiceover.proto", + ], +) + diff --git a/model/src/main/proto/WORKSPACE b/model/src/main/proto/WORKSPACE new file mode 100644 index 00000000000..222f7124e1f --- /dev/null +++ b/model/src/main/proto/WORKSPACE @@ -0,0 +1,16 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +# rules_proto defines abstract rules for building Protocol Buffers. +http_archive( + name = "rules_proto", + sha256 = "2490dca4f249b8a9a3ab07bd1ba6eca085aaf8e45a734af92aad0c42d9dc7aaf", + strip_prefix = "rules_proto-218ffa7dfa5408492dc86c01ee637614f8695c45", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") +rules_proto_dependencies() +rules_proto_toolchains() \ No newline at end of file From 372deaeb5dae2c50075dc8d6389399d0ebd58df9 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 16 Jul 2020 17:30:43 -0400 Subject: [PATCH 004/106] Added newline at end of WORKSPACE file --- model/src/main/proto/BUILD.bazel | 1 - model/src/main/proto/WORKSPACE | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel index a572d2469b8..b229d5f90a0 100644 --- a/model/src/main/proto/BUILD.bazel +++ b/model/src/main/proto/BUILD.bazel @@ -16,4 +16,3 @@ proto_library( "voiceover.proto", ], ) - diff --git a/model/src/main/proto/WORKSPACE b/model/src/main/proto/WORKSPACE index 222f7124e1f..169ff7cada9 100644 --- a/model/src/main/proto/WORKSPACE +++ b/model/src/main/proto/WORKSPACE @@ -13,4 +13,4 @@ http_archive( load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") rules_proto_dependencies() -rules_proto_toolchains() \ No newline at end of file +rules_proto_toolchains() From 5c0b6f586ceea1855703c247f3b5fdcac3627471 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 16 Jul 2020 20:14:02 -0400 Subject: [PATCH 005/106] Created macro to process proto files --- model/src/main/proto/BUILD.bazel | 29 +++++++++++++++++++--- model/src/main/proto/preprocess_protos.bzl | 12 +++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 model/src/main/proto/preprocess_protos.bzl diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel index b229d5f90a0..67224d63496 100644 --- a/model/src/main/proto/BUILD.bazel +++ b/model/src/main/proto/BUILD.bazel @@ -1,18 +1,39 @@ load("@rules_proto//proto:defs.bzl", "proto_library") +load("//:preprocess_protos.bzl", "process") proto_library( name = "proto_lib", srcs = ["event_logger.proto", "example.proto", - "exploration.proto", "interaction_object.proto", "onboarding.proto", "profile.proto", - "question.proto", "subtitled_html.proto", - "topic.proto", "thumbnail.proto", "translation.proto", "voiceover.proto", - ], + "//bazel-bin/processed_topic.proto", + "//bazel-bin/processed_question.proto", + "//bazel-bin/processed_exploration.proto", + ], + data = [ + ":process_exploration", + ":process_question", + ":process_topic", + ], ) + +process( + name = "process_topic", + src = "topic.proto" +) + +process( + name = "process_question", + src = "question.proto" +) + +process( + name = "process_exploration", + src = "exploration.proto" +) \ No newline at end of file diff --git a/model/src/main/proto/preprocess_protos.bzl b/model/src/main/proto/preprocess_protos.bzl new file mode 100644 index 00000000000..f4947724677 --- /dev/null +++ b/model/src/main/proto/preprocess_protos.bzl @@ -0,0 +1,12 @@ +def process(name, src): + """ + """ + native.genrule( + name = name, + srcs = [src], + outs = ["processed_" + src], + cmd = ''' cp $< $@ &&\ + sed 's/import \"/import \"model\/src\/main\/proto\//g' $< > $@ + ''' + , + ) From 9408e27eaf92977ac372ea2b8248d0d62c9f28fa Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 11:02:56 -0400 Subject: [PATCH 006/106] Both Bazel and Gradle now build /model successfully --- WORKSPACE | 15 +++++++++ model/BUILD.bazel | 36 ++++++++++++++++++++ model/src/main/proto/BUILD.bazel | 39 ---------------------- model/src/main/proto/WORKSPACE | 16 --------- model/src/main/proto/preprocess_protos.bzl | 9 +++++ 5 files changed, 60 insertions(+), 55 deletions(-) create mode 100644 model/BUILD.bazel delete mode 100644 model/src/main/proto/BUILD.bazel delete mode 100644 model/src/main/proto/WORKSPACE diff --git a/WORKSPACE b/WORKSPACE index e31343d7647..6d30a1861a1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -33,3 +33,18 @@ http_archive( load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") kotlin_repositories() kt_register_toolchains() + +# rules_proto defines abstract rules for building Protocol Buffers. +http_archive( + name = "rules_proto", + sha256 = "2490dca4f249b8a9a3ab07bd1ba6eca085aaf8e45a734af92aad0c42d9dc7aaf", + strip_prefix = "rules_proto-218ffa7dfa5408492dc86c01ee637614f8695c45", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") +rules_proto_dependencies() +rules_proto_toolchains() diff --git a/model/BUILD.bazel b/model/BUILD.bazel new file mode 100644 index 00000000000..e0f0c0352d8 --- /dev/null +++ b/model/BUILD.bazel @@ -0,0 +1,36 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") +load("//model:src/main/proto/preprocess_protos.bzl", "process") + +proto_library( + name = "proto_lib", + srcs = ["src/main/proto/event_logger.proto", + "src/main/proto/example.proto", + "src/main/proto/interaction_object.proto", + "src/main/proto/onboarding.proto", + "src/main/proto/profile.proto", + "src/main/proto/subtitled_html.proto", + "src/main/proto/thumbnail.proto", + "src/main/proto/translation.proto", + "src/main/proto/voiceover.proto", + ], + data = [ + ":process_exploration", + ":process_question", + :process_topic", + ], +) + +process( + name = "process_topic", + src = "topic.proto" +) + +process( + name = "process_question", + src = "question.proto" +) + +process( + name = "process_exploration", + src = "exploration.proto" +) \ No newline at end of file diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel deleted file mode 100644 index 67224d63496..00000000000 --- a/model/src/main/proto/BUILD.bazel +++ /dev/null @@ -1,39 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("//:preprocess_protos.bzl", "process") - -proto_library( - name = "proto_lib", - srcs = ["event_logger.proto", - "example.proto", - "interaction_object.proto", - "onboarding.proto", - "profile.proto", - "subtitled_html.proto", - "thumbnail.proto", - "translation.proto", - "voiceover.proto", - "//bazel-bin/processed_topic.proto", - "//bazel-bin/processed_question.proto", - "//bazel-bin/processed_exploration.proto", - ], - data = [ - ":process_exploration", - ":process_question", - ":process_topic", - ], -) - -process( - name = "process_topic", - src = "topic.proto" -) - -process( - name = "process_question", - src = "question.proto" -) - -process( - name = "process_exploration", - src = "exploration.proto" -) \ No newline at end of file diff --git a/model/src/main/proto/WORKSPACE b/model/src/main/proto/WORKSPACE deleted file mode 100644 index 169ff7cada9..00000000000 --- a/model/src/main/proto/WORKSPACE +++ /dev/null @@ -1,16 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# rules_proto defines abstract rules for building Protocol Buffers. -http_archive( - name = "rules_proto", - sha256 = "2490dca4f249b8a9a3ab07bd1ba6eca085aaf8e45a734af92aad0c42d9dc7aaf", - strip_prefix = "rules_proto-218ffa7dfa5408492dc86c01ee637614f8695c45", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz", - "https://github.com/bazelbuild/rules_proto/archive/218ffa7dfa5408492dc86c01ee637614f8695c45.tar.gz", - ], -) - -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") -rules_proto_dependencies() -rules_proto_toolchains() diff --git a/model/src/main/proto/preprocess_protos.bzl b/model/src/main/proto/preprocess_protos.bzl index f4947724677..397837a1c55 100644 --- a/model/src/main/proto/preprocess_protos.bzl +++ b/model/src/main/proto/preprocess_protos.bzl @@ -1,5 +1,9 @@ + def process(name, src): """ + Formats the import statement of the src file to contain a full path to the file + The genrule() rule generates a copy of the src file and alters the copy + The proto_library() rule takes this altered copy and builds it """ native.genrule( name = name, @@ -10,3 +14,8 @@ def process(name, src): ''' , ) + + native.proto_library( + name = name + "_lib", + srcs = ["processed_" + src] + ) \ No newline at end of file From 7d44fea677f3257d570219052a7b59b7f21a9465 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 11:04:22 -0400 Subject: [PATCH 007/106] Fixed typo in BUILD --- model/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index e0f0c0352d8..c1ac3a54b51 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -16,7 +16,7 @@ proto_library( data = [ ":process_exploration", ":process_question", - :process_topic", + ":process_topic", ], ) From 5c44743991cd38c52d6eb5e34055284a44dd5d53 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 11:18:31 -0400 Subject: [PATCH 008/106] Added missing end of file empty lines --- model/BUILD.bazel | 2 +- model/src/main/proto/preprocess_protos.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index c1ac3a54b51..1d3a592eaa8 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -33,4 +33,4 @@ process( process( name = "process_exploration", src = "exploration.proto" -) \ No newline at end of file +) diff --git a/model/src/main/proto/preprocess_protos.bzl b/model/src/main/proto/preprocess_protos.bzl index 397837a1c55..b7d2b6ac2b1 100644 --- a/model/src/main/proto/preprocess_protos.bzl +++ b/model/src/main/proto/preprocess_protos.bzl @@ -18,4 +18,4 @@ def process(name, src): native.proto_library( name = name + "_lib", srcs = ["processed_" + src] - ) \ No newline at end of file + ) From 020475462307c086782bd744e9a2a445991f9b3c Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 11:52:21 -0400 Subject: [PATCH 009/106] Added Robolectric dependencies and general build rule --- WORKSPACE | 31 ++++++++++++++++++++++++++++- utility/BUILD.bazel | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 utility/BUILD.bazel diff --git a/WORKSPACE b/WORKSPACE index 6d30a1861a1..280afa702ec 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,7 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") android_sdk_repository( name = "androidsdk", api_level = 28, - build_tools_version = "28.0.2", + #build_tools_version = "28.0.2", ) #Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external @@ -45,6 +45,35 @@ http_archive( ], ) +#Add support for Dagger +DAGGER_TAG = "2.28.1" +DAGGER_SHA = "9e69ab2f9a47e0f74e71fe49098bea908c528aa02fa0c5995334447b310d0cdd" +http_archive( + name = "dagger", + strip_prefix = "dagger-dagger-%s" % DAGGER_TAG, + sha256 = DAGGER_SHA, + urls = ["https://github.com/google/dagger/archive/dagger-%s.zip" % DAGGER_TAG], +) + +load("@rules_jvm_external//:defs.bzl", "maven_install") +load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") + +#Add support for Robolectric: http://robolectric.org/getting-started/ +http_archive( + name = "robolectric", + urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.0.1.tar.gz"], + strip_prefix = "robolectric-bazel-4.0.1", + sha256 = "dff7a1f8e7bd8dc737f20b6bbfaf78d8b5851debe6a074757f75041029f0c43b", +) +load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") +robolectric_repositories() + +maven_install( + artifacts = DAGGER_ARTIFACTS, + repositories = DAGGER_REPOSITORIES, +) + load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") rules_proto_dependencies() rules_proto_toolchains() + diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel new file mode 100644 index 00000000000..e29fea98578 --- /dev/null +++ b/utility/BUILD.bazel @@ -0,0 +1,48 @@ +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@dagger//:workspace_defs.bzl", "dagger_rules") + +package(default_visibility = ["//visibility:public"]) + +kt_android_library( + name = "dagger_graph", + custom_package = "org.oppia.util", + srcs = [ + "src/main/java/org/oppia/util/accessibility/*.kt", + "src/main/java/org/oppia/util/caching/*.kt", + "src/main/java/org/oppia/util/data/*.kt", + "src/main/java/org/oppia/util/datetime/*.kt", + "src/main/java/org/oppia/util/gcsresource/*.kt", + "src/main/java/org/oppia/util/logging/*.kt", + "src/main/java/org/oppia/util/networking/*.kt", + "src/main/java/org/oppia/util/parser/*.kt", + "src/main/java/org/oppia/util/profile/*.kt", + "src/main/java/org/oppia/util/system/*.kt", + "src/main/java/org/oppia/util/threading/*.kt", + "src/test/java/org/oppia/util/data/*.kt", + "src/test/java/org/oppia/util/datetime/*.kt", + "src/test/java/org/oppia/util/logging/*.kt", + "src/test/java/org/oppia/util/networking/*.kt", + "src/test/java/org/oppia/util/profile/*.kt", + "src/test/java/org/oppia/util/system/*.kt", + ], + deps = [ + ":dagger", + ], +) + +kt_android_library( + name = "utility_lib", + custom_package = "org.oppia.util", + srcs = [ + "src/main/java/org/oppia/util/extensions/*.kt", + "src/main/java/org/oppia/util/statusbar/*.kt", + ], + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger_graph", + ], +) + +dagger_rules() \ No newline at end of file From cb11a09969fdb37beb32a47a96cbe833248e2c54 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 12:17:04 -0400 Subject: [PATCH 010/106] Source files building in both systems - added a TODO for test files --- WORKSPACE | 20 +++++++++++++------- utility/BUILD.bazel | 27 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 280afa702ec..b1d0a3a2d29 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -58,19 +58,25 @@ http_archive( load("@rules_jvm_external//:defs.bzl", "maven_install") load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") -#Add support for Robolectric: http://robolectric.org/getting-started/ +#Add support for Robolectric: https://github.com/robolectric/robolectric-bazel http_archive( - name = "robolectric", - urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.0.1.tar.gz"], - strip_prefix = "robolectric-bazel-4.0.1", - sha256 = "dff7a1f8e7bd8dc737f20b6bbfaf78d8b5851debe6a074757f75041029f0c43b", + name = "robolectric", + urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.1.tar.gz"], + strip_prefix = "robolectric-bazel-4.1", ) load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") robolectric_repositories() maven_install( - artifacts = DAGGER_ARTIFACTS, - repositories = DAGGER_REPOSITORIES, + artifacts = DAGGER_ARTIFACTS + [ + "org.robolectric:robolectric:4.2", + "androidx.appcompat:appcompat:1.0.2", + "androidx.core:core-ktx:1.0.1", + ], + repositories = DAGGER_REPOSITORIES + [ + "https://maven.google.com", + "https://repo1.maven.org/maven2", + ], ) load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index e29fea98578..aea42ecd99f 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -19,12 +19,6 @@ kt_android_library( "src/main/java/org/oppia/util/profile/*.kt", "src/main/java/org/oppia/util/system/*.kt", "src/main/java/org/oppia/util/threading/*.kt", - "src/test/java/org/oppia/util/data/*.kt", - "src/test/java/org/oppia/util/datetime/*.kt", - "src/test/java/org/oppia/util/logging/*.kt", - "src/test/java/org/oppia/util/networking/*.kt", - "src/test/java/org/oppia/util/profile/*.kt", - "src/test/java/org/oppia/util/system/*.kt", ], deps = [ ":dagger", @@ -45,4 +39,25 @@ kt_android_library( ], ) +#TODO: Get android_local_test working with kotlin files +''' +android_local_test( + name = "utility_tests_lib", + srcs = [ + "src/test/java/org/oppia/util/data/*.kt", + "src/test/java/org/oppia/util/datetime/*.kt", + "src/test/java/org/oppia/util/logging/*.kt", + "src/test/java/org/oppia/util/networking/*.kt", + "src/test/java/org/oppia/util/profile/*.kt", + "src/test/java/org/oppia/util/system/*.kt", + ], + deps = [ + ":utility_lib", + #"@robolectric//bazel:robolectric", + "@maven//:org_robolectric_robolectric", + "@robolectric//bazel:android-all", + ], +) +''' + dagger_rules() \ No newline at end of file From a8b989fcb90de57365471cf69a1a95c3534fa262 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 12:26:14 -0400 Subject: [PATCH 011/106] Turned two kt_android_library rules into one --- utility/BUILD.bazel | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index aea42ecd99f..0d696872267 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -5,7 +5,7 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "dagger_graph", + name = "utility_lib", custom_package = "org.oppia.util", srcs = [ "src/main/java/org/oppia/util/accessibility/*.kt", @@ -19,26 +19,16 @@ kt_android_library( "src/main/java/org/oppia/util/profile/*.kt", "src/main/java/org/oppia/util/system/*.kt", "src/main/java/org/oppia/util/threading/*.kt", + "src/main/java/org/oppia/util/extensions/*.kt", + "src/main/java/org/oppia/util/statusbar/*.kt", ], + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", ], ) -kt_android_library( - name = "utility_lib", - custom_package = "org.oppia.util", - srcs = [ - "src/main/java/org/oppia/util/extensions/*.kt", - "src/main/java/org/oppia/util/statusbar/*.kt", - ], - resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger_graph", - ], -) - #TODO: Get android_local_test working with kotlin files ''' android_local_test( From ad2cb36ce418a507d6aabfd4228dd0e91e290d02 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 15:49:01 -0400 Subject: [PATCH 012/106] Added dependencies for test files --- WORKSPACE | 4 +++ utility/BUILD.bazel | 73 +++++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index b1d0a3a2d29..b35ae49e645 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -71,11 +71,15 @@ maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.2", "androidx.appcompat:appcompat:1.0.2", + "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", "androidx.core:core-ktx:1.0.1", + "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2",# + "junit:junit:4.12", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", "https://repo1.maven.org/maven2", + "https://jcenter.bintray.com/", ], ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 0d696872267..39a30114cb2 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -5,47 +5,50 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "utility_lib", - custom_package = "org.oppia.util", - srcs = [ - "src/main/java/org/oppia/util/accessibility/*.kt", - "src/main/java/org/oppia/util/caching/*.kt", - "src/main/java/org/oppia/util/data/*.kt", - "src/main/java/org/oppia/util/datetime/*.kt", - "src/main/java/org/oppia/util/gcsresource/*.kt", - "src/main/java/org/oppia/util/logging/*.kt", - "src/main/java/org/oppia/util/networking/*.kt", - "src/main/java/org/oppia/util/parser/*.kt", - "src/main/java/org/oppia/util/profile/*.kt", - "src/main/java/org/oppia/util/system/*.kt", - "src/main/java/org/oppia/util/threading/*.kt", - "src/main/java/org/oppia/util/extensions/*.kt", - "src/main/java/org/oppia/util/statusbar/*.kt", - ], - resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - ], + name = "utility_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/**/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], ) #TODO: Get android_local_test working with kotlin files ''' +kt_android_library( + name = "test_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/test/**/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + ":utility_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + #artifact("androidx.appcompat:appcompat:1.0.2"), + ], +) + + android_local_test( - name = "utility_tests_lib", - srcs = [ - "src/test/java/org/oppia/util/data/*.kt", - "src/test/java/org/oppia/util/datetime/*.kt", - "src/test/java/org/oppia/util/logging/*.kt", - "src/test/java/org/oppia/util/networking/*.kt", - "src/test/java/org/oppia/util/profile/*.kt", - "src/test/java/org/oppia/util/system/*.kt", - ], + name = "all_tests", + custom_package = "org.oppia.util", + test_class = "org.oppia.util", deps = [ - ":utility_lib", - #"@robolectric//bazel:robolectric", - "@maven//:org_robolectric_robolectric", - "@robolectric//bazel:android-all", + ":dagger", + ":test_lib", + "@robolectric//bazel:android-all", + artifact("org.robolectric:robolectric"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("junit:junit"), ], ) ''' From 379990ebbbbdc0aa59fe719817c6aa960b5fbbb7 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 15:59:08 -0400 Subject: [PATCH 013/106] Created kt_android_library rule for source files --- testing/BUILD.bazel | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 testing/BUILD.bazel diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel new file mode 100644 index 00000000000..eaa9858a783 --- /dev/null +++ b/testing/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@dagger//:workspace_defs.bzl", "dagger_rules") + +package(default_visibility = ["//visibility:public"]) + +kt_android_library( + name = "testing_lib", + custom_package = "org.oppia.testing", + srcs = glob(["src/main/java/**/*.kt"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], +) + +dagger_rules() \ No newline at end of file From 6d9f24443888a980d7a37ef906ab4065891d7d98 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 16:10:40 -0400 Subject: [PATCH 014/106] Add TODO for android_local_test rule --- testing/BUILD.bazel | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index eaa9858a783..450eca14424 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -5,16 +5,31 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "testing_lib", - custom_package = "org.oppia.testing", - srcs = glob(["src/main/java/**/*.kt"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("androidx.appcompat:appcompat:1.0.2"), - ], + name = "testing_main_lib", + custom_package = "org.oppia.testing", + srcs = glob(["src/main/java/**/*.kt"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], + ) + +kt_android_library( + name = "testing_test_lib", + custom_package = "org.oppia.testing", + srcs = glob(["src/test/java/**/*.kt"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], ) +#TODO: Add android_local_test rule + dagger_rules() \ No newline at end of file From c45c72ec477b2d0cbfde2416094218ed4b5e5537 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 16:59:01 -0400 Subject: [PATCH 015/106] Added a test manifest for android_local_test() --- utility/src/test/TestManifest.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 utility/src/test/TestManifest.xml diff --git a/utility/src/test/TestManifest.xml b/utility/src/test/TestManifest.xml new file mode 100644 index 00000000000..2b65e5417cc --- /dev/null +++ b/utility/src/test/TestManifest.xml @@ -0,0 +1,6 @@ + + + + From 04d2281cf4eb709dbc21cdd190ce1cde1e852011 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 16:59:39 -0400 Subject: [PATCH 016/106] Added Firebase dependencies and git_repository for tools_android --- WORKSPACE | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index b35ae49e645..11f31bd3062 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,6 @@ 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("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") android_sdk_repository( name = "androidsdk", @@ -67,6 +68,15 @@ http_archive( load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") robolectric_repositories() +#Add support for Firebase Crashlytics +git_repository( + name = "tools_android", + commit = "00e6f4b7bdd75911e33c618a9bc57bab7a6e8930", + remote = "https://github.com/bazelbuild/tools_android" +) +load("@tools_android//tools/googleservices:defs.bzl", "google_services_workspace_dependencies") +google_services_workspace_dependencies() + maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.2", @@ -75,11 +85,19 @@ maven_install( "androidx.core:core-ktx:1.0.1", "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2",# "junit:junit:4.12", + "com.github.bumptech.glide:glide:4.11.0", + "com.github.bumptech.glide:compiler:4.11.0", + "com.caverock:androidsvg-aar:1.4", + "com.crashlytics.sdk.android:crashlytics:2.9.8", + "io.fabric.sdk.android:fabric:1.4.7", + "com.google.gms:google-services:4.3.3", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", "https://repo1.maven.org/maven2", "https://jcenter.bintray.com/", + "https://bintray.com/bintray/jcenter", + "https://maven.fabric.io/public", ], ) From f48602467b077bdba32af501791463579a4eb871 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 20 Jul 2020 11:51:15 -0400 Subject: [PATCH 017/106] Refactored google-services.json, imported new dependencies --- WORKSPACE | 8 +++++- firebase/BUILD.bazel | 26 ++++++++++++++++++++ {app => firebase}/google-services.json | 0 model/BUILD.bazel | 2 ++ utility/BUILD.bazel | 34 +++++++++++++++----------- utility/src/main/AndroidManifest.xml | 4 ++- utility/src/test/TestManifest.xml | 2 +- 7 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 firebase/BUILD.bazel rename {app => firebase}/google-services.json (100%) diff --git a/WORKSPACE b/WORKSPACE index 11f31bd3062..0afbf03a757 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -69,21 +69,25 @@ load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") robolectric_repositories() #Add support for Firebase Crashlytics + git_repository( name = "tools_android", commit = "00e6f4b7bdd75911e33c618a9bc57bab7a6e8930", remote = "https://github.com/bazelbuild/tools_android" ) + load("@tools_android//tools/googleservices:defs.bzl", "google_services_workspace_dependencies") google_services_workspace_dependencies() +#TODO: Remove unused dependencies once android_local_test errors are resolved maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.2", "androidx.appcompat:appcompat:1.0.2", + "com.android.support:support-annotations:28.0.0", "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", "androidx.core:core-ktx:1.0.1", - "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2",# + "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", "junit:junit:4.12", "com.github.bumptech.glide:glide:4.11.0", "com.github.bumptech.glide:compiler:4.11.0", @@ -91,6 +95,8 @@ maven_install( "com.crashlytics.sdk.android:crashlytics:2.9.8", "io.fabric.sdk.android:fabric:1.4.7", "com.google.gms:google-services:4.3.3", + "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03", + "com.google.firebase:firebase-analytics-ktx:17.4.2", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", diff --git a/firebase/BUILD.bazel b/firebase/BUILD.bazel new file mode 100644 index 00000000000..4f55531ff56 --- /dev/null +++ b/firebase/BUILD.bazel @@ -0,0 +1,26 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("@tools_android//tools/crashlytics:defs.bzl", "crashlytics_android_library") +load("@tools_android//tools/googleservices:defs.bzl", "google_services_xml") + +package(default_visibility = ["//visibility:public"]) + +GOOGLE_SERVICES_RESOURCES = google_services_xml( + package_name = "org.oppia.app", + google_services_json = "google-services.json", +) + +crashlytics_android_library( + name = "crashlytics_lib", + package_name = "org.oppia.app", + build_id = "48fc9d17-e102-444c-8e0d-638d75ec0942", + resource_files = GOOGLE_SERVICES_RESOURCES, +) + +android_library( + name = "crashlytics_deps", + exports = [ + artifact("com.crashlytics.sdk.android:crashlytics"), + artifact("io.fabric.sdk.android:fabric"), + ], +) \ No newline at end of file diff --git a/app/google-services.json b/firebase/google-services.json similarity index 100% rename from app/google-services.json rename to firebase/google-services.json diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 1d3a592eaa8..f1e60f88b49 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,6 +1,8 @@ load("@rules_proto//proto:defs.bzl", "proto_library") load("//model:src/main/proto/preprocess_protos.bzl", "process") +package(default_visibility = ["//visibility:public"]) + proto_library( name = "proto_lib", srcs = ["src/main/proto/event_logger.proto", diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 39a30114cb2..e1365fa8c34 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -12,45 +12,51 @@ kt_android_library( manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", + "//firebase:crashlytics_lib", + "//firebase:crashlytics_deps", + artifact("androidx.appcompat:appcompat"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("androidx.appcompat:appcompat:1.0.2"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), ], ) #TODO: Get android_local_test working with kotlin files -''' + kt_android_library( name = "test_lib", custom_package = "org.oppia.util", - srcs = glob(["src/test/**/*.kt"]), + srcs = glob(["src/test/**/*.kt", "src/test/**/**/*.kt"]), resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), - manifest = "src/main/AndroidManifest.xml", + manifest = "src/test/TestManifest.xml", deps = [ - ":dagger", ":utility_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - #artifact("androidx.appcompat:appcompat:1.0.2"), ], ) - +''' android_local_test( name = "all_tests", custom_package = "org.oppia.util", test_class = "org.oppia.util", + manifest = "src/test/TestManifest.xml", deps = [ - ":dagger", ":test_lib", "@robolectric//bazel:android-all", artifact("org.robolectric:robolectric"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("junit:junit"), ], + ) ''' -dagger_rules() \ No newline at end of file +dagger_rules() diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index 5a2a48aa161..a4f801202ae 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1 +1,3 @@ - + + + \ No newline at end of file diff --git a/utility/src/test/TestManifest.xml b/utility/src/test/TestManifest.xml index 2b65e5417cc..ac7679afad9 100644 --- a/utility/src/test/TestManifest.xml +++ b/utility/src/test/TestManifest.xml @@ -1,6 +1,6 @@ - From fa16eb44af9ffc29a175d9272fc190e6e577ac2d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 20 Jul 2020 12:04:59 -0400 Subject: [PATCH 018/106] Fixed Bens nits --- model/BUILD.bazel | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 1d3a592eaa8..82f0b3f7e77 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -3,20 +3,21 @@ load("//model:src/main/proto/preprocess_protos.bzl", "process") proto_library( name = "proto_lib", - srcs = ["src/main/proto/event_logger.proto", - "src/main/proto/example.proto", - "src/main/proto/interaction_object.proto", - "src/main/proto/onboarding.proto", - "src/main/proto/profile.proto", - "src/main/proto/subtitled_html.proto", - "src/main/proto/thumbnail.proto", - "src/main/proto/translation.proto", - "src/main/proto/voiceover.proto", + srcs = [ + "src/main/proto/event_logger.proto", + "src/main/proto/example.proto", + "src/main/proto/interaction_object.proto", + "src/main/proto/onboarding.proto", + "src/main/proto/profile.proto", + "src/main/proto/subtitled_html.proto", + "src/main/proto/thumbnail.proto", + "src/main/proto/translation.proto", + "src/main/proto/voiceover.proto", ], data = [ - ":process_exploration", - ":process_question", - ":process_topic", + ":process_exploration", + ":process_question", + ":process_topic", ], ) From 5d31b5c1efc8acd1d51b129d456bbe497e7d9565 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 20 Jul 2020 15:55:33 -0400 Subject: [PATCH 019/106] Fixed space in WORKSPACE comment --- WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 6d30a1861a1..77796b211c0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -7,7 +7,7 @@ android_sdk_repository( build_tools_version = "28.0.2", ) -#Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external +# Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external RULES_JVM_EXTERNAL_TAG = "2.9" RULES_JVM_EXTERNAL_SHA = "e5b97a31a3e8feed91636f42e19b11c49487b85e5de2f387c999ea14d77c7f45" http_archive( From 3f9ed6576695a6a973a3cdfc8080b9e21bcc805d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 10:29:35 -0400 Subject: [PATCH 020/106] Got a demo test working in both Java and Kotlin --- WORKSPACE | 12 +- testing/BUILD.bazel | 22 ++++ utility/BUILD.bazel | 112 +++++++++++++++++- .../org/oppia/util/data/DemoJavaTest.java | 20 ++++ 4 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 testing/BUILD.bazel create mode 100644 utility/src/test/java/org/oppia/util/data/DemoJavaTest.java diff --git a/WORKSPACE b/WORKSPACE index 0afbf03a757..a5082789d64 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -62,8 +62,8 @@ load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") #Add support for Robolectric: https://github.com/robolectric/robolectric-bazel http_archive( name = "robolectric", - urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.1.tar.gz"], - strip_prefix = "robolectric-bazel-4.1", + urls = ["https://github.com/oppia/robolectric-bazel/archive/4.x-oppia-exclusive-rc02.tar.gz"], + strip_prefix = "robolectric-bazel-4.x-oppia-exclusive-rc02", ) load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") robolectric_repositories() @@ -82,13 +82,14 @@ google_services_workspace_dependencies() #TODO: Remove unused dependencies once android_local_test errors are resolved maven_install( artifacts = DAGGER_ARTIFACTS + [ - "org.robolectric:robolectric:4.2", + "org.robolectric:robolectric:4.3", "androidx.appcompat:appcompat:1.0.2", "com.android.support:support-annotations:28.0.0", "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", "androidx.core:core-ktx:1.0.1", "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", "junit:junit:4.12", + "com.google.truth:truth:0.43", "com.github.bumptech.glide:glide:4.11.0", "com.github.bumptech.glide:compiler:4.11.0", "com.caverock:androidsvg-aar:1.4", @@ -97,6 +98,11 @@ maven_install( "com.google.gms:google-services:4.3.3", "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03", "com.google.firebase:firebase-analytics-ktx:17.4.2", + "org.mockito:mockito-core:2.19.0", + "androidx.test.ext:junit:1.1.1", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", + "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", + "org.robolectric:annotations:4.3", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel new file mode 100644 index 00000000000..d85cdf85678 --- /dev/null +++ b/testing/BUILD.bazel @@ -0,0 +1,22 @@ +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@dagger//:workspace_defs.bzl", "dagger_rules") + +package(default_visibility = ["//visibility:public"]) + +kt_android_library( + name = "testing_main_lib", + custom_package = "org.oppia.testing", + srcs = glob(["src/main/java/**/FakeSystemClock.kt"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "@robolectric//bazel:android-all", + artifact("org.robolectric:robolectric"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], + ) + +dagger_rules() \ No newline at end of file diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index e1365fa8c34..1f2755ebb8a 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -8,12 +8,13 @@ kt_android_library( name = "utility_lib", custom_package = "org.oppia.util", srcs = glob(["src/main/**/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", "//firebase:crashlytics_lib", "//firebase:crashlytics_deps", + artifact("com.google.truth:truth"), artifact("androidx.appcompat:appcompat"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), @@ -27,11 +28,116 @@ kt_android_library( artifact("io.fabric.sdk.android:fabric:1.4.7"), artifact("com.google.gms:google-services:4.3.3"), artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), ], ) -#TODO: Get android_local_test working with kotlin files +kt_android_library( + name = "async", + custom_package = "org.oppia.util", + srcs = ["src/main/java/org/oppia/util/data/AsyncResult.kt"], + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//testing:testing_main_lib", + artifact("com.google.truth:truth"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("org.mockito:mockito-core:2.19.0"), + artifact("androidx.test.ext:junit"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.appcompat:appcompat"), + artifact("androidx.core:core-ktx"), + artifact("junit:junit"), + artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), + ], +) + +kt_android_library( + name = "async_test_lib", + custom_package = "org.oppia.util", + srcs = ["src/test/java/org/oppia/util/data/AsyncResultTest.kt"], + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/test/TestManifest.xml", + deps = [ + ":async", + ":dagger", +# "//testing:testing_main_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), +# artifact("com.google.truth:truth"), +# artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), +# artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + #artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), +# artifact("androidx.lifecycle:lifecycle-livedata-ktx"), +# artifact("io.fabric.sdk.android:fabric:1.4.7"), +# artifact("org.mockito:mockito-core:2.19.0"), +# artifact("androidx.test.ext:junit"), +# artifact("com.github.bumptech.glide:glide"), +# artifact("com.github.bumptech.glide:compiler"), +# artifact("com.caverock:androidsvg-aar"), +# artifact("androidx.appcompat:appcompat"), +# artifact("androidx.core:core-ktx"), +# artifact("junit:junit"), +# artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), + ], +) +android_local_test( + name = "async_tests", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.data.AsyncResultTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":async_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + artifact("com.google.truth:truth"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("org.mockito:mockito-core:2.19.0"), + artifact("androidx.test.ext:junit"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.appcompat:appcompat"), + artifact("androidx.core:core-ktx"), + artifact("junit:junit"), + artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), + ], + +) + +android_local_test( + name = "demo_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.data.DemoJavaTest", + srcs = ["src/test/java/org/oppia/util/data/DemoJavaTest.java"], + manifest = "src/test/TestManifest.xml", + deps = [ + #":async_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + artifact("com.google.truth:truth"), + artifact("junit:junit"), + artifact("org.robolectric:annotations:4.3"), + artifact("androidx.test.ext:junit"), + ], +) + +#TODO: Get android_local_test working with kotlin files +''' kt_android_library( name = "test_lib", custom_package = "org.oppia.util", @@ -42,7 +148,7 @@ kt_android_library( ":utility_lib", ], ) - +''' ''' android_local_test( name = "all_tests", diff --git a/utility/src/test/java/org/oppia/util/data/DemoJavaTest.java b/utility/src/test/java/org/oppia/util/data/DemoJavaTest.java new file mode 100644 index 00000000000..34317a2ccac --- /dev/null +++ b/utility/src/test/java/org/oppia/util/data/DemoJavaTest.java @@ -0,0 +1,20 @@ +package org.oppia.util.data; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.annotation.LooperMode; + +import static com.google.common.truth.Truth.assertThat; + +@RunWith(AndroidJUnit4.class) +@LooperMode(LooperMode.Mode.PAUSED) +public class DemoJavaTest { + + @Test + public void testIsTrue() { + boolean result = true; + assertThat(result).isTrue(); + } + +} From 1c982a9767e84e3a83fc39c6f33e893ecdeec292 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 10:35:36 -0400 Subject: [PATCH 021/106] Added rules_java dependencies for protocol buffers --- WORKSPACE | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index 77796b211c0..2001c25703e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -48,3 +48,18 @@ http_archive( load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") rules_proto_dependencies() rules_proto_toolchains() + +# rules_java defines rules for generating Java code from Protocol Buffers. +http_archive( + name = "rules_java", + sha256 = "ccf00372878d141f7d5568cedc4c42ad4811ba367ea3e26bc7c43445bbc52895", + strip_prefix = "rules_java-d7bf804c8731edd232cb061cb2a9fe003a85d8ee", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_java/archive/d7bf804c8731edd232cb061cb2a9fe003a85d8ee.tar.gz", + "https://github.com/bazelbuild/rules_java/archive/d7bf804c8731edd232cb061cb2a9fe003a85d8ee.tar.gz", + ], +) + +load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") +rules_java_dependencies() +rules_java_toolchains() From a7346e14b620ec8cdaef70c89d9600e90e31ca66 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 11:38:35 -0400 Subject: [PATCH 022/106] Added java_proto_library rules, each proto file now has its own rule --- model/BUILD.bazel | 132 +++++++++++++++++---- model/src/main/proto/preprocess_protos.bzl | 5 + 2 files changed, 117 insertions(+), 20 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 82f0b3f7e77..95011373dd8 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,37 +1,129 @@ load("@rules_proto//proto:defs.bzl", "proto_library") +load("@rules_java//java:defs.bzl", "java_proto_library") load("//model:src/main/proto/preprocess_protos.bzl", "process") proto_library( - name = "proto_lib", - srcs = [ - "src/main/proto/event_logger.proto", - "src/main/proto/example.proto", - "src/main/proto/interaction_object.proto", - "src/main/proto/onboarding.proto", - "src/main/proto/profile.proto", - "src/main/proto/subtitled_html.proto", - "src/main/proto/thumbnail.proto", - "src/main/proto/translation.proto", - "src/main/proto/voiceover.proto", - ], - data = [ - ":process_exploration", - ":process_question", - ":process_topic", - ], + name = "event_logger_proto", + srcs = ["src/main/proto/event_logger.proto"], +) + +java_proto_library( + name = "event_logger_java_proto", + deps = [":event_logger_proto"], +) + +proto_library( + name = "example_proto", + srcs = ["src/main/proto/example.proto"], +) + +java_proto_library( + name = "example_java_proto", + deps = [":example_proto"], +) + +proto_library( + name = "interaction_object_proto", + srcs = ["src/main/proto/interaction_object.proto"], +) + +java_proto_library( + name = "interaction_object_java_proto", + deps = [":interaction_object_proto"], +) + +proto_library( + name = "onboarding_proto", + srcs = ["src/main/proto/onboarding.proto"], +) + +java_proto_library( + name = "onboarding_java_proto", + deps = [":onboarding_proto"], +) + +proto_library( + name = "profile_proto", + srcs = ["src/main/proto/profile.proto"], +) + +java_proto_library( + name = "profile_java_proto", + deps = [":profile_proto"], +) + +proto_library( + name = "subtitled_html_proto", + srcs = ["src/main/proto/subtitled_html.proto"], +) + +java_proto_library( + name = "subtitled_html_java_proto", + deps = [":subtitled_html_proto"], +) + +proto_library( + name = "thumbnail_proto", + srcs = ["src/main/proto/thumbnail.proto"], +) + +java_proto_library( + name = "thumbnail_java_proto", + deps = [":thumbnail_proto"], +) + +proto_library( + name = "translation_proto", + srcs = ["src/main/proto/translation.proto"], +) + +java_proto_library( + name = "translation_java_proto", + deps = [":translation_proto"], +) + +proto_library( + name = "voiceover_proto", + srcs = ["src/main/proto/voiceover.proto"], +) + +java_proto_library( + name = "voiceover_java_proto", + deps = [":voiceover_proto"], ) process( name = "process_topic", - src = "topic.proto" + src = "src/main/proto/topic.proto" ) process( name = "process_question", - src = "question.proto" + src = "src/main/proto/question.proto" ) process( name = "process_exploration", - src = "exploration.proto" + src = "src/main/proto/exploration.proto" +) + +android_library( + name = "model_lib", + srcs = [ + + ], + data = [ + ":event_logger_java_proto", + ":example_java_proto", + ":interaction_object_java_proto", + ":onboarding_java_proto", + ":profile_java_proto", + ":subtitled_html_java_proto", + ":thumbnail_java_proto", + ":translation_java_proto", + ":voiceover_java_proto", + ":process_exploration", + ":process_question", + ":process_topic", + ], ) diff --git a/model/src/main/proto/preprocess_protos.bzl b/model/src/main/proto/preprocess_protos.bzl index b7d2b6ac2b1..7321a50ea61 100644 --- a/model/src/main/proto/preprocess_protos.bzl +++ b/model/src/main/proto/preprocess_protos.bzl @@ -19,3 +19,8 @@ def process(name, src): name = name + "_lib", srcs = ["processed_" + src] ) + + native.java_proto_library( + name = name + "_java_lib", + deps = [name + "_lib"] + ) From 6fc021ba75dfc02d2dc8d88d4a1c89eab4fb76eb Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 11:42:00 -0400 Subject: [PATCH 023/106] Remove unnecessary srcs attribute for android_library --- model/BUILD.bazel | 3 --- 1 file changed, 3 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 95011373dd8..8a9a969b939 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -109,9 +109,6 @@ process( android_library( name = "model_lib", - srcs = [ - - ], data = [ ":event_logger_java_proto", ":example_java_proto", From b3d55e872424e7e09ba929e14fd6c4918df63057 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 11:45:01 -0400 Subject: [PATCH 024/106] Rename bzl file macro --- model/BUILD.bazel | 20 +++++++++---------- ...os.bzl => format_import_proto_library.bzl} | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) rename model/src/main/proto/{preprocess_protos.bzl => format_import_proto_library.bzl} (93%) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 8a9a969b939..a9f091934ed 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,6 +1,6 @@ load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") -load("//model:src/main/proto/preprocess_protos.bzl", "process") +load("//model:src/main/proto/format_import_proto_library.bzl", "format_import_proto_library") proto_library( name = "event_logger_proto", @@ -92,18 +92,18 @@ java_proto_library( deps = [":voiceover_proto"], ) -process( - name = "process_topic", +format_import_proto_library( + name = "topic_proto", src = "src/main/proto/topic.proto" ) -process( - name = "process_question", +format_import_proto_library( + name = "question_proto", src = "src/main/proto/question.proto" ) -process( - name = "process_exploration", +format_import_proto_library( + name = "exploration_proto", src = "src/main/proto/exploration.proto" ) @@ -119,8 +119,8 @@ android_library( ":thumbnail_java_proto", ":translation_java_proto", ":voiceover_java_proto", - ":process_exploration", - ":process_question", - ":process_topic", + ":exploration_proto", + ":question_proto", + ":topic_proto", ], ) diff --git a/model/src/main/proto/preprocess_protos.bzl b/model/src/main/proto/format_import_proto_library.bzl similarity index 93% rename from model/src/main/proto/preprocess_protos.bzl rename to model/src/main/proto/format_import_proto_library.bzl index 7321a50ea61..30379a5026f 100644 --- a/model/src/main/proto/preprocess_protos.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -1,5 +1,5 @@ -def process(name, src): +def format_import_proto_library(name, src): """ Formats the import statement of the src file to contain a full path to the file The genrule() rule generates a copy of the src file and alters the copy From 7030c839b08f5f8d2db67385878525b62849298b Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 11:52:21 -0400 Subject: [PATCH 025/106] Added Robolectric dependencies and general build rule --- WORKSPACE | 31 ++++++++++++++++++++++++++++- utility/BUILD.bazel | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 utility/BUILD.bazel diff --git a/WORKSPACE b/WORKSPACE index 2001c25703e..f4c5f5df268 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,7 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") android_sdk_repository( name = "androidsdk", api_level = 28, - build_tools_version = "28.0.2", + #build_tools_version = "28.0.2", ) # Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external @@ -63,3 +63,32 @@ http_archive( load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") rules_java_dependencies() rules_java_toolchains() + +#Add support for Dagger +DAGGER_TAG = "2.28.1" +DAGGER_SHA = "9e69ab2f9a47e0f74e71fe49098bea908c528aa02fa0c5995334447b310d0cdd" +http_archive( + name = "dagger", + strip_prefix = "dagger-dagger-%s" % DAGGER_TAG, + sha256 = DAGGER_SHA, + urls = ["https://github.com/google/dagger/archive/dagger-%s.zip" % DAGGER_TAG], +) + +load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") + +#Add support for Robolectric: http://robolectric.org/getting-started/ +http_archive( + name = "robolectric", + urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.0.1.tar.gz"], + strip_prefix = "robolectric-bazel-4.0.1", + sha256 = "dff7a1f8e7bd8dc737f20b6bbfaf78d8b5851debe6a074757f75041029f0c43b", +) +load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") +robolectric_repositories() + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +maven_install( + artifacts = DAGGER_ARTIFACTS, + repositories = DAGGER_REPOSITORIES, +) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel new file mode 100644 index 00000000000..e29fea98578 --- /dev/null +++ b/utility/BUILD.bazel @@ -0,0 +1,48 @@ +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@dagger//:workspace_defs.bzl", "dagger_rules") + +package(default_visibility = ["//visibility:public"]) + +kt_android_library( + name = "dagger_graph", + custom_package = "org.oppia.util", + srcs = [ + "src/main/java/org/oppia/util/accessibility/*.kt", + "src/main/java/org/oppia/util/caching/*.kt", + "src/main/java/org/oppia/util/data/*.kt", + "src/main/java/org/oppia/util/datetime/*.kt", + "src/main/java/org/oppia/util/gcsresource/*.kt", + "src/main/java/org/oppia/util/logging/*.kt", + "src/main/java/org/oppia/util/networking/*.kt", + "src/main/java/org/oppia/util/parser/*.kt", + "src/main/java/org/oppia/util/profile/*.kt", + "src/main/java/org/oppia/util/system/*.kt", + "src/main/java/org/oppia/util/threading/*.kt", + "src/test/java/org/oppia/util/data/*.kt", + "src/test/java/org/oppia/util/datetime/*.kt", + "src/test/java/org/oppia/util/logging/*.kt", + "src/test/java/org/oppia/util/networking/*.kt", + "src/test/java/org/oppia/util/profile/*.kt", + "src/test/java/org/oppia/util/system/*.kt", + ], + deps = [ + ":dagger", + ], +) + +kt_android_library( + name = "utility_lib", + custom_package = "org.oppia.util", + srcs = [ + "src/main/java/org/oppia/util/extensions/*.kt", + "src/main/java/org/oppia/util/statusbar/*.kt", + ], + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger_graph", + ], +) + +dagger_rules() \ No newline at end of file From 7c35ecff0a48dd6a7245dcca6eaf1dca9498ccbf Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 12:17:04 -0400 Subject: [PATCH 026/106] Source files building in both systems - added a TODO for test files --- WORKSPACE | 20 +++++++++++++------- utility/BUILD.bazel | 27 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index f4c5f5df268..05b21a27105 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -76,12 +76,11 @@ http_archive( load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") -#Add support for Robolectric: http://robolectric.org/getting-started/ +#Add support for Robolectric: https://github.com/robolectric/robolectric-bazel http_archive( - name = "robolectric", - urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.0.1.tar.gz"], - strip_prefix = "robolectric-bazel-4.0.1", - sha256 = "dff7a1f8e7bd8dc737f20b6bbfaf78d8b5851debe6a074757f75041029f0c43b", + name = "robolectric", + urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.1.tar.gz"], + strip_prefix = "robolectric-bazel-4.1", ) load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") robolectric_repositories() @@ -89,6 +88,13 @@ robolectric_repositories() load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( - artifacts = DAGGER_ARTIFACTS, - repositories = DAGGER_REPOSITORIES, + artifacts = DAGGER_ARTIFACTS + [ + "org.robolectric:robolectric:4.2", + "androidx.appcompat:appcompat:1.0.2", + "androidx.core:core-ktx:1.0.1", + ], + repositories = DAGGER_REPOSITORIES + [ + "https://maven.google.com", + "https://repo1.maven.org/maven2", + ], ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index e29fea98578..aea42ecd99f 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -19,12 +19,6 @@ kt_android_library( "src/main/java/org/oppia/util/profile/*.kt", "src/main/java/org/oppia/util/system/*.kt", "src/main/java/org/oppia/util/threading/*.kt", - "src/test/java/org/oppia/util/data/*.kt", - "src/test/java/org/oppia/util/datetime/*.kt", - "src/test/java/org/oppia/util/logging/*.kt", - "src/test/java/org/oppia/util/networking/*.kt", - "src/test/java/org/oppia/util/profile/*.kt", - "src/test/java/org/oppia/util/system/*.kt", ], deps = [ ":dagger", @@ -45,4 +39,25 @@ kt_android_library( ], ) +#TODO: Get android_local_test working with kotlin files +''' +android_local_test( + name = "utility_tests_lib", + srcs = [ + "src/test/java/org/oppia/util/data/*.kt", + "src/test/java/org/oppia/util/datetime/*.kt", + "src/test/java/org/oppia/util/logging/*.kt", + "src/test/java/org/oppia/util/networking/*.kt", + "src/test/java/org/oppia/util/profile/*.kt", + "src/test/java/org/oppia/util/system/*.kt", + ], + deps = [ + ":utility_lib", + #"@robolectric//bazel:robolectric", + "@maven//:org_robolectric_robolectric", + "@robolectric//bazel:android-all", + ], +) +''' + dagger_rules() \ No newline at end of file From dfd545ad8a819b643d666c2c0445e47e14767d37 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 12:26:14 -0400 Subject: [PATCH 027/106] Turned two kt_android_library rules into one --- utility/BUILD.bazel | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index aea42ecd99f..0d696872267 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -5,7 +5,7 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "dagger_graph", + name = "utility_lib", custom_package = "org.oppia.util", srcs = [ "src/main/java/org/oppia/util/accessibility/*.kt", @@ -19,26 +19,16 @@ kt_android_library( "src/main/java/org/oppia/util/profile/*.kt", "src/main/java/org/oppia/util/system/*.kt", "src/main/java/org/oppia/util/threading/*.kt", + "src/main/java/org/oppia/util/extensions/*.kt", + "src/main/java/org/oppia/util/statusbar/*.kt", ], + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", ], ) -kt_android_library( - name = "utility_lib", - custom_package = "org.oppia.util", - srcs = [ - "src/main/java/org/oppia/util/extensions/*.kt", - "src/main/java/org/oppia/util/statusbar/*.kt", - ], - resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger_graph", - ], -) - #TODO: Get android_local_test working with kotlin files ''' android_local_test( From 866a00a9de50948afb51c2d15f6c5a8501a07e23 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 15:49:01 -0400 Subject: [PATCH 028/106] Added dependencies for test files --- WORKSPACE | 4 +++ utility/BUILD.bazel | 73 +++++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 05b21a27105..2a0c4817a5d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -91,10 +91,14 @@ maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.2", "androidx.appcompat:appcompat:1.0.2", + "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", "androidx.core:core-ktx:1.0.1", + "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2",# + "junit:junit:4.12", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", "https://repo1.maven.org/maven2", + "https://jcenter.bintray.com/", ], ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 0d696872267..39a30114cb2 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -5,47 +5,50 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "utility_lib", - custom_package = "org.oppia.util", - srcs = [ - "src/main/java/org/oppia/util/accessibility/*.kt", - "src/main/java/org/oppia/util/caching/*.kt", - "src/main/java/org/oppia/util/data/*.kt", - "src/main/java/org/oppia/util/datetime/*.kt", - "src/main/java/org/oppia/util/gcsresource/*.kt", - "src/main/java/org/oppia/util/logging/*.kt", - "src/main/java/org/oppia/util/networking/*.kt", - "src/main/java/org/oppia/util/parser/*.kt", - "src/main/java/org/oppia/util/profile/*.kt", - "src/main/java/org/oppia/util/system/*.kt", - "src/main/java/org/oppia/util/threading/*.kt", - "src/main/java/org/oppia/util/extensions/*.kt", - "src/main/java/org/oppia/util/statusbar/*.kt", - ], - resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - ], + name = "utility_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/**/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], ) #TODO: Get android_local_test working with kotlin files ''' +kt_android_library( + name = "test_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/test/**/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + ":utility_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + #artifact("androidx.appcompat:appcompat:1.0.2"), + ], +) + + android_local_test( - name = "utility_tests_lib", - srcs = [ - "src/test/java/org/oppia/util/data/*.kt", - "src/test/java/org/oppia/util/datetime/*.kt", - "src/test/java/org/oppia/util/logging/*.kt", - "src/test/java/org/oppia/util/networking/*.kt", - "src/test/java/org/oppia/util/profile/*.kt", - "src/test/java/org/oppia/util/system/*.kt", - ], + name = "all_tests", + custom_package = "org.oppia.util", + test_class = "org.oppia.util", deps = [ - ":utility_lib", - #"@robolectric//bazel:robolectric", - "@maven//:org_robolectric_robolectric", - "@robolectric//bazel:android-all", + ":dagger", + ":test_lib", + "@robolectric//bazel:android-all", + artifact("org.robolectric:robolectric"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("junit:junit"), ], ) ''' From c0a791aa58a042141508d8c710dd106a2389d9a6 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 15:59:08 -0400 Subject: [PATCH 029/106] Created kt_android_library rule for source files --- testing/BUILD.bazel | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 testing/BUILD.bazel diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel new file mode 100644 index 00000000000..eaa9858a783 --- /dev/null +++ b/testing/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@dagger//:workspace_defs.bzl", "dagger_rules") + +package(default_visibility = ["//visibility:public"]) + +kt_android_library( + name = "testing_lib", + custom_package = "org.oppia.testing", + srcs = glob(["src/main/java/**/*.kt"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], +) + +dagger_rules() \ No newline at end of file From 69751699bafd38850a52834b77515fbc95471e95 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 17 Jul 2020 16:10:40 -0400 Subject: [PATCH 030/106] Add TODO for android_local_test rule --- testing/BUILD.bazel | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index eaa9858a783..450eca14424 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -5,16 +5,31 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "testing_lib", - custom_package = "org.oppia.testing", - srcs = glob(["src/main/java/**/*.kt"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("androidx.appcompat:appcompat:1.0.2"), - ], + name = "testing_main_lib", + custom_package = "org.oppia.testing", + srcs = glob(["src/main/java/**/*.kt"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], + ) + +kt_android_library( + name = "testing_test_lib", + custom_package = "org.oppia.testing", + srcs = glob(["src/test/java/**/*.kt"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("androidx.appcompat:appcompat:1.0.2"), + ], ) +#TODO: Add android_local_test rule + dagger_rules() \ No newline at end of file From e16ee96b4460badfff25efbe8d63a7d10ee74095 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 12:22:32 -0400 Subject: [PATCH 031/106] Changed model visability, added model and util dependencies to testing --- model/BUILD.bazel | 1 + testing/BUILD.bazel | 2 ++ 2 files changed, 3 insertions(+) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index a9f091934ed..8ab04b7bf49 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -123,4 +123,5 @@ android_library( ":question_proto", ":topic_proto", ], + visibility = ["//visibility:public"], ) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 450eca14424..20bb11e276f 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -11,6 +11,8 @@ kt_android_library( manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", + "//model:model_lib", + "//utility:utility_lib", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("androidx.appcompat:appcompat:1.0.2"), From 11094d09dd4363ee541833b5f6fe2876a78dde61 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 12:24:48 -0400 Subject: [PATCH 032/106] Added dependencies to testing_main_lib --- testing/BUILD.bazel | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 20bb11e276f..e552b4ad679 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -15,7 +15,20 @@ kt_android_library( "//utility:utility_lib", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("androidx.appcompat:appcompat:1.0.2"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), ], ) From 6a9058a135be45d7cfc7bf5e60a1fcb8ae3ccdae Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 13:55:20 -0400 Subject: [PATCH 033/106] Testing source files now build --- WORKSPACE | 21 ++++++- model/BUILD.bazel | 25 ++++---- .../proto/format_import_proto_library.bzl | 6 +- testing/BUILD.bazel | 4 +- utility/BUILD.bazel | 57 ++++++++++++++++++- 5 files changed, 94 insertions(+), 19 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 2a0c4817a5d..4df9ef679c3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -89,16 +89,33 @@ load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = DAGGER_ARTIFACTS + [ - "org.robolectric:robolectric:4.2", + "org.robolectric:robolectric:4.3", "androidx.appcompat:appcompat:1.0.2", + "com.android.support:support-annotations:28.0.0", "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", "androidx.core:core-ktx:1.0.1", - "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2",# + "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", "junit:junit:4.12", + "com.google.truth:truth:0.43", + "com.github.bumptech.glide:glide:4.11.0", + "com.github.bumptech.glide:compiler:4.11.0", + "com.caverock:androidsvg-aar:1.4", + "com.crashlytics.sdk.android:crashlytics:2.9.8", + "io.fabric.sdk.android:fabric:1.4.7", + "com.google.gms:google-services:4.3.3", + "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03", + "com.google.firebase:firebase-analytics-ktx:17.4.2", + "org.mockito:mockito-core:2.19.0", + "androidx.test.ext:junit:1.1.1", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", + "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", + "org.robolectric:annotations:4.3", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", "https://repo1.maven.org/maven2", "https://jcenter.bintray.com/", + "https://bintray.com/bintray/jcenter", + "https://maven.fabric.io/public", ], ) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 8ab04b7bf49..9246a9c64ff 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,5 +1,6 @@ load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_java//java:defs.bzl", "java_library") +load("@rules_java//java:defs.bzl", "java_lite_proto_library") load("//model:src/main/proto/format_import_proto_library.bzl", "format_import_proto_library") proto_library( @@ -7,7 +8,7 @@ proto_library( srcs = ["src/main/proto/event_logger.proto"], ) -java_proto_library( +java_lite_proto_library( name = "event_logger_java_proto", deps = [":event_logger_proto"], ) @@ -17,7 +18,7 @@ proto_library( srcs = ["src/main/proto/example.proto"], ) -java_proto_library( +java_lite_proto_library( name = "example_java_proto", deps = [":example_proto"], ) @@ -27,7 +28,7 @@ proto_library( srcs = ["src/main/proto/interaction_object.proto"], ) -java_proto_library( +java_lite_proto_library( name = "interaction_object_java_proto", deps = [":interaction_object_proto"], ) @@ -37,7 +38,7 @@ proto_library( srcs = ["src/main/proto/onboarding.proto"], ) -java_proto_library( +java_lite_proto_library( name = "onboarding_java_proto", deps = [":onboarding_proto"], ) @@ -47,7 +48,7 @@ proto_library( srcs = ["src/main/proto/profile.proto"], ) -java_proto_library( +java_lite_proto_library( name = "profile_java_proto", deps = [":profile_proto"], ) @@ -57,7 +58,7 @@ proto_library( srcs = ["src/main/proto/subtitled_html.proto"], ) -java_proto_library( +java_lite_proto_library( name = "subtitled_html_java_proto", deps = [":subtitled_html_proto"], ) @@ -67,7 +68,7 @@ proto_library( srcs = ["src/main/proto/thumbnail.proto"], ) -java_proto_library( +java_lite_proto_library( name = "thumbnail_java_proto", deps = [":thumbnail_proto"], ) @@ -77,7 +78,7 @@ proto_library( srcs = ["src/main/proto/translation.proto"], ) -java_proto_library( +java_lite_proto_library( name = "translation_java_proto", deps = [":translation_proto"], ) @@ -87,7 +88,7 @@ proto_library( srcs = ["src/main/proto/voiceover.proto"], ) -java_proto_library( +java_lite_proto_library( name = "voiceover_java_proto", deps = [":voiceover_proto"], ) @@ -109,7 +110,7 @@ format_import_proto_library( android_library( name = "model_lib", - data = [ + exports = [ ":event_logger_java_proto", ":example_java_proto", ":interaction_object_java_proto", @@ -119,6 +120,8 @@ android_library( ":thumbnail_java_proto", ":translation_java_proto", ":voiceover_java_proto", + ], + data = [ ":exploration_proto", ":question_proto", ":topic_proto", diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 30379a5026f..393ac690ecd 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -17,10 +17,10 @@ def format_import_proto_library(name, src): native.proto_library( name = name + "_lib", - srcs = ["processed_" + src] + srcs = ["processed_" + src], ) - native.java_proto_library( + native.java_lite_proto_library( name = name + "_java_lib", - deps = [name + "_lib"] + deps = [":" + name + "_lib"], ) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index e552b4ad679..d9e5b53eee9 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -12,7 +12,9 @@ kt_android_library( deps = [ ":dagger", "//model:model_lib", - "//utility:utility_lib", + "//utility:utility_logging_threading_accessibility_lib", + "@robolectric//bazel:android-all", + artifact("org.robolectric:robolectric"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 39a30114cb2..fe08d6ed599 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -7,14 +7,67 @@ package(default_visibility = ["//visibility:public"]) kt_android_library( name = "utility_lib", custom_package = "org.oppia.util", - srcs = glob(["src/main/**/*.kt"]), + srcs = glob( + ["src/main/java/org/oppia/util/**/*.kt"], + exclude = [ + "src/main/java/org/oppia/util/logging/*.kt", + "src/main/java/org/oppia/util/threading/*.kt" + ] + ), resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", + "//model:model_lib", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("androidx.appcompat:appcompat:1.0.2"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +#TODO: Have each library in utility contain a different rule +kt_android_library( + name = "utility_logging_threading_accessibility_lib", + custom_package = "org.oppia.util", + srcs = glob([ + "src/main/java/org/oppia/util/logging/*.kt", + "src/main/java/org/oppia/util/threading/*.kt", + "src/main/java/org/oppia/util/accessibility/*.kt", + ]), + resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), ], ) From 12deabe75d23683080071694613796ce95e3229a Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 14:01:36 -0400 Subject: [PATCH 034/106] Test files are building --- testing/BUILD.bazel | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index d9e5b53eee9..8d8cbae6db3 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -40,13 +40,32 @@ kt_android_library( srcs = glob(["src/test/java/**/*.kt"]), manifest = "src/main/AndroidManifest.xml", deps = [ + ":testing_main_lib", ":dagger", + "//model:model_lib", + "//utility:utility_logging_threading_accessibility_lib", + "@robolectric//bazel:android-all", + artifact("org.robolectric:robolectric"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("androidx.appcompat:appcompat:1.0.2"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), ], ) #TODO: Add android_local_test rule + dagger_rules() \ No newline at end of file From a8fe758839f075dfa3d5ba6d8a27f4069c04b1e0 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 14:03:24 -0400 Subject: [PATCH 035/106] Changed to java_lite --- model/BUILD.bazel | 26 +++++++++++-------- .../proto/format_import_proto_library.bzl | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index a9f091934ed..9246a9c64ff 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,5 +1,6 @@ load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_java//java:defs.bzl", "java_library") +load("@rules_java//java:defs.bzl", "java_lite_proto_library") load("//model:src/main/proto/format_import_proto_library.bzl", "format_import_proto_library") proto_library( @@ -7,7 +8,7 @@ proto_library( srcs = ["src/main/proto/event_logger.proto"], ) -java_proto_library( +java_lite_proto_library( name = "event_logger_java_proto", deps = [":event_logger_proto"], ) @@ -17,7 +18,7 @@ proto_library( srcs = ["src/main/proto/example.proto"], ) -java_proto_library( +java_lite_proto_library( name = "example_java_proto", deps = [":example_proto"], ) @@ -27,7 +28,7 @@ proto_library( srcs = ["src/main/proto/interaction_object.proto"], ) -java_proto_library( +java_lite_proto_library( name = "interaction_object_java_proto", deps = [":interaction_object_proto"], ) @@ -37,7 +38,7 @@ proto_library( srcs = ["src/main/proto/onboarding.proto"], ) -java_proto_library( +java_lite_proto_library( name = "onboarding_java_proto", deps = [":onboarding_proto"], ) @@ -47,7 +48,7 @@ proto_library( srcs = ["src/main/proto/profile.proto"], ) -java_proto_library( +java_lite_proto_library( name = "profile_java_proto", deps = [":profile_proto"], ) @@ -57,7 +58,7 @@ proto_library( srcs = ["src/main/proto/subtitled_html.proto"], ) -java_proto_library( +java_lite_proto_library( name = "subtitled_html_java_proto", deps = [":subtitled_html_proto"], ) @@ -67,7 +68,7 @@ proto_library( srcs = ["src/main/proto/thumbnail.proto"], ) -java_proto_library( +java_lite_proto_library( name = "thumbnail_java_proto", deps = [":thumbnail_proto"], ) @@ -77,7 +78,7 @@ proto_library( srcs = ["src/main/proto/translation.proto"], ) -java_proto_library( +java_lite_proto_library( name = "translation_java_proto", deps = [":translation_proto"], ) @@ -87,7 +88,7 @@ proto_library( srcs = ["src/main/proto/voiceover.proto"], ) -java_proto_library( +java_lite_proto_library( name = "voiceover_java_proto", deps = [":voiceover_proto"], ) @@ -109,7 +110,7 @@ format_import_proto_library( android_library( name = "model_lib", - data = [ + exports = [ ":event_logger_java_proto", ":example_java_proto", ":interaction_object_java_proto", @@ -119,8 +120,11 @@ android_library( ":thumbnail_java_proto", ":translation_java_proto", ":voiceover_java_proto", + ], + data = [ ":exploration_proto", ":question_proto", ":topic_proto", ], + visibility = ["//visibility:public"], ) diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 30379a5026f..300f43bf52b 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -20,7 +20,7 @@ def format_import_proto_library(name, src): srcs = ["processed_" + src] ) - native.java_proto_library( + native.java_lite_proto_library( name = name + "_java_lib", deps = [name + "_lib"] ) From 3f27b226c1676ae8b65bef32ac967ff8c618a663 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 14:11:45 -0400 Subject: [PATCH 036/106] Added EOF newlines --- testing/BUILD.bazel | 2 +- utility/BUILD.bazel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 92904888d07..b3427ca4b45 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -67,4 +67,4 @@ kt_android_library( #TODO: Add android_local_test rule -dagger_rules() \ No newline at end of file +dagger_rules() diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 37453efdb8a..280002c783c 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -106,4 +106,4 @@ android_local_test( ) ''' -dagger_rules() \ No newline at end of file +dagger_rules() From bb1b906fa217b3e92e8e20493f5b5c490e5bff79 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 14:26:38 -0400 Subject: [PATCH 037/106] Each library now has its own build rule --- utility/BUILD.bazel | 415 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 369 insertions(+), 46 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 1f2755ebb8a..7c3fd496be2 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -5,20 +5,359 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "utility_lib", + +) + +kt_android_library( + name = "utility_accessibility_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/accessibility/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_caching_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/caching/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_data_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/data/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_datetime_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/datetime/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_extensions_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/extensions/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_gcsresource_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/gcsresource/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_logging_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/logging/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_networking_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/networking/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_parser_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/parser/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_profile_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/profile/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_statusbar_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/statusbar/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_system_lib", custom_package = "org.oppia.util", - srcs = glob(["src/main/**/*.kt"]), + srcs = glob(["src/main/java/org/oppia/util/system/*.kt"]), resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - "//firebase:crashlytics_lib", - "//firebase:crashlytics_deps", + "//model:model_lib", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("com.google.truth:truth"), artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("com.google.firebase:firebase-analytics-ktx"), + artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("com.google.gms:google-services:4.3.3"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core:2.19.0"), + ], +) + +kt_android_library( + name = "utility_threading_lib", + custom_package = "org.oppia.util", + srcs = glob(["src/main/java/org/oppia/util/threading/*.kt"]), + resource_files = glob(["src/main/res/**/*.xml"]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("com.google.truth:truth"), + artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), artifact("com.github.bumptech.glide:compiler"), artifact("com.caverock:androidsvg-aar"), @@ -33,6 +372,7 @@ kt_android_library( ], ) +#TODO: Build all tests kt_android_library( name = "async", custom_package = "org.oppia.util", @@ -69,55 +409,38 @@ kt_android_library( deps = [ ":async", ":dagger", -# "//testing:testing_main_lib", "@robolectric//bazel:android-all", "@maven//:org_robolectric_robolectric", artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), -# artifact("com.google.truth:truth"), -# artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), -# artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - #artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), -# artifact("androidx.lifecycle:lifecycle-livedata-ktx"), -# artifact("io.fabric.sdk.android:fabric:1.4.7"), -# artifact("org.mockito:mockito-core:2.19.0"), -# artifact("androidx.test.ext:junit"), -# artifact("com.github.bumptech.glide:glide"), -# artifact("com.github.bumptech.glide:compiler"), -# artifact("com.caverock:androidsvg-aar"), -# artifact("androidx.appcompat:appcompat"), -# artifact("androidx.core:core-ktx"), -# artifact("junit:junit"), -# artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), ], ) android_local_test( - name = "async_tests", - custom_package = "org.oppia.util", - test_class = "org.oppia.util.data.AsyncResultTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":async_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - artifact("com.google.truth:truth"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("org.mockito:mockito-core:2.19.0"), - artifact("androidx.test.ext:junit"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.appcompat:appcompat"), - artifact("androidx.core:core-ktx"), - artifact("junit:junit"), - artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), - ], - -) + name = "async_tests", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.data.AsyncResultTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":async_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + artifact("com.google.truth:truth"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + artifact("io.fabric.sdk.android:fabric:1.4.7"), + artifact("org.mockito:mockito-core:2.19.0"), + artifact("androidx.test.ext:junit"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.github.bumptech.glide:compiler"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.appcompat:appcompat"), + artifact("androidx.core:core-ktx"), + artifact("junit:junit"), + artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), + ], + ) android_local_test( name = "demo_test", From 30a8ac26fc2860a41690b30bece230b5c40bfa50 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 15:36:13 -0400 Subject: [PATCH 038/106] Utility is now one rule --- utility/BUILD.bazel | 347 +------------------------------------------- 1 file changed, 5 insertions(+), 342 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 7c3fd496be2..2c68523cfdd 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -5,354 +5,17 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - -) - -kt_android_library( - name = "utility_accessibility_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/accessibility/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_caching_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/caching/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_data_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/data/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_datetime_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/datetime/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_extensions_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/extensions/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_gcsresource_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/gcsresource/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_logging_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/logging/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_networking_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/networking/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_parser_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/parser/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_profile_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/profile/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_statusbar_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/statusbar/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_system_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/system/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), - ], -) - -kt_android_library( - name = "utility_threading_lib", + name = "utility_lib", custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/threading/*.kt"]), + srcs = glob(["src/main/java/org/oppia/util/**/*.kt"], + exclude = ["src/main/java/org/oppia/util/logging/firebase/*.kt"]), resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", "//model:model_lib", + "//firebase:crashlytics_lib", + "//firebase:crashlytics_deps", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), From ef3e8571339fb3fb520d751aa1d7415d9f6be7c3 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 15:57:27 -0400 Subject: [PATCH 039/106] Changed visibility for utility_lib --- utility/BUILD.bazel | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 2c68523cfdd..0d32b978a74 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -2,8 +2,6 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") -package(default_visibility = ["//visibility:public"]) - kt_android_library( name = "utility_lib", custom_package = "org.oppia.util", @@ -33,6 +31,7 @@ kt_android_library( artifact("androidx.test.ext:junit"), artifact("org.mockito:mockito-core:2.19.0"), ], + visibility = ["//visibility:public"] ) #TODO: Build all tests From d107b075f68cf01dd4024f0cda7eead7c477a8ae Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 16:06:52 -0400 Subject: [PATCH 040/106] Added duplicate google-services.json file to please Gradle --- app/google-services.json | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/google-services.json diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 00000000000..5b1dc0f6672 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "215533462679", + "firebase_url": "https://oppia-android-dev.firebaseio.com", + "project_id": "oppia-android-dev", + "storage_bucket": "oppia-android-dev.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:215533462679:android:a25a70347460cd014035d2", + "android_client_info": { + "package_name": "org.oppia.app" + } + }, + "oauth_client": [ + { + "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCI5yOe1vF9g_e3tcIQb64C5i64AUNT1fc" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} From 94213cdb133a905f2fbe154167f55d34a840de12 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 13:08:02 -0400 Subject: [PATCH 041/106] Changed event_logger.proto to oppia_logger.proto --- model/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 9246a9c64ff..bedc30c3bb1 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -5,7 +5,7 @@ load("//model:src/main/proto/format_import_proto_library.bzl", "format_import_pr proto_library( name = "event_logger_proto", - srcs = ["src/main/proto/event_logger.proto"], + srcs = ["src/main/proto/oppia_logger.proto"], ) java_lite_proto_library( From 24e8537e263e15ad20919627a7bcaa3831d918fe Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 13:36:26 -0400 Subject: [PATCH 042/106] Added missing EOF newlines --- firebase/BUILD.bazel | 2 +- testing/BUILD.bazel | 2 +- utility/src/main/AndroidManifest.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firebase/BUILD.bazel b/firebase/BUILD.bazel index 4f55531ff56..f19532f58b3 100644 --- a/firebase/BUILD.bazel +++ b/firebase/BUILD.bazel @@ -23,4 +23,4 @@ android_library( artifact("com.crashlytics.sdk.android:crashlytics"), artifact("io.fabric.sdk.android:fabric"), ], -) \ No newline at end of file +) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index d85cdf85678..94c6c0d6350 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -19,4 +19,4 @@ kt_android_library( ], ) -dagger_rules() \ No newline at end of file +dagger_rules() diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index a4f801202ae..51500aa9971 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ - \ No newline at end of file + From e1ce0d1916e9ee226995b9e7653f1d28723ffdc2 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 17:01:42 -0400 Subject: [PATCH 043/106] Fixed bug in import statements for exploration.proto, topic.proto, and question.proto --- model/BUILD.bazel | 51 +++++++++++++++---- .../proto/format_import_proto_library.bzl | 27 +++++++--- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index bedc30c3bb1..e765332a70c 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -94,18 +94,49 @@ java_lite_proto_library( ) format_import_proto_library( - name = "topic_proto", - src = "src/main/proto/topic.proto" + name = "question", + src = "src/main/proto/question.proto", + deps = [ + ":exploration_proto", + ":subtitled_html_proto", + ], +) + +java_lite_proto_library( + name = "question_java_proto", + deps = [":question_proto"], ) format_import_proto_library( - name = "question_proto", - src = "src/main/proto/question.proto" + name = "topic", + src = "src/main/proto/topic.proto", + deps = [ + ":subtitled_html_proto", + ":thumbnail_proto", + ":translation_proto", + ":voiceover_proto", + ], +) + +java_lite_proto_library( + name = "topic_java_proto", + deps = [":topic_proto"], ) format_import_proto_library( - name = "exploration_proto", - src = "src/main/proto/exploration.proto" + name = "exploration", + src = "src/main/proto/exploration.proto", + deps = [ + ":subtitled_html_proto", + ":interaction_object_proto", + ":translation_proto", + ":voiceover_proto", + ], +) + +java_lite_proto_library( + name = "exploration_java_proto", + deps = [":exploration_proto"], ) android_library( @@ -120,11 +151,9 @@ android_library( ":thumbnail_java_proto", ":translation_java_proto", ":voiceover_java_proto", - ], - data = [ - ":exploration_proto", - ":question_proto", - ":topic_proto", + ":exploration_java_proto", + ":question_java_proto", + ":topic_java_proto", ], visibility = ["//visibility:public"], ) diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 300f43bf52b..553fed9ed32 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -1,26 +1,39 @@ -def format_import_proto_library(name, src): +def format_import_proto_library(name, src, deps): """ Formats the import statement of the src file to contain a full path to the file The genrule() rule generates a copy of the src file and alters the copy The proto_library() rule takes this altered copy and builds it """ + native.genrule( name = name, srcs = [src], outs = ["processed_" + src], - cmd = ''' cp $< $@ &&\ - sed 's/import \"/import \"model\/src\/main\/proto\//g' $< > $@ + cmd = ''' + cat $< | + sed 's/import \"/import \"model\/src\/main\/proto\//g' | + sed 's/\"model\/src\/main\/proto\/exploration/\"model\/processed_src\/main\/proto\/exploration/g' | + sed 's/\"model\/src\/main\/proto\/topic/\"model\/processed_src\/main\/proto\/topic/g' | + sed 's/\"model\/src\/main\/proto\/question/\"model\/processed_src\/main\/proto\/question/g' > $@ ''' , ) native.proto_library( - name = name + "_lib", - srcs = ["processed_" + src] + name = name + "_proto", + srcs = ["processed_" + src], + deps = deps ) +''' native.java_lite_proto_library( - name = name + "_java_lib", - deps = [name + "_lib"] + name = name + "_java_proto", + deps = [name + "_proto"] + java_lite_proto_deps, ) +''' + +''' cp $< $@ &&\ + sed 's/import \"/import \"model\/src\/main\/proto\//g' $< > $@ &&\ + sed 's/\"model\/src\/main\/proto\/exploration/\"exploration/g' $@ >> $@ + ''' \ No newline at end of file From 23cd84ade622ed61d77b3e7a060dad9421eae272 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 17:20:05 -0400 Subject: [PATCH 044/106] Deleted DemoJava --- utility/BUILD.bazel | 17 ---------------- .../org/oppia/util/data/DemoJavaTest.java | 20 ------------------- 2 files changed, 37 deletions(-) delete mode 100644 utility/src/test/java/org/oppia/util/data/DemoJavaTest.java diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 0d32b978a74..4a9e45c6fb0 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -104,23 +104,6 @@ android_local_test( ], ) -android_local_test( - name = "demo_test", - custom_package = "org.oppia.util", - test_class = "org.oppia.util.data.DemoJavaTest", - srcs = ["src/test/java/org/oppia/util/data/DemoJavaTest.java"], - manifest = "src/test/TestManifest.xml", - deps = [ - #":async_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - artifact("com.google.truth:truth"), - artifact("junit:junit"), - artifact("org.robolectric:annotations:4.3"), - artifact("androidx.test.ext:junit"), - ], -) - #TODO: Get android_local_test working with kotlin files ''' kt_android_library( diff --git a/utility/src/test/java/org/oppia/util/data/DemoJavaTest.java b/utility/src/test/java/org/oppia/util/data/DemoJavaTest.java deleted file mode 100644 index 34317a2ccac..00000000000 --- a/utility/src/test/java/org/oppia/util/data/DemoJavaTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.oppia.util.data; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.annotation.LooperMode; - -import static com.google.common.truth.Truth.assertThat; - -@RunWith(AndroidJUnit4.class) -@LooperMode(LooperMode.Mode.PAUSED) -public class DemoJavaTest { - - @Test - public void testIsTrue() { - boolean result = true; - assertThat(result).isTrue(); - } - -} From 67fee1870d03d2951b51ac0bc6edc50ce052ec24 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 17:18:53 -0400 Subject: [PATCH 045/106] CHanged rules_kotlin version --- WORKSPACE | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 2001c25703e..971437309de 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,19 +20,31 @@ http_archive( load("@rules_jvm_external//:defs.bzl", "maven_install") # Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin. -RULES_KOTLIN_VERSION = "legacy-1.3.0-rc4" -RULES_KOTLIN_SHA = "fe32ced5273bcc2f9e41cea65a28a9184a77f3bc30fea8a5c47b3d3bfc801dff" -http_archive( - name = "io_bazel_rules_kotlin", - urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], - type = "zip", - strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, - sha256 = RULES_KOTLIN_SHA, -) +#RULES_KOTLIN_VERSION = "legacy-1.3.0-rc4" +#RULES_KOTLIN_SHA = "fe32ced5273bcc2f9e41cea65a28a9184a77f3bc30fea8a5c47b3d3bfc801dff" +#http_archive( +# name = "io_bazel_rules_kotlin", +# urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], +# type = "zip", +# strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, +# sha256 = RULES_KOTLIN_SHA, +#) +#load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") +#kotlin_repositories() +#kt_register_toolchains() -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") -kotlin_repositories() -kt_register_toolchains() +#RULES_KOTLIN_VERSION = "legacy-1.3.0-rc4" +#RULES_KOTLIN_SHA = "fe32ced5273bcc2f9e41cea65a28a9184a77f3bc30fea8a5c47b3d3bfc801dff" +#http_archive( +# name = "io_bazel_rules_kotlin", +# urls = ["https://github.com/oppia/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], +# type = "zip", +# strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, +# sha256 = RULES_KOTLIN_SHA, +#) +#load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") +#kotlin_repositories() +#kt_register_toolchains() # rules_proto defines abstract rules for building Protocol Buffers. http_archive( @@ -63,3 +75,19 @@ http_archive( load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") rules_java_dependencies() rules_java_toolchains() + +RULES_KOTLIN_VERSION = "legacy-1.4.0-rcx-oppia-exclusive-rc01" +RULES_KOTLIN_SHA = "600f3d916eda5531dd70614ec96dc92b4ac24da0e1d815eb94559976e9bea8aa" +http_archive( + name = "io_bazel_rules_kotlin", + urls = ["https://github.com/oppia/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], + type = "zip", + strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, + sha256 = RULES_KOTLIN_SHA, +) +#TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release +load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies") +kt_download_local_dev_dependencies() +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") +kotlin_repositories() +kt_register_toolchains() From 48eb9be3d8a1a01e1f3d59a62f77341a9f6ef8a4 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 11:40:53 -0400 Subject: [PATCH 046/106] Added Firebase dependencies --- WORKSPACE | 4 ++++ utility/BUILD.bazel | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 947b21f3922..129f0572680 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -123,6 +123,10 @@ maven_install( "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", "org.robolectric:annotations:4.3", + "com.crashlytics.sdk.android:crashlytics:2.9.8", #Firebase + "io.fabric.sdk.android:fabric:1.4.7", #Firebase + "com.google.firebase:firebase-analytics:17.4.4", #Firebase + "com.google.firebase:firebase-crashlytics:17.1.1", #Firebase ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 4a9e45c6fb0..110be33551b 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -14,6 +14,8 @@ kt_android_library( "//model:model_lib", "//firebase:crashlytics_lib", "//firebase:crashlytics_deps", + artifact("com.google.firebase:firebase-analytics:17.4.4"), + artifact("com.google.firebase:firebase-crashlytics:17.1.1"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), @@ -23,7 +25,6 @@ kt_android_library( artifact("com.github.bumptech.glide:compiler"), artifact("com.caverock:androidsvg-aar"), artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), artifact("io.fabric.sdk.android:fabric:1.4.7"), artifact("com.google.gms:google-services:4.3.3"), From c466d3ccd109583a1aac0afa0917b1ab00a4c5b8 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 11:50:54 -0400 Subject: [PATCH 047/106] Removed AsyncResultTest example --- utility/BUILD.bazel | 97 --------------------------------------------- 1 file changed, 97 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 110be33551b..6cd66213034 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -35,103 +35,6 @@ kt_android_library( visibility = ["//visibility:public"] ) -#TODO: Build all tests -kt_android_library( - name = "async", - custom_package = "org.oppia.util", - srcs = ["src/main/java/org/oppia/util/data/AsyncResult.kt"], - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//testing:testing_main_lib", - artifact("com.google.truth:truth"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("org.mockito:mockito-core:2.19.0"), - artifact("androidx.test.ext:junit"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.appcompat:appcompat"), - artifact("androidx.core:core-ktx"), - artifact("junit:junit"), - artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), - ], -) - -kt_android_library( - name = "async_test_lib", - custom_package = "org.oppia.util", - srcs = ["src/test/java/org/oppia/util/data/AsyncResultTest.kt"], - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/test/TestManifest.xml", - deps = [ - ":async", - ":dagger", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), - ], -) - -android_local_test( - name = "async_tests", - custom_package = "org.oppia.util", - test_class = "org.oppia.util.data.AsyncResultTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":async_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - artifact("com.google.truth:truth"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("org.mockito:mockito-core:2.19.0"), - artifact("androidx.test.ext:junit"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.appcompat:appcompat"), - artifact("androidx.core:core-ktx"), - artifact("junit:junit"), - artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), - ], - ) - #TODO: Get android_local_test working with kotlin files -''' -kt_android_library( - name = "test_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/test/**/*.kt", "src/test/**/**/*.kt"]), - resource_files = glob(["src/main/res/**/*.xml", "src/main/res/**/*.png"]), - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_lib", - ], -) -''' -''' -android_local_test( - name = "all_tests", - custom_package = "org.oppia.util", - test_class = "org.oppia.util", - manifest = "src/test/TestManifest.xml", - deps = [ - ":test_lib", - "@robolectric//bazel:android-all", - artifact("org.robolectric:robolectric"), - artifact("junit:junit"), - ], - -) -''' dagger_rules() From a5e903943871fa9ef081240b6eb34da996dc629d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 11:52:49 -0400 Subject: [PATCH 048/106] Removed AsynchResultTest example --- utility/BUILD.bazel | 71 --------------------------------------------- 1 file changed, 71 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index db2503f5652..6cd66213034 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -35,77 +35,6 @@ kt_android_library( visibility = ["//visibility:public"] ) -#TODO: Build all tests -kt_android_library( - name = "async", - custom_package = "org.oppia.util", - srcs = ["src/main/java/org/oppia/util/data/AsyncResult.kt"], - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//testing:testing_main_lib", - artifact("com.google.truth:truth"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("org.mockito:mockito-core:2.19.0"), - artifact("androidx.test.ext:junit"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.appcompat:appcompat"), - artifact("androidx.core:core-ktx"), - artifact("junit:junit"), - artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), - ], -) - -kt_android_library( - name = "async_test_lib", - custom_package = "org.oppia.util", - srcs = ["src/test/java/org/oppia/util/data/AsyncResultTest.kt"], - resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/test/TestManifest.xml", - deps = [ - ":async", - ":dagger", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), - ], -) - -android_local_test( - name = "async_tests", - custom_package = "org.oppia.util", - test_class = "org.oppia.util.data.AsyncResultTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":async_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - artifact("com.google.truth:truth"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("org.mockito:mockito-core:2.19.0"), - artifact("androidx.test.ext:junit"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.appcompat:appcompat"), - artifact("androidx.core:core-ktx"), - artifact("junit:junit"), - artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), - ], - ) - #TODO: Get android_local_test working with kotlin files - dagger_rules() From 8d6b28f8c1b55acfd51466a393e676ce00152dda Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 11:23:49 -0400 Subject: [PATCH 049/106] Removed unnecessary comments in WORKSPACE and moved rules_kotlin --- WORKSPACE | 56 +++++++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 971437309de..524e6a127a5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,31 +20,21 @@ http_archive( load("@rules_jvm_external//:defs.bzl", "maven_install") # Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin. -#RULES_KOTLIN_VERSION = "legacy-1.3.0-rc4" -#RULES_KOTLIN_SHA = "fe32ced5273bcc2f9e41cea65a28a9184a77f3bc30fea8a5c47b3d3bfc801dff" -#http_archive( -# name = "io_bazel_rules_kotlin", -# urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], -# type = "zip", -# strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, -# sha256 = RULES_KOTLIN_SHA, -#) -#load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") -#kotlin_repositories() -#kt_register_toolchains() - -#RULES_KOTLIN_VERSION = "legacy-1.3.0-rc4" -#RULES_KOTLIN_SHA = "fe32ced5273bcc2f9e41cea65a28a9184a77f3bc30fea8a5c47b3d3bfc801dff" -#http_archive( -# name = "io_bazel_rules_kotlin", -# urls = ["https://github.com/oppia/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], -# type = "zip", -# strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, -# sha256 = RULES_KOTLIN_SHA, -#) -#load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") -#kotlin_repositories() -#kt_register_toolchains() +RULES_KOTLIN_VERSION = "legacy-1.4.0-rcx-oppia-exclusive-rc01" +RULES_KOTLIN_SHA = "600f3d916eda5531dd70614ec96dc92b4ac24da0e1d815eb94559976e9bea8aa" +http_archive( + name = "io_bazel_rules_kotlin", + urls = ["https://github.com/oppia/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], + type = "zip", + strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, + sha256 = RULES_KOTLIN_SHA, +) +#TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release +load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies") +kt_download_local_dev_dependencies() +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") +kotlin_repositories() +kt_register_toolchains() # rules_proto defines abstract rules for building Protocol Buffers. http_archive( @@ -75,19 +65,3 @@ http_archive( load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") rules_java_dependencies() rules_java_toolchains() - -RULES_KOTLIN_VERSION = "legacy-1.4.0-rcx-oppia-exclusive-rc01" -RULES_KOTLIN_SHA = "600f3d916eda5531dd70614ec96dc92b4ac24da0e1d815eb94559976e9bea8aa" -http_archive( - name = "io_bazel_rules_kotlin", - urls = ["https://github.com/oppia/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION], - type = "zip", - strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, - sha256 = RULES_KOTLIN_SHA, -) -#TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release -load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies") -kt_download_local_dev_dependencies() -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") -kotlin_repositories() -kt_register_toolchains() From d712b5e94c77508f56fb0386d7b09f266c022ada Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 11:35:33 -0400 Subject: [PATCH 050/106] Added re-naming TODOs --- BUILD.bazel | 1 + model/BUILD.bazel | 1 + 2 files changed, 2 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index e69de29bb2d..c6dcdaab5e5 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -0,0 +1 @@ +#TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. \ No newline at end of file diff --git a/model/BUILD.bazel b/model/BUILD.bazel index e765332a70c..866bb8fcabb 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,3 +1,4 @@ +#TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_java//java:defs.bzl", "java_library") load("@rules_java//java:defs.bzl", "java_lite_proto_library") From 310514452819eb6330a8ee3d4b1807d3a22a9569 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 11:52:45 -0400 Subject: [PATCH 051/106] Renamed java_proto rules java_proto_lite --- model/BUILD.bazel | 48 +++++++++---------- .../proto/format_import_proto_library.bzl | 15 +----- 2 files changed, 25 insertions(+), 38 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 866bb8fcabb..3d67708f30a 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -10,7 +10,7 @@ proto_library( ) java_lite_proto_library( - name = "event_logger_java_proto", + name = "event_logger_java_proto_lite", deps = [":event_logger_proto"], ) @@ -20,7 +20,7 @@ proto_library( ) java_lite_proto_library( - name = "example_java_proto", + name = "example_java_proto_lite", deps = [":example_proto"], ) @@ -30,7 +30,7 @@ proto_library( ) java_lite_proto_library( - name = "interaction_object_java_proto", + name = "interaction_object_java_proto_lite", deps = [":interaction_object_proto"], ) @@ -40,7 +40,7 @@ proto_library( ) java_lite_proto_library( - name = "onboarding_java_proto", + name = "onboarding_java_proto_lite", deps = [":onboarding_proto"], ) @@ -50,7 +50,7 @@ proto_library( ) java_lite_proto_library( - name = "profile_java_proto", + name = "profile_java_proto_lite", deps = [":profile_proto"], ) @@ -60,7 +60,7 @@ proto_library( ) java_lite_proto_library( - name = "subtitled_html_java_proto", + name = "subtitled_html_java_proto_lite", deps = [":subtitled_html_proto"], ) @@ -70,7 +70,7 @@ proto_library( ) java_lite_proto_library( - name = "thumbnail_java_proto", + name = "thumbnail_java_proto_lite", deps = [":thumbnail_proto"], ) @@ -80,7 +80,7 @@ proto_library( ) java_lite_proto_library( - name = "translation_java_proto", + name = "translation_java_proto_lite", deps = [":translation_proto"], ) @@ -90,7 +90,7 @@ proto_library( ) java_lite_proto_library( - name = "voiceover_java_proto", + name = "voiceover_java_proto_lite", deps = [":voiceover_proto"], ) @@ -104,7 +104,7 @@ format_import_proto_library( ) java_lite_proto_library( - name = "question_java_proto", + name = "question_java_proto_lite", deps = [":question_proto"], ) @@ -120,7 +120,7 @@ format_import_proto_library( ) java_lite_proto_library( - name = "topic_java_proto", + name = "topic_java_proto_lite", deps = [":topic_proto"], ) @@ -136,25 +136,25 @@ format_import_proto_library( ) java_lite_proto_library( - name = "exploration_java_proto", + name = "exploration_java_proto_lite", deps = [":exploration_proto"], ) android_library( name = "model_lib", exports = [ - ":event_logger_java_proto", - ":example_java_proto", - ":interaction_object_java_proto", - ":onboarding_java_proto", - ":profile_java_proto", - ":subtitled_html_java_proto", - ":thumbnail_java_proto", - ":translation_java_proto", - ":voiceover_java_proto", - ":exploration_java_proto", - ":question_java_proto", - ":topic_java_proto", + ":event_logger_java_proto_lite", + ":example_java_proto_lite", + ":interaction_object_java_proto_lite", + ":onboarding_java_proto_lite", + ":profile_java_proto_lite", + ":subtitled_html_java_proto_lite", + ":thumbnail_java_proto_lite", + ":translation_java_proto_lite", + ":voiceover_java_proto_lite", + ":exploration_java_proto_lite", + ":question_java_proto_lite", + ":topic_java_proto_lite", ], visibility = ["//visibility:public"], ) diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 553fed9ed32..a29d09c0ee3 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -16,8 +16,7 @@ def format_import_proto_library(name, src, deps): sed 's/\"model\/src\/main\/proto\/exploration/\"model\/processed_src\/main\/proto\/exploration/g' | sed 's/\"model\/src\/main\/proto\/topic/\"model\/processed_src\/main\/proto\/topic/g' | sed 's/\"model\/src\/main\/proto\/question/\"model\/processed_src\/main\/proto\/question/g' > $@ - ''' - , + ''', ) native.proto_library( @@ -25,15 +24,3 @@ def format_import_proto_library(name, src, deps): srcs = ["processed_" + src], deps = deps ) - -''' - native.java_lite_proto_library( - name = name + "_java_proto", - deps = [name + "_proto"] + java_lite_proto_deps, - ) -''' - -''' cp $< $@ &&\ - sed 's/import \"/import \"model\/src\/main\/proto\//g' $< > $@ &&\ - sed 's/\"model\/src\/main\/proto\/exploration/\"exploration/g' $@ >> $@ - ''' \ No newline at end of file From 2f50207f1ee612cd7ff55b99243e2adbd9e9dc48 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 12:26:32 -0400 Subject: [PATCH 052/106] Added doc comments to model/BUILD.bazel and format_import_proto_library --- model/BUILD.bazel | 5 ++++- .../proto/format_import_proto_library.bzl | 22 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 3d67708f30a..b11b2a28f91 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,6 +1,9 @@ #TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. +'''In Bazel, proto files are built using the proto_library() and java_lite_proto_library() rules. +The proto_library() rule creates a proto file library to be used in multiple languages. +The java_lite_proto_library() rule takes in a proto_library target and generates java code. +''' load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_java//java:defs.bzl", "java_library") load("@rules_java//java:defs.bzl", "java_lite_proto_library") load("//model:src/main/proto/format_import_proto_library.bzl", "format_import_proto_library") diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index a29d09c0ee3..9178229782e 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -1,9 +1,23 @@ def format_import_proto_library(name, src, deps): - """ - Formats the import statement of the src file to contain a full path to the file - The genrule() rule generates a copy of the src file and alters the copy - The proto_library() rule takes this altered copy and builds it + """This macro exists as a way to build proto files that contain import statements in both Gradle + and Bazel. + Currently the files that use this macro are: exploration.proto, topic.proto, and question.proto. + This macro formats the src file's import statements to contain a full path to the file in order + for Bazel to properly locate file. + The genrule() rule generates an altered copy of the src file for Bazel to build, leaving the + unaltered copy for Gradle to use. + The proto_library() rule takes this altered copy and builds it into a proto_library that a + java_lite_proto_library() rule can depend on. + + Args: + name: str. The name of the .proto file without the '.proto' suffix. This will be the root for + the name of the proto library created. Ex: If name = 'topic', then the src file is + 'topic.proto' and the proto library created will be named 'topic_proto'. + src: str. The name of the .proto file to be built into a proto_library. + deps: list of str. The list of dependencies needed to build the src file. This list will contain + all of the proto_library targets for the files imported into src. + """ native.genrule( From 323a0cb355e1d4cf592f70f198dd94a8f7d5ba73 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 12:31:30 -0400 Subject: [PATCH 053/106] Added comments to WORKSPACE file --- WORKSPACE | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index 524e6a127a5..37bf019f674 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,6 +1,10 @@ +'''This file lists and imports all external dependencies needed to build Oppia Android. +''' load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") +# Android SDK configuration. For more details, see: +# https://docs.bazel.build/versions/master/be/android.html#android_sdk_repository android_sdk_repository( name = "androidsdk", api_level = 28, From d87c95c56ed5e1f3f5781a08f48fd7b8daf1aed5 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 12:50:48 -0400 Subject: [PATCH 054/106] Fixed nits --- BUILD.bazel | 2 +- WORKSPACE | 15 +++++++-------- model/BUILD.bazel | 2 +- .../main/proto/format_import_proto_library.bzl | 2 +- utility/BUILD.bazel | 5 +++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index c6dcdaab5e5..9eb76c0f2e8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1 +1 @@ -#TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. \ No newline at end of file +# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index dea13602e55..fd50e7aa94f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -9,7 +9,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") android_sdk_repository( name = "androidsdk", api_level = 28, - #build_tools_version = "28.0.2", + # build_tools_version = "28.0.2", ) # Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external @@ -34,7 +34,8 @@ http_archive( strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, sha256 = RULES_KOTLIN_SHA, ) -#TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release + +# TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies") kt_download_local_dev_dependencies() load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") @@ -71,7 +72,7 @@ load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_jav rules_java_dependencies() rules_java_toolchains() -#Add support for Dagger +# Add support for Dagger DAGGER_TAG = "2.28.1" DAGGER_SHA = "9e69ab2f9a47e0f74e71fe49098bea908c528aa02fa0c5995334447b310d0cdd" http_archive( @@ -83,7 +84,7 @@ http_archive( load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES") -#Add support for Robolectric: https://github.com/robolectric/robolectric-bazel +# Add support for Robolectric: https://github.com/robolectric/robolectric-bazel http_archive( name = "robolectric", urls = ["https://github.com/oppia/robolectric-bazel/archive/4.x-oppia-exclusive-rc02.tar.gz"], @@ -92,8 +93,7 @@ http_archive( load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories") robolectric_repositories() -#Add support for Firebase Crashlytics - +# Add support for Firebase Crashlytics git_repository( name = "tools_android", commit = "00e6f4b7bdd75911e33c618a9bc57bab7a6e8930", @@ -103,9 +103,8 @@ git_repository( load("@tools_android//tools/googleservices:defs.bzl", "google_services_workspace_dependencies") google_services_workspace_dependencies() - load("@rules_jvm_external//:defs.bzl", "maven_install") -#TODO: Remove unused dependencies once android_local_test errors are resolved +# TODO: Remove unused dependencies once android_local_test errors are resolved maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.3", diff --git a/model/BUILD.bazel b/model/BUILD.bazel index b11b2a28f91..5470f4e1126 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,4 +1,4 @@ -#TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. +# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. '''In Bazel, proto files are built using the proto_library() and java_lite_proto_library() rules. The proto_library() rule creates a proto file library to be used in multiple languages. The java_lite_proto_library() rule takes in a proto_library target and generates java code. diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 9178229782e..cc11a1c65ef 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -36,5 +36,5 @@ def format_import_proto_library(name, src, deps): native.proto_library( name = name + "_proto", srcs = ["processed_" + src], - deps = deps + deps = deps, ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 6cd66213034..56fa01a86d0 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -1,3 +1,4 @@ +# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") @@ -32,9 +33,9 @@ kt_android_library( artifact("androidx.test.ext:junit"), artifact("org.mockito:mockito-core:2.19.0"), ], - visibility = ["//visibility:public"] + visibility = ["//visibility:public"], ) -#TODO: Get android_local_test working with kotlin files +# TODO: Get android_local_test working with kotlin files dagger_rules() From 20d2c5d5b60682311b7e39c70c79475140ab924c Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 12:54:19 -0400 Subject: [PATCH 055/106] Added comment to kt_android_library() rule --- utility/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 56fa01a86d0..8ee03e698be 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") +'''A kt_android_library() rule that builds utility module kotlin source files into a library.''' kt_android_library( name = "utility_lib", custom_package = "org.oppia.util", From 9857eafde6440b0f02a4d66fd2db6a9c9719104b Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 12:57:18 -0400 Subject: [PATCH 056/106] Fixed more nits --- BUILD.bazel | 2 +- WORKSPACE | 2 +- model/BUILD.bazel | 2 +- model/src/main/proto/format_import_proto_library.bzl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index c6dcdaab5e5..9eb76c0f2e8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1 +1 @@ -#TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. \ No newline at end of file +# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index 37bf019f674..39011d55549 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -33,7 +33,7 @@ http_archive( strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, sha256 = RULES_KOTLIN_SHA, ) -#TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release +# TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies") kt_download_local_dev_dependencies() load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") diff --git a/model/BUILD.bazel b/model/BUILD.bazel index b11b2a28f91..5470f4e1126 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,4 +1,4 @@ -#TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. +# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. '''In Bazel, proto files are built using the proto_library() and java_lite_proto_library() rules. The proto_library() rule creates a proto file library to be used in multiple languages. The java_lite_proto_library() rule takes in a proto_library target and generates java code. diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 9178229782e..cc11a1c65ef 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -36,5 +36,5 @@ def format_import_proto_library(name, src, deps): native.proto_library( name = name + "_proto", srcs = ["processed_" + src], - deps = deps + deps = deps, ) From 522993ff75276f960862de874ae3da9fddc48cc4 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 13:23:23 -0400 Subject: [PATCH 057/106] Added Firebase comment --- firebase/BUILD.bazel | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/firebase/BUILD.bazel b/firebase/BUILD.bazel index f19532f58b3..e467a05e8f5 100644 --- a/firebase/BUILD.bazel +++ b/firebase/BUILD.bazel @@ -1,3 +1,7 @@ +''' Builds and exports Firebase dependencies. +To reference these dependencies, add '//firebase:crashlytics_lib' and '//firebase:crashlytics_deps' +to your build rule's dependency list. +''' load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") load("@tools_android//tools/crashlytics:defs.bzl", "crashlytics_android_library") From dfa8e0b4d7242d078c0ed4f1e28138117c8ca2f6 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 13:31:58 -0400 Subject: [PATCH 058/106] Fixed merge conflicts and nits --- testing/BUILD.bazel | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 7cbac7b31f6..2f63263668b 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -1,3 +1,4 @@ +# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") @@ -34,7 +35,6 @@ kt_android_library( ], ) - kt_android_library( name = "testing_test_lib", custom_package = "org.oppia.testing", @@ -66,6 +66,6 @@ kt_android_library( ], ) -#TODO: Add android_local_test rule +# TODO: Add android_local_test rule dagger_rules() From 9789204e063fb9cc32e388fdeed4f5005d259cdb Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 13:34:36 -0400 Subject: [PATCH 059/106] Deleted unused dependencies from testing_main_lib --- testing/BUILD.bazel | 4 ---- 1 file changed, 4 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 2f63263668b..f10b943cd1c 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -14,11 +14,7 @@ kt_android_library( ":dagger", "//model:model_lib", "//utility:utility_lib", - "@robolectric//bazel:android-all", artifact("org.robolectric:robolectric"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("com.google.truth:truth"), artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), From 364435d0ad71e7bde21441e598568f185f7ba190 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:09:29 -0400 Subject: [PATCH 060/106] Changed library name to model --- model/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 5470f4e1126..712e8d55d96 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -144,7 +144,7 @@ java_lite_proto_library( ) android_library( - name = "model_lib", + name = "model", exports = [ ":event_logger_java_proto_lite", ":example_java_proto_lite", From 7e61655fbc22b07d42cbd8407f9fe045f01fd45f Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:13:08 -0400 Subject: [PATCH 061/106] Formatted WORKSPACE comment --- WORKSPACE | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 39011d55549..b300b6807d2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,7 @@ -'''This file lists and imports all external dependencies needed to build Oppia Android. ''' +This file lists and imports all external dependencies needed to build Oppia Android. +''' + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") From 9773e663570930d93fdc0a85ecd31419c14e2524 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:22:40 -0400 Subject: [PATCH 062/106] Formatted TODO statement --- model/BUILD.bazel | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index 712e8d55d96..d24d89809db 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,8 +1,10 @@ -# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. -'''In Bazel, proto files are built using the proto_library() and java_lite_proto_library() rules. +# TODO(#1532): Rename file to 'BUILD' post-Gradle. +''' +In Bazel, proto files are built using the proto_library() and java_lite_proto_library() rules. The proto_library() rule creates a proto file library to be used in multiple languages. The java_lite_proto_library() rule takes in a proto_library target and generates java code. ''' + load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_java//java:defs.bzl", "java_lite_proto_library") load("//model:src/main/proto/format_import_proto_library.bzl", "format_import_proto_library") From 9fc0d53c8fec4e58a3ed6b74c60296653aaf53c8 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:29:40 -0400 Subject: [PATCH 063/106] Changed format_import_proto_library comment --- .../main/proto/format_import_proto_library.bzl | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index cc11a1c65ef..842072079d5 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -1,23 +1,10 @@ def format_import_proto_library(name, src, deps): - """This macro exists as a way to build proto files that contain import statements in both Gradle + """ + This macro exists as a way to build proto files that contain import statements in both Gradle and Bazel. - Currently the files that use this macro are: exploration.proto, topic.proto, and question.proto. This macro formats the src file's import statements to contain a full path to the file in order for Bazel to properly locate file. - The genrule() rule generates an altered copy of the src file for Bazel to build, leaving the - unaltered copy for Gradle to use. - The proto_library() rule takes this altered copy and builds it into a proto_library that a - java_lite_proto_library() rule can depend on. - - Args: - name: str. The name of the .proto file without the '.proto' suffix. This will be the root for - the name of the proto library created. Ex: If name = 'topic', then the src file is - 'topic.proto' and the proto library created will be named 'topic_proto'. - src: str. The name of the .proto file to be built into a proto_library. - deps: list of str. The list of dependencies needed to build the src file. This list will contain - all of the proto_library targets for the files imported into src. - """ native.genrule( From fdcb154f42957ddaeff386c7c209c991ddb5d15f Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:30:49 -0400 Subject: [PATCH 064/106] Added EOF newline --- BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.bazel b/BUILD.bazel index 9eb76c0f2e8..b24f125bab0 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1 +1 @@ -# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. \ No newline at end of file +# TODO(#1532): Rename file to 'BUILD' post-Gradle. From 8185bdd2d7000f228264df8ec9d48fc8f284ab19 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:46:31 -0400 Subject: [PATCH 065/106] Created Issue and linked TODO in WORKSPACE --- WORKSPACE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index b300b6807d2..da25584f7aa 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,9 +35,10 @@ http_archive( strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION, sha256 = RULES_KOTLIN_SHA, ) -# TODO: Remove kt_download_local_dev_dependencies() when switching to rules_kotlin release +# TODO(#1535): Remove once rules_kotlin is released because these lines become unnecessary load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies") kt_download_local_dev_dependencies() + load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") kotlin_repositories() kt_register_toolchains() From 3d21d6f7e8a512a4c352e801eac41d05ab90c358 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:56:32 -0400 Subject: [PATCH 066/106] Edited model BUILD file top comment --- model/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/model/BUILD.bazel b/model/BUILD.bazel index d24d89809db..6df71f45910 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -1,5 +1,6 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' +This library contains all protos used in the app and is a dependency for all other modules. In Bazel, proto files are built using the proto_library() and java_lite_proto_library() rules. The proto_library() rule creates a proto file library to be used in multiple languages. The java_lite_proto_library() rule takes in a proto_library target and generates java code. From 8e368b4111da92ac1f14b624ebfa846ecd2cf28e Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 17:00:02 -0400 Subject: [PATCH 067/106] Addressed nits --- model/src/main/proto/format_import_proto_library.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 842072079d5..1f6aa147033 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -1,4 +1,3 @@ - def format_import_proto_library(name, src, deps): """ This macro exists as a way to build proto files that contain import statements in both Gradle From af7832b9ba0aa3fce35d189d7c82e0e1425870e0 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 17:40:13 -0400 Subject: [PATCH 068/106] Fixed nits and added comments --- firebase/BUILD.bazel | 7 ++++++- utility/BUILD.bazel | 24 +++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/firebase/BUILD.bazel b/firebase/BUILD.bazel index e467a05e8f5..a534fcb7037 100644 --- a/firebase/BUILD.bazel +++ b/firebase/BUILD.bazel @@ -1,7 +1,10 @@ -''' Builds and exports Firebase dependencies. +# TODO(#1532): Rename file to 'BUILD' post-Gradle. +''' +Builds and exports Firebase dependencies. To reference these dependencies, add '//firebase:crashlytics_lib' and '//firebase:crashlytics_deps' to your build rule's dependency list. ''' + load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") load("@tools_android//tools/crashlytics:defs.bzl", "crashlytics_android_library") @@ -26,5 +29,7 @@ android_library( exports = [ artifact("com.crashlytics.sdk.android:crashlytics"), artifact("io.fabric.sdk.android:fabric"), + artifact("com.google.firebase:firebase-analytics:17.4.4"), + artifact("com.google.firebase:firebase-crashlytics:17.1.1"), ], ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 8ee03e698be..8ea453c283b 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -1,11 +1,19 @@ -# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. +# TODO(#1532): Rename file to 'BUILD' post-Gradle. +''' +This library contains utilities that all other modules, minus model, depend on. +It also contains Robolectric and JUnit tests for it's utilities. +In Bazel, Kotlin source files are built into a library using the kt_android_library() rule. +Kotlin test files must be built in their own kt_android_library() rule and added as a dependency to +an android_local_test() rule which configures instrumentation tests in Bazel. +''' + load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") -'''A kt_android_library() rule that builds utility module kotlin source files into a library.''' +# A kt_android_library() rule that builds utility module kotlin source files into a library. kt_android_library( - name = "utility_lib", + name = "utility", custom_package = "org.oppia.util", srcs = glob(["src/main/java/org/oppia/util/**/*.kt"], exclude = ["src/main/java/org/oppia/util/logging/firebase/*.kt"]), @@ -13,11 +21,9 @@ kt_android_library( manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - "//model:model_lib", + "//model:model", "//firebase:crashlytics_lib", "//firebase:crashlytics_deps", - artifact("com.google.firebase:firebase-analytics:17.4.4"), - artifact("com.google.firebase:firebase-crashlytics:17.1.1"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), @@ -37,6 +43,10 @@ kt_android_library( visibility = ["//visibility:public"], ) -# TODO: Get android_local_test working with kotlin files +''' +TODO: Write a kt_android_library() rule to build test files and an android_local_test() rule. +Because test files depend on the testing module source files being built, these rules have been left +for a later PR. +''' dagger_rules() From 8fb154152e6d8689082f8c54496c480e9710200f Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:06:52 -0400 Subject: [PATCH 069/106] Fixing nits --- WORKSPACE | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 6a147548481..0ec4dbada45 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -11,7 +11,6 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") android_sdk_repository( name = "androidsdk", api_level = 28, - # build_tools_version = "28.0.2", ) # Add support for JVM rules: https://github.com/bazelbuild/rules_jvm_external @@ -24,8 +23,6 @@ http_archive( url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, ) -load("@rules_jvm_external//:defs.bzl", "maven_install") - # Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin. RULES_KOTLIN_VERSION = "legacy-1.4.0-rcx-oppia-exclusive-rc01" RULES_KOTLIN_SHA = "600f3d916eda5531dd70614ec96dc92b4ac24da0e1d815eb94559976e9bea8aa" @@ -107,6 +104,7 @@ load("@tools_android//tools/googleservices:defs.bzl", "google_services_workspace google_services_workspace_dependencies() load("@rules_jvm_external//:defs.bzl", "maven_install") + # TODO: Remove unused dependencies once android_local_test errors are resolved maven_install( artifacts = DAGGER_ARTIFACTS + [ From 2b9d7c60efe201440d97c04641617ee141f2d265 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:14:35 -0400 Subject: [PATCH 070/106] Deleted unnecessary dependencies and testing example file --- testing/BUILD.bazel | 22 ---------------------- utility/BUILD.bazel | 14 +------------- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 testing/BUILD.bazel diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel deleted file mode 100644 index 94c6c0d6350..00000000000 --- a/testing/BUILD.bazel +++ /dev/null @@ -1,22 +0,0 @@ -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") -load("@rules_jvm_external//:defs.bzl", "artifact") -load("@dagger//:workspace_defs.bzl", "dagger_rules") - -package(default_visibility = ["//visibility:public"]) - -kt_android_library( - name = "testing_main_lib", - custom_package = "org.oppia.testing", - srcs = glob(["src/main/java/**/FakeSystemClock.kt"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "@robolectric//bazel:android-all", - artifact("org.robolectric:robolectric"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("androidx.appcompat:appcompat:1.0.2"), - ], - ) - -dagger_rules() diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 8ea453c283b..51f7c91712d 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -15,8 +15,7 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") kt_android_library( name = "utility", custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/**/*.kt"], - exclude = ["src/main/java/org/oppia/util/logging/firebase/*.kt"]), + srcs = glob(["src/main/java/org/oppia/util/**/*.kt"]), resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/main/AndroidManifest.xml", deps = [ @@ -25,20 +24,9 @@ kt_android_library( "//firebase:crashlytics_lib", "//firebase:crashlytics_deps", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), ], visibility = ["//visibility:public"], ) From 980ca8815fa80eade7e17f756a1edb744b7a9cd2 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:20:51 -0400 Subject: [PATCH 071/106] Fixed manifest issues --- utility/src/main/AndroidManifest.xml | 6 ++++-- utility/src/test/{TestManifest.xml => AndroidManifest.xml} | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) rename utility/src/test/{TestManifest.xml => AndroidManifest.xml} (64%) diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index 51500aa9971..4cf1c15cda0 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,3 +1,5 @@ - - + + diff --git a/utility/src/test/TestManifest.xml b/utility/src/test/AndroidManifest.xml similarity index 64% rename from utility/src/test/TestManifest.xml rename to utility/src/test/AndroidManifest.xml index ac7679afad9..4cf1c15cda0 100644 --- a/utility/src/test/TestManifest.xml +++ b/utility/src/test/AndroidManifest.xml @@ -1,6 +1,5 @@ - - From a63ad7f776039a7d5b28e3d6eff2aa2f4274131d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:40:39 -0400 Subject: [PATCH 072/106] Move google json file --- app/google-services.json | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 app/google-services.json diff --git a/app/google-services.json b/app/google-services.json deleted file mode 100644 index 5b1dc0f6672..00000000000 --- a/app/google-services.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "project_info": { - "project_number": "215533462679", - "firebase_url": "https://oppia-android-dev.firebaseio.com", - "project_id": "oppia-android-dev", - "storage_bucket": "oppia-android-dev.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:215533462679:android:a25a70347460cd014035d2", - "android_client_info": { - "package_name": "org.oppia.app" - } - }, - "oauth_client": [ - { - "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCI5yOe1vF9g_e3tcIQb64C5i64AUNT1fc" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} From fff3d8919d1bb4cf68b770ecfd543336b3dd9ba3 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:41:49 -0400 Subject: [PATCH 073/106] Restore app version of json --- app/google-services.json | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/google-services.json diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 00000000000..5b1dc0f6672 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "215533462679", + "firebase_url": "https://oppia-android-dev.firebaseio.com", + "project_id": "oppia-android-dev", + "storage_bucket": "oppia-android-dev.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:215533462679:android:a25a70347460cd014035d2", + "android_client_info": { + "package_name": "org.oppia.app" + } + }, + "oauth_client": [ + { + "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCI5yOe1vF9g_e3tcIQb64C5i64AUNT1fc" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} From c7cad13cec090463f05d690d04a8c1f4e0ddba13 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:50:40 -0400 Subject: [PATCH 074/106] Edit TODO --- utility/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 51f7c91712d..4a6c6a6b995 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -32,7 +32,7 @@ kt_android_library( ) ''' -TODO: Write a kt_android_library() rule to build test files and an android_local_test() rule. +TODO(#59): Write a kt_android_library() rule to build test files and an android_local_test() rule. Because test files depend on the testing module source files being built, these rules have been left for a later PR. ''' From 654328eb4c84141bb788208f7ab472b4c4bd564c Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:53:59 -0400 Subject: [PATCH 075/106] Deleted TODO --- WORKSPACE | 1 - 1 file changed, 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 0ec4dbada45..1e14692a43b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -105,7 +105,6 @@ google_services_workspace_dependencies() load("@rules_jvm_external//:defs.bzl", "maven_install") -# TODO: Remove unused dependencies once android_local_test errors are resolved maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.3", From a842aec2ca68959a4f73d4c6039597bb77d72ddf Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 18:56:47 -0400 Subject: [PATCH 076/106] Changed Firebase comment --- firebase/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase/BUILD.bazel b/firebase/BUILD.bazel index a534fcb7037..763c9d5509c 100644 --- a/firebase/BUILD.bazel +++ b/firebase/BUILD.bazel @@ -1,6 +1,6 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' -Builds and exports Firebase dependencies. +Package for all Firebase dependencies. To reference these dependencies, add '//firebase:crashlytics_lib' and '//firebase:crashlytics_deps' to your build rule's dependency list. ''' From 9360972616e284b610f6316855f87d741a0fe507 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 11:13:39 -0400 Subject: [PATCH 077/106] Added testing functionality from later PR --- WORKSPACE | 5 ++- oppia_android_test.bzl | 30 +++++++++++++ testing/BUILD.bazel | 64 ++++++++++------------------ testing/src/test/AndroidManifest.xml | 5 +++ testing/testing_test.bzl | 13 ++++++ 5 files changed, 75 insertions(+), 42 deletions(-) create mode 100644 oppia_android_test.bzl create mode 100644 testing/src/test/AndroidManifest.xml create mode 100644 testing/testing_test.bzl diff --git a/WORKSPACE b/WORKSPACE index 1e14692a43b..3294d55a644 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -108,11 +108,13 @@ load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.3", + "org.robolectric:annotations:4.3", "androidx.appcompat:appcompat:1.0.2", + "androidx.annotation:annotation:1.1.0", "com.android.support:support-annotations:28.0.0", "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", + "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8", "androidx.core:core-ktx:1.0.1", - "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", "junit:junit:4.12", "com.google.truth:truth:0.43", "com.github.bumptech.glide:glide:4.11.0", @@ -132,6 +134,7 @@ maven_install( "io.fabric.sdk.android:fabric:1.4.7", "com.google.firebase:firebase-analytics:17.4.4", "com.google.firebase:firebase-crashlytics:17.1.1", + "org.jetbrains.kotlin:kotlin-reflect:1.3.41", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl new file mode 100644 index 00000000000..92638f3466a --- /dev/null +++ b/oppia_android_test.bzl @@ -0,0 +1,30 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") + +def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files, + test_class, src_library_name): + + kt_android_library( + name = name + "_lib", + custom_package = custom_package, + srcs = srcs, + resource_files = resource_files, + manifest = test_manifest, + deps = [ + ":" + src_library_name, + ], + ) + + native.android_local_test( + name = name, + custom_package = custom_package, + test_class = test_class, + manifest = test_manifest, + deps = [ + ":" + name + "_lib", + ":dagger", + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), + artifact("org.robolectric:robolectric"), + ], + ) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index f10b943cd1c..c98d496cfa2 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -1,67 +1,49 @@ -# TODO: Rename file to 'BUILD' post-Gradle. See https://github.com/oppia/oppia-android/issues/1532. +# TODO(#1532): Rename file to 'BUILD' post-Gradle. +''' + +''' load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") - -package(default_visibility = ["//visibility:public"]) +load("//:oppia_android_test.bzl", "oppia_android_test") +load("//testing:testing_test.bzl", "testing_test") kt_android_library( - name = "testing_main_lib", + name = "testing", custom_package = "org.oppia.testing", srcs = glob(["src/main/java/**/*.kt"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - "//model:model_lib", - "//utility:utility_lib", + "//utility:utility", + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("org.robolectric:robolectric"), - artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), ], ) kt_android_library( - name = "testing_test_lib", + name = "testing_tests", custom_package = "org.oppia.testing", - srcs = glob(["src/test/java/**/*.kt"]), + srcs = glob(["src/test/java/org/oppia/testing/*.kt"]), manifest = "src/main/AndroidManifest.xml", deps = [ - ":testing_main_lib", + ":testing", ":dagger", - "//model:model_lib", - "//utility:utility_lib", - "@robolectric//bazel:android-all", - artifact("org.robolectric:robolectric"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("com.google.truth:truth"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.github.bumptech.glide:compiler"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), - artifact("com.google.firebase:firebase-analytics-ktx"), - artifact("com.crashlytics.sdk.android:crashlytics:2.9.8"), - artifact("io.fabric.sdk.android:fabric:1.4.7"), - artifact("com.google.gms:google-services:4.3.3"), - artifact("com.android.support:support-annotations"), artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), ], ) -# TODO: Add android_local_test rule +testing_test( + name = "FakeEventLoggerTest", + src = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], + test_class = "org.oppia.testing.FakeEventLoggerTest", +) + +testing_test( + name = "FakeExceptionLoggerTest", + src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], + test_class = "org.oppia.testing.FakeExceptionLoggerTest", +) dagger_rules() diff --git a/testing/src/test/AndroidManifest.xml b/testing/src/test/AndroidManifest.xml new file mode 100644 index 00000000000..0912e38fbe1 --- /dev/null +++ b/testing/src/test/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl new file mode 100644 index 00000000000..38504bbc9ee --- /dev/null +++ b/testing/testing_test.bzl @@ -0,0 +1,13 @@ +load("//:oppia_android_test.bzl", "oppia_android_test") + +def testing_test(name, src, test_class): + + oppia_android_test( + name = name, + srcs = src, + resource_files = native.glob(["src/main/res/**/*.xml"]), + src_library_name = "testing_tests", + custom_package = "org.oppia.testing", + test_class = test_class, + test_manifest = "src/test/AndroidManifest.xml", + ) From 705d1952b993c77bebd9b6bab472848acdf48ff5 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 11:40:26 -0400 Subject: [PATCH 078/106] Added comments to bzl files --- oppia_android_test.bzl | 51 ++++++++++++++++++++++------------------ testing/BUILD.bazel | 10 +++++++- testing/testing_test.bzl | 23 +++++++++++------- 3 files changed, 51 insertions(+), 33 deletions(-) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 92638f3466a..2921c575598 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -3,28 +3,33 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files, test_class, src_library_name): + """ + This macro exists as a way to set up a test in Oppia Android to be run with Bazel. + This macro creates a library for an individual test that is fed as a dependency into an + android_local_test() rule which configures the test to be run with Roboletric and Bazel. + """ - kt_android_library( - name = name + "_lib", - custom_package = custom_package, - srcs = srcs, - resource_files = resource_files, - manifest = test_manifest, - deps = [ - ":" + src_library_name, - ], - ) + kt_android_library( + name = name + "_lib", + custom_package = custom_package, + srcs = srcs, + resource_files = resource_files, + manifest = test_manifest, + deps = [ + ":" + src_library_name, + ], + ) - native.android_local_test( - name = name, - custom_package = custom_package, - test_class = test_class, - manifest = test_manifest, - deps = [ - ":" + name + "_lib", - ":dagger", - "@robolectric//bazel:android-all", - artifact("org.jetbrains.kotlin:kotlin-reflect"), - artifact("org.robolectric:robolectric"), - ], - ) + native.android_local_test( + name = name, + custom_package = custom_package, + test_class = test_class, + manifest = test_manifest, + deps = [ + ":" + name + "_lib", + ":dagger", + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), + artifact("org.robolectric:robolectric"), + ], + ) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index c98d496cfa2..4ee48824d75 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -1,7 +1,13 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' - +This library contains fake objects used for testing as well as tests for these objects. +In Bazel, Kotlin source files are built into a library using the kt_android_library() rule. +Individual Kotlin test files must be built in their own kt_android_library() rules and added as a +dependency to an android_local_test() rule which configures instrumentation tests in Bazel. +In order to eliminate duplicate code, a custom macro testing_test() has been written to streamline +testing in this module. ''' + load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") @@ -19,6 +25,7 @@ kt_android_library( artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("org.robolectric:robolectric"), ], + visibility = ["//visibility:public"], ) kt_android_library( @@ -32,6 +39,7 @@ kt_android_library( artifact("com.google.truth:truth"), artifact("androidx.test.ext:junit"), ], + visibility = ["//visibility:public"], ) testing_test( diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl index 38504bbc9ee..44d1556bfc1 100644 --- a/testing/testing_test.bzl +++ b/testing/testing_test.bzl @@ -1,13 +1,18 @@ load("//:oppia_android_test.bzl", "oppia_android_test") def testing_test(name, src, test_class): + ''' + This macro exists as a way to customize the oppia_android_test() macro for the testing module. + This macro calls the oppia_android_test() macro such that the only necessary parameters for this + macro are the parameters specific to the individual test being run. + ''' - oppia_android_test( - name = name, - srcs = src, - resource_files = native.glob(["src/main/res/**/*.xml"]), - src_library_name = "testing_tests", - custom_package = "org.oppia.testing", - test_class = test_class, - test_manifest = "src/test/AndroidManifest.xml", - ) + oppia_android_test( + name = name, + srcs = src, + resource_files = native.glob(["src/main/res/**/*.xml"]), + src_library_name = "testing_tests", + custom_package = "org.oppia.testing", + test_class = test_class, + test_manifest = "src/test/AndroidManifest.xml", + ) From 2b7be7301af532c391e0f039b5165b506b0bb553 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 11:46:50 -0400 Subject: [PATCH 079/106] Added targetSDK to manifests --- utility/BUILD.bazel | 4 ++-- utility/src/main/AndroidManifest.xml | 2 +- utility/src/test/AndroidManifest.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 4a6c6a6b995..721e0fe6c69 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -11,7 +11,7 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") -# A kt_android_library() rule that builds utility module kotlin source files into a library. +# Library for general-purpose utilities. kt_android_library( name = "utility", custom_package = "org.oppia.util", @@ -20,7 +20,7 @@ kt_android_library( manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - "//model:model", + "//model", "//firebase:crashlytics_lib", "//firebase:crashlytics_deps", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index 4cf1c15cda0..0e527c3295d 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="28" /> diff --git a/utility/src/test/AndroidManifest.xml b/utility/src/test/AndroidManifest.xml index 4cf1c15cda0..0e527c3295d 100644 --- a/utility/src/test/AndroidManifest.xml +++ b/utility/src/test/AndroidManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="28" /> From 062174477df03584868ec479bc62370c76353f2a Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 11:51:55 -0400 Subject: [PATCH 080/106] Changed crashlytics_lib to crashlytics --- firebase/BUILD.bazel | 4 ++-- utility/BUILD.bazel | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firebase/BUILD.bazel b/firebase/BUILD.bazel index 763c9d5509c..15ea0e8097f 100644 --- a/firebase/BUILD.bazel +++ b/firebase/BUILD.bazel @@ -1,7 +1,7 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' Package for all Firebase dependencies. -To reference these dependencies, add '//firebase:crashlytics_lib' and '//firebase:crashlytics_deps' +To reference these dependencies, add '//firebase:crashlytics' and '//firebase:crashlytics_deps' to your build rule's dependency list. ''' @@ -18,7 +18,7 @@ GOOGLE_SERVICES_RESOURCES = google_services_xml( ) crashlytics_android_library( - name = "crashlytics_lib", + name = "crashlytics", package_name = "org.oppia.app", build_id = "48fc9d17-e102-444c-8e0d-638d75ec0942", resource_files = GOOGLE_SERVICES_RESOURCES, diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 721e0fe6c69..0a6f147ffa5 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -21,7 +21,7 @@ kt_android_library( deps = [ ":dagger", "//model", - "//firebase:crashlytics_lib", + "//firebase:crashlytics", "//firebase:crashlytics_deps", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("androidx.appcompat:appcompat"), From af931e96057a38d8d29b9fb547a457272bff6f95 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 12:02:17 -0400 Subject: [PATCH 081/106] Changed testing_tests visibility --- testing/BUILD.bazel | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 4ee48824d75..723a23c2b17 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -14,6 +14,7 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") load("//:oppia_android_test.bzl", "oppia_android_test") load("//testing:testing_test.bzl", "testing_test") +# Library for general-purpose testing fakes. kt_android_library( name = "testing", custom_package = "org.oppia.testing", @@ -21,13 +22,14 @@ kt_android_library( manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - "//utility:utility", + "//utility", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("org.robolectric:robolectric"), ], visibility = ["//visibility:public"], ) +# Library for tests of testing fakes. kt_android_library( name = "testing_tests", custom_package = "org.oppia.testing", @@ -39,7 +41,7 @@ kt_android_library( artifact("com.google.truth:truth"), artifact("androidx.test.ext:junit"), ], - visibility = ["//visibility:public"], + visibility = ["//visibility:private"], ) testing_test( From 0b9c14ae550c5ba27e0779530c3aabd07fd8112a Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 12:30:43 -0400 Subject: [PATCH 082/106] Changed type of comment ticks --- oppia_android_test.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 2921c575598..427dd6c9dc4 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -3,11 +3,11 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files, test_class, src_library_name): - """ + ''' This macro exists as a way to set up a test in Oppia Android to be run with Bazel. This macro creates a library for an individual test that is fed as a dependency into an android_local_test() rule which configures the test to be run with Roboletric and Bazel. - """ + ''' kt_android_library( name = name + "_lib", From 65f13c1c904f1cdc514a83b414007db71a9ca796 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 18:48:42 -0400 Subject: [PATCH 083/106] Fixed nits and added TODOs --- BUILD.bazel | 1 - WORKSPACE | 1 + .../src/main/proto/format_import_proto_library.bzl | 13 +++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) delete mode 100644 BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel deleted file mode 100644 index b24f125bab0..00000000000 --- a/BUILD.bazel +++ /dev/null @@ -1 +0,0 @@ -# TODO(#1532): Rename file to 'BUILD' post-Gradle. diff --git a/WORKSPACE b/WORKSPACE index da25584f7aa..2d07384aba8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -7,6 +7,7 @@ load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") # Android SDK configuration. For more details, see: # https://docs.bazel.build/versions/master/be/android.html#android_sdk_repository +# TODO(#1542): Sync Android SDK version with the manifest. android_sdk_repository( name = "androidsdk", api_level = 28, diff --git a/model/src/main/proto/format_import_proto_library.bzl b/model/src/main/proto/format_import_proto_library.bzl index 1f6aa147033..dbbb7bbcfd8 100644 --- a/model/src/main/proto/format_import_proto_library.bzl +++ b/model/src/main/proto/format_import_proto_library.bzl @@ -1,11 +1,20 @@ def format_import_proto_library(name, src, deps): - """ + ''' This macro exists as a way to build proto files that contain import statements in both Gradle and Bazel. This macro formats the src file's import statements to contain a full path to the file in order for Bazel to properly locate file. - """ + Args: + name: str. The name of the .proto file without the '.proto' suffix. This will be the root for + the name of the proto library created. Ex: If name = 'topic', then the src file is + 'topic.proto' and the proto library created will be named 'topic_proto'. + src: str. The name of the .proto file to be built into a proto_library. + deps: list of str. The list of dependencies needed to build the src file. This list will contain + all of the proto_library targets for the files imported into src. + ''' + + # TODO(#1543): Ensure this function works on Windows systems. native.genrule( name = name, srcs = [src], From f466e8f8b58d549dd41b13a5cce0bbc08697d3c6 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 19:10:44 -0400 Subject: [PATCH 084/106] Added Args to document comment --- oppia_android_test.bzl | 10 ++++++++++ testing/testing_test.bzl | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 427dd6c9dc4..9abc36b7c71 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -7,6 +7,16 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files This macro exists as a way to set up a test in Oppia Android to be run with Bazel. This macro creates a library for an individual test that is fed as a dependency into an android_local_test() rule which configures the test to be run with Roboletric and Bazel. + + Args: + name: str. The name of the Kotlin test file without the '.kt' suffix. + srcs: str. The name of the Kotlin test file to be run. + test_manifest: str. The path to the test manifest file. + custom_package: str. The module's package. Example: 'org.oppia.utility'. + resource_files: str. The path to the resource files. This is typically a glob([]). + test_class: The package of the src file. For example, if the src is 'FakeEventLoggerTest.kt', + then the test_class would be "org.oppia.testing.FakeEventLoggerTest". + src_library_name: str. The name of the library that builds the module's test files. ''' kt_android_library( diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl index 44d1556bfc1..c2fadfb5bc3 100644 --- a/testing/testing_test.bzl +++ b/testing/testing_test.bzl @@ -5,6 +5,12 @@ def testing_test(name, src, test_class): This macro exists as a way to customize the oppia_android_test() macro for the testing module. This macro calls the oppia_android_test() macro such that the only necessary parameters for this macro are the parameters specific to the individual test being run. + + Args: + name: str. The name of the Kotlin test file without the '.kt' suffix. + src: str. The name of the Kotlin test file to be run. + test_class: str. The package of the src file. Example: If the src is 'FakeEventLoggerTest.kt', + then the test_class would be "org.oppia.testing.FakeEventLoggerTest". ''' oppia_android_test( From 58752b41dc66adf3d918a5da56c7a6657cb253da Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 30 Jul 2020 11:22:20 -0400 Subject: [PATCH 085/106] Changed targetSDK to 29 --- utility/src/main/AndroidManifest.xml | 2 +- utility/src/test/AndroidManifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index 0e527c3295d..6d4711a80a6 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="29" /> diff --git a/utility/src/test/AndroidManifest.xml b/utility/src/test/AndroidManifest.xml index 0e527c3295d..6d4711a80a6 100644 --- a/utility/src/test/AndroidManifest.xml +++ b/utility/src/test/AndroidManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="29" /> From d152713517887a2c5f6185fb12d4dfa94113e18b Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 30 Jul 2020 11:24:17 -0400 Subject: [PATCH 086/106] Formatted TODO --- utility/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 0a6f147ffa5..35f11e4fd49 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -31,8 +31,8 @@ kt_android_library( visibility = ["//visibility:public"], ) +# TODO(#59): Write a kt_android_library() rule to build test files and an android_local_test() rule. ''' -TODO(#59): Write a kt_android_library() rule to build test files and an android_local_test() rule. Because test files depend on the testing module source files being built, these rules have been left for a later PR. ''' From 74e4e52abde967328afab452413ec5a670814173 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 30 Jul 2020 13:45:28 -0400 Subject: [PATCH 087/106] Moved google-services.json --- app/google-services.json | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 app/google-services.json diff --git a/app/google-services.json b/app/google-services.json deleted file mode 100644 index 5b1dc0f6672..00000000000 --- a/app/google-services.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "project_info": { - "project_number": "215533462679", - "firebase_url": "https://oppia-android-dev.firebaseio.com", - "project_id": "oppia-android-dev", - "storage_bucket": "oppia-android-dev.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:215533462679:android:a25a70347460cd014035d2", - "android_client_info": { - "package_name": "org.oppia.app" - } - }, - "oauth_client": [ - { - "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCI5yOe1vF9g_e3tcIQb64C5i64AUNT1fc" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} From 0c9d1975efa796169be2ae138408d634b7d64363 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 30 Jul 2020 14:05:24 -0400 Subject: [PATCH 088/106] Added gogle-services.json back to app --- app/google-services.json | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/google-services.json diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 00000000000..5b1dc0f6672 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "215533462679", + "firebase_url": "https://oppia-android-dev.firebaseio.com", + "project_id": "oppia-android-dev", + "storage_bucket": "oppia-android-dev.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:215533462679:android:a25a70347460cd014035d2", + "android_client_info": { + "package_name": "org.oppia.app" + } + }, + "oauth_client": [ + { + "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCI5yOe1vF9g_e3tcIQb64C5i64AUNT1fc" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} From 72e0acd88aead0e963204c391ac416aef75d6159 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 31 Jul 2020 16:43:27 -0400 Subject: [PATCH 089/106] Trying to remove combined testing library --- BUILD.bazel | 0 oppia_android_test.bzl | 20 ++++++-------------- testing/BUILD.bazel | 30 ++++++++++++++++++++++++++++++ testing/testing_test.bzl | 5 +++-- 4 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 00000000000..e69de29bb2d diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 9abc36b7c71..e99cf6271e6 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -2,11 +2,10 @@ load("@rules_jvm_external//:defs.bzl", "artifact") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files, - test_class, src_library_name): + test_class, deps): #src_library_name): ''' - This macro exists as a way to set up a test in Oppia Android to be run with Bazel. - This macro creates a library for an individual test that is fed as a dependency into an - android_local_test() rule which configures the test to be run with Roboletric and Bazel. + Creates an Oppia test target for running the specified test as an Android local test with Kotlin + support. Note that this creates an additional, internal library. Args: name: str. The name of the Kotlin test file without the '.kt' suffix. @@ -25,9 +24,8 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files srcs = srcs, resource_files = resource_files, manifest = test_manifest, - deps = [ - ":" + src_library_name, - ], + deps = deps, + testonly = True, ) native.android_local_test( @@ -35,11 +33,5 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files custom_package = custom_package, test_class = test_class, manifest = test_manifest, - deps = [ - ":" + name + "_lib", - ":dagger", - "@robolectric//bazel:android-all", - artifact("org.jetbrains.kotlin:kotlin-reflect"), - artifact("org.robolectric:robolectric"), - ], + deps = [ ":" + name + "_lib",] + deps, ) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 723a23c2b17..5df02dda336 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -44,16 +44,46 @@ kt_android_library( visibility = ["//visibility:private"], ) +DEPS = [ + #"testing_tests", + ":FakeExceptionLoggerTest_lib", + ":dagger", + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), + artifact("org.robolectric:robolectric"), + ":testing", + "//utility", + "//model", + artifact("com.google.truth:truth"), + artifact("androidx.test.ext:junit"), +] + +DEPS2 = [ + #"testing_tests", + ":dagger", + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), + artifact("org.robolectric:robolectric"), + ":testing", + "//utility", + "//model", + artifact("com.google.truth:truth"), + artifact("androidx.test.ext:junit"), +] + + testing_test( name = "FakeEventLoggerTest", src = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], test_class = "org.oppia.testing.FakeEventLoggerTest", + deps = DEPS, ) testing_test( name = "FakeExceptionLoggerTest", src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], test_class = "org.oppia.testing.FakeExceptionLoggerTest", + deps = DEPS2, ) dagger_rules() diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl index c2fadfb5bc3..a57884bb575 100644 --- a/testing/testing_test.bzl +++ b/testing/testing_test.bzl @@ -1,6 +1,6 @@ load("//:oppia_android_test.bzl", "oppia_android_test") -def testing_test(name, src, test_class): +def testing_test(name, src, test_class, deps): ''' This macro exists as a way to customize the oppia_android_test() macro for the testing module. This macro calls the oppia_android_test() macro such that the only necessary parameters for this @@ -17,8 +17,9 @@ def testing_test(name, src, test_class): name = name, srcs = src, resource_files = native.glob(["src/main/res/**/*.xml"]), - src_library_name = "testing_tests", + #src_library_name = "testing_tests", custom_package = "org.oppia.testing", test_class = test_class, test_manifest = "src/test/AndroidManifest.xml", + deps = deps, ) From 0aa646d9ac865beab281604c91e53be0be1fe135 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 10:15:41 -0400 Subject: [PATCH 090/106] Changed targetSDK to 29 --- testing/src/test/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/src/test/AndroidManifest.xml b/testing/src/test/AndroidManifest.xml index 0912e38fbe1..866b17b8a84 100644 --- a/testing/src/test/AndroidManifest.xml +++ b/testing/src/test/AndroidManifest.xml @@ -1,5 +1,5 @@ + android:maxSdkVersion="29" /> From 7660d7d85b65c1b9981fbc454e88162e6db3f4cd Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 10:48:42 -0400 Subject: [PATCH 091/106] Tests pass now with deps passed in. --- oppia_android_test.bzl | 2 +- testing/BUILD.bazel | 80 +++++++++++++--------------- testing/testing_test.bzl | 3 +- utility/src/main/AndroidManifest.xml | 2 +- 4 files changed, 40 insertions(+), 47 deletions(-) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index e99cf6271e6..6844420049d 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -2,7 +2,7 @@ load("@rules_jvm_external//:defs.bzl", "artifact") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files, - test_class, deps): #src_library_name): + test_class, deps): ''' Creates an Oppia test target for running the specified test as an Android local test with Kotlin support. Note that this creates an additional, internal library. diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 5df02dda336..686f5e5bb9b 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -18,7 +18,7 @@ load("//testing:testing_test.bzl", "testing_test") kt_android_library( name = "testing", custom_package = "org.oppia.testing", - srcs = glob(["src/main/java/**/*.kt"]), + srcs = glob(["src/main/java/org/oppia/testing/*.kt"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", @@ -30,60 +30,52 @@ kt_android_library( ) # Library for tests of testing fakes. -kt_android_library( - name = "testing_tests", - custom_package = "org.oppia.testing", - srcs = glob(["src/test/java/org/oppia/testing/*.kt"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":testing", - ":dagger", - artifact("com.google.truth:truth"), - artifact("androidx.test.ext:junit"), - ], - visibility = ["//visibility:private"], -) - -DEPS = [ - #"testing_tests", - ":FakeExceptionLoggerTest_lib", - ":dagger", - "@robolectric//bazel:android-all", - artifact("org.jetbrains.kotlin:kotlin-reflect"), - artifact("org.robolectric:robolectric"), - ":testing", - "//utility", - "//model", - artifact("com.google.truth:truth"), - artifact("androidx.test.ext:junit"), -] - -DEPS2 = [ - #"testing_tests", - ":dagger", - "@robolectric//bazel:android-all", - artifact("org.jetbrains.kotlin:kotlin-reflect"), - artifact("org.robolectric:robolectric"), - ":testing", - "//utility", - "//model", - artifact("com.google.truth:truth"), - artifact("androidx.test.ext:junit"), -] - +#kt_android_library( +# name = "testing_tests", +# custom_package = "org.oppia.testing", +# srcs = glob(["src/test/java/org/oppia/testing/*.kt"]), +# manifest = "src/main/AndroidManifest.xml", +# deps = [ +# ":testing", +# ":dagger", +# artifact("com.google.truth:truth"), +# artifact("androidx.test.ext:junit"), +# ], +# visibility = ["//visibility:private"], +#) testing_test( name = "FakeEventLoggerTest", src = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], test_class = "org.oppia.testing.FakeEventLoggerTest", - deps = DEPS, + deps = [ + ":testing", + ":dagger", + # "//utility", + # "//model", + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), +# artifact("org.robolectric:robolectric"), + artifact("com.google.truth:truth"), + artifact("androidx.test.ext:junit"), + ], ) testing_test( name = "FakeExceptionLoggerTest", src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], test_class = "org.oppia.testing.FakeExceptionLoggerTest", - deps = DEPS2, + deps = [ + ":dagger", + ":testing", +# "//utility", +# "//model", + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), + #artifact("org.robolectric:robolectric"), + artifact("com.google.truth:truth"), + artifact("androidx.test.ext:junit"), + ], ) dagger_rules() diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl index a57884bb575..9e3531a48a8 100644 --- a/testing/testing_test.bzl +++ b/testing/testing_test.bzl @@ -8,9 +8,10 @@ def testing_test(name, src, test_class, deps): Args: name: str. The name of the Kotlin test file without the '.kt' suffix. - src: str. The name of the Kotlin test file to be run. + src: list of str. The list of test files to be run. test_class: str. The package of the src file. Example: If the src is 'FakeEventLoggerTest.kt', then the test_class would be "org.oppia.testing.FakeEventLoggerTest". + deps: list of str. The list of dependencies needed to build and run this test. ''' oppia_android_test( diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index 6d4711a80a6..c1709cdb835 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - From 8aa8c597c9fda2bfd34dedbf98aed936e61c507d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 10:50:02 -0400 Subject: [PATCH 092/106] Created TEST_DEPS list to avoid duplicate list of dependencies --- testing/BUILD.bazel | 46 ++++++++++----------------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 686f5e5bb9b..86a4fbae85a 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -29,53 +29,27 @@ kt_android_library( visibility = ["//visibility:public"], ) -# Library for tests of testing fakes. -#kt_android_library( -# name = "testing_tests", -# custom_package = "org.oppia.testing", -# srcs = glob(["src/test/java/org/oppia/testing/*.kt"]), -# manifest = "src/main/AndroidManifest.xml", -# deps = [ -# ":testing", -# ":dagger", -# artifact("com.google.truth:truth"), -# artifact("androidx.test.ext:junit"), -# ], -# visibility = ["//visibility:private"], -#) +TEST_DEPS = [ + ":testing", + ":dagger", + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), + artifact("com.google.truth:truth"), + artifact("androidx.test.ext:junit"), +] testing_test( name = "FakeEventLoggerTest", src = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], test_class = "org.oppia.testing.FakeEventLoggerTest", - deps = [ - ":testing", - ":dagger", - # "//utility", - # "//model", - "@robolectric//bazel:android-all", - artifact("org.jetbrains.kotlin:kotlin-reflect"), -# artifact("org.robolectric:robolectric"), - artifact("com.google.truth:truth"), - artifact("androidx.test.ext:junit"), - ], + deps = TEST_DEPS, ) testing_test( name = "FakeExceptionLoggerTest", src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], test_class = "org.oppia.testing.FakeExceptionLoggerTest", - deps = [ - ":dagger", - ":testing", -# "//utility", -# "//model", - "@robolectric//bazel:android-all", - artifact("org.jetbrains.kotlin:kotlin-reflect"), - #artifact("org.robolectric:robolectric"), - artifact("com.google.truth:truth"), - artifact("androidx.test.ext:junit"), - ], + deps = TEST_DEPS, ) dagger_rules() From d4f53c443fdc4eed0c8b14f328e8c09a256bd6d4 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 10:53:24 -0400 Subject: [PATCH 093/106] Removed unused resources and manifest --- oppia_android_test.bzl | 4 +--- testing/testing_test.bzl | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 6844420049d..ee4d2f56b09 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -1,7 +1,7 @@ load("@rules_jvm_external//:defs.bzl", "artifact") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") -def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files, +def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, deps): ''' Creates an Oppia test target for running the specified test as an Android local test with Kotlin @@ -22,8 +22,6 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files name = name + "_lib", custom_package = custom_package, srcs = srcs, - resource_files = resource_files, - manifest = test_manifest, deps = deps, testonly = True, ) diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl index 9e3531a48a8..d8288cdc2f5 100644 --- a/testing/testing_test.bzl +++ b/testing/testing_test.bzl @@ -17,8 +17,6 @@ def testing_test(name, src, test_class, deps): oppia_android_test( name = name, srcs = src, - resource_files = native.glob(["src/main/res/**/*.xml"]), - #src_library_name = "testing_tests", custom_package = "org.oppia.testing", test_class = test_class, test_manifest = "src/test/AndroidManifest.xml", From a275d9c5d8078a5d2f9b3706f703c03814deb15d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 10:54:13 -0400 Subject: [PATCH 094/106] Updated comments to reflect changes --- oppia_android_test.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index ee4d2f56b09..245fbc318b3 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -12,7 +12,6 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, srcs: str. The name of the Kotlin test file to be run. test_manifest: str. The path to the test manifest file. custom_package: str. The module's package. Example: 'org.oppia.utility'. - resource_files: str. The path to the resource files. This is typically a glob([]). test_class: The package of the src file. For example, if the src is 'FakeEventLoggerTest.kt', then the test_class would be "org.oppia.testing.FakeEventLoggerTest". src_library_name: str. The name of the library that builds the module's test files. From 297cfa1617b4de66809d8a5dbf70dbf4cb85af92 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 11:39:54 -0400 Subject: [PATCH 095/106] Updated comment for testing_test --- testing/testing_test.bzl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl index d8288cdc2f5..f0c621aa150 100644 --- a/testing/testing_test.bzl +++ b/testing/testing_test.bzl @@ -2,9 +2,7 @@ load("//:oppia_android_test.bzl", "oppia_android_test") def testing_test(name, src, test_class, deps): ''' - This macro exists as a way to customize the oppia_android_test() macro for the testing module. - This macro calls the oppia_android_test() macro such that the only necessary parameters for this - macro are the parameters specific to the individual test being run. + Creates individual tests for test files in the testing module. Args: name: str. The name of the Kotlin test file without the '.kt' suffix. From 51bcc06f2705537a0a7a1cd563d0aac3fe7ccb49 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 11:46:12 -0400 Subject: [PATCH 096/106] Formatted dependencies and removed unused dependency --- WORKSPACE | 27 ++++++++++++--------------- firebase/BUILD.bazel | 4 ++-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 50948d9dfb1..da73f1aea27 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -109,30 +109,27 @@ load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = DAGGER_ARTIFACTS + [ "org.robolectric:robolectric:4.3", + "org.robolectric:annotations:4.3", "androidx.appcompat:appcompat:1.0.2", + "androidx.core:core-ktx:1.0.1", + "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03", + "androidx.test.ext:junit:1.1.1", "com.android.support:support-annotations:28.0.0", "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", - "androidx.core:core-ktx:1.0.1", "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", - "junit:junit:4.12", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", + "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", "com.google.truth:truth:0.43", - "com.github.bumptech.glide:glide:4.11.0", - "com.github.bumptech.glide:compiler:4.11.0", - "com.caverock:androidsvg-aar:1.4", - "com.crashlytics.sdk.android:crashlytics:2.9.8", - "io.fabric.sdk.android:fabric:1.4.7", "com.google.gms:google-services:4.3.3", - "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03", "com.google.firebase:firebase-analytics-ktx:17.4.2", - "org.mockito:mockito-core:2.19.0", - "androidx.test.ext:junit:1.1.1", - "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", - "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", - "org.robolectric:annotations:4.3", - "com.crashlytics.sdk.android:crashlytics:2.9.8", - "io.fabric.sdk.android:fabric:1.4.7", "com.google.firebase:firebase-analytics:17.4.4", "com.google.firebase:firebase-crashlytics:17.1.1", + "com.crashlytics.sdk.android:crashlytics:2.9.8", + "io.fabric.sdk.android:fabric:1.4.7", + "com.github.bumptech.glide:glide:4.11.0", + "com.caverock:androidsvg-aar:1.4", + "org.mockito:mockito-core:2.19.0", + "junit:junit:4.12", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", diff --git a/firebase/BUILD.bazel b/firebase/BUILD.bazel index 15ea0e8097f..30e5c7be7b0 100644 --- a/firebase/BUILD.bazel +++ b/firebase/BUILD.bazel @@ -29,7 +29,7 @@ android_library( exports = [ artifact("com.crashlytics.sdk.android:crashlytics"), artifact("io.fabric.sdk.android:fabric"), - artifact("com.google.firebase:firebase-analytics:17.4.4"), - artifact("com.google.firebase:firebase-crashlytics:17.1.1"), + artifact("com.google.firebase:firebase-analytics"), + artifact("com.google.firebase:firebase-crashlytics"), ], ) From fd4386fe2913d635896fbb22565dd8cfa7530d21 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 11:55:03 -0400 Subject: [PATCH 097/106] Updated dependency list --- WORKSPACE | 2 -- 1 file changed, 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index da73f1aea27..b63c57dc6a4 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -120,8 +120,6 @@ maven_install( "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", "com.google.truth:truth:0.43", - "com.google.gms:google-services:4.3.3", - "com.google.firebase:firebase-analytics-ktx:17.4.2", "com.google.firebase:firebase-analytics:17.4.4", "com.google.firebase:firebase-crashlytics:17.1.1", "com.crashlytics.sdk.android:crashlytics:2.9.8", From 33d8e2a0f64ef8466424d68879b682011a88ef8d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 11:57:43 -0400 Subject: [PATCH 098/106] Header for oppia_android_test now fits on one line --- oppia_android_test.bzl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 245fbc318b3..a251ee7d609 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -1,8 +1,7 @@ load("@rules_jvm_external//:defs.bzl", "artifact") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") -def oppia_android_test(name, srcs, test_manifest, custom_package, - test_class, deps): +def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, deps): ''' Creates an Oppia test target for running the specified test as an Android local test with Kotlin support. Note that this creates an additional, internal library. From 1294d081b91783157f7aaebc481084d5204871e4 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 12:16:57 -0400 Subject: [PATCH 099/106] Edited documentation for oppia_android_test --- oppia_android_test.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index a251ee7d609..b65be3406e1 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -8,12 +8,12 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, de Args: name: str. The name of the Kotlin test file without the '.kt' suffix. - srcs: str. The name of the Kotlin test file to be run. + srcs: list of str. The name of the Kotlin test files to be run. test_manifest: str. The path to the test manifest file. custom_package: str. The module's package. Example: 'org.oppia.utility'. test_class: The package of the src file. For example, if the src is 'FakeEventLoggerTest.kt', then the test_class would be "org.oppia.testing.FakeEventLoggerTest". - src_library_name: str. The name of the library that builds the module's test files. + deps: list of str. The list of dependencies needed to run the tests. ''' kt_android_library( From b0637dc7f5944651478c816902924f656c506141 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 12:18:19 -0400 Subject: [PATCH 100/106] Updated documentation for utility and testing BUILD files --- testing/BUILD.bazel | 5 ----- utility/BUILD.bazel | 4 ---- 2 files changed, 9 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 86a4fbae85a..8be3ebe3da5 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -1,11 +1,6 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' This library contains fake objects used for testing as well as tests for these objects. -In Bazel, Kotlin source files are built into a library using the kt_android_library() rule. -Individual Kotlin test files must be built in their own kt_android_library() rules and added as a -dependency to an android_local_test() rule which configures instrumentation tests in Bazel. -In order to eliminate duplicate code, a custom macro testing_test() has been written to streamline -testing in this module. ''' load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 35f11e4fd49..4be27444247 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -1,10 +1,6 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' This library contains utilities that all other modules, minus model, depend on. -It also contains Robolectric and JUnit tests for it's utilities. -In Bazel, Kotlin source files are built into a library using the kt_android_library() rule. -Kotlin test files must be built in their own kt_android_library() rule and added as a dependency to -an android_local_test() rule which configures instrumentation tests in Bazel. ''' load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") From 122f4519be4c84b021500d4b02c09cee1e6e59d7 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 3 Aug 2020 12:24:27 -0400 Subject: [PATCH 101/106] Changed src to srcs --- WORKSPACE | 1 + testing/BUILD.bazel | 4 ++-- testing/testing_test.bzl | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 3b413a3bb0a..0227b76d9ba 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -120,6 +120,7 @@ maven_install( "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", + "org.jetbrains.kotlin:kotlin-reflect:1.3.41", "com.google.truth:truth:0.43", "com.google.firebase:firebase-analytics:17.4.4", "com.google.firebase:firebase-crashlytics:17.1.1", diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 8be3ebe3da5..c226c15fc6b 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -35,14 +35,14 @@ TEST_DEPS = [ testing_test( name = "FakeEventLoggerTest", - src = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], + srcs = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], test_class = "org.oppia.testing.FakeEventLoggerTest", deps = TEST_DEPS, ) testing_test( name = "FakeExceptionLoggerTest", - src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], + srcs = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], test_class = "org.oppia.testing.FakeExceptionLoggerTest", deps = TEST_DEPS, ) diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl index f0c621aa150..fd3532adcb5 100644 --- a/testing/testing_test.bzl +++ b/testing/testing_test.bzl @@ -1,6 +1,6 @@ load("//:oppia_android_test.bzl", "oppia_android_test") -def testing_test(name, src, test_class, deps): +def testing_test(name, srcs, test_class, deps): ''' Creates individual tests for test files in the testing module. @@ -14,7 +14,7 @@ def testing_test(name, src, test_class, deps): oppia_android_test( name = name, - srcs = src, + srcs = srcs, custom_package = "org.oppia.testing", test_class = test_class, test_manifest = "src/test/AndroidManifest.xml", From 84e505140574dff2166464660ba0fd6dbffb9d3b Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 6 Aug 2020 10:53:40 -0400 Subject: [PATCH 102/106] Fixed the duplicate google-services.json issue --- {firebase => app}/BUILD.bazel | 3 +-- firebase/google-services.json | 40 ----------------------------------- utility/BUILD.bazel | 4 ++-- 3 files changed, 3 insertions(+), 44 deletions(-) rename {firebase => app}/BUILD.bazel (91%) delete mode 100644 firebase/google-services.json diff --git a/firebase/BUILD.bazel b/app/BUILD.bazel similarity index 91% rename from firebase/BUILD.bazel rename to app/BUILD.bazel index 30e5c7be7b0..49997a3b8c1 100644 --- a/firebase/BUILD.bazel +++ b/app/BUILD.bazel @@ -1,10 +1,9 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' Package for all Firebase dependencies. -To reference these dependencies, add '//firebase:crashlytics' and '//firebase:crashlytics_deps' +To reference these dependencies, add '//app:crashlytics' and '//app:crashlytics_deps' to your build rule's dependency list. ''' - load("@rules_jvm_external//:defs.bzl", "artifact") load("@dagger//:workspace_defs.bzl", "dagger_rules") load("@tools_android//tools/crashlytics:defs.bzl", "crashlytics_android_library") diff --git a/firebase/google-services.json b/firebase/google-services.json deleted file mode 100644 index 5b1dc0f6672..00000000000 --- a/firebase/google-services.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "project_info": { - "project_number": "215533462679", - "firebase_url": "https://oppia-android-dev.firebaseio.com", - "project_id": "oppia-android-dev", - "storage_bucket": "oppia-android-dev.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:215533462679:android:a25a70347460cd014035d2", - "android_client_info": { - "package_name": "org.oppia.app" - } - }, - "oauth_client": [ - { - "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCI5yOe1vF9g_e3tcIQb64C5i64AUNT1fc" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "215533462679-rjdq4c32s9mh9ouq0vlmo80u83a7kjdr.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 35f11e4fd49..b511f7fc1de 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -21,8 +21,8 @@ kt_android_library( deps = [ ":dagger", "//model", - "//firebase:crashlytics", - "//firebase:crashlytics_deps", + "//app:crashlytics", + "//app:crashlytics_deps", artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), From 3c0932d92ebe1a508c867fffa5559555d62d75ad Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 6 Aug 2020 11:00:18 -0400 Subject: [PATCH 103/106] Created Issue and added TODO --- app/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 49997a3b8c1..f1e3fcf6d51 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -11,6 +11,7 @@ load("@tools_android//tools/googleservices:defs.bzl", "google_services_xml") package(default_visibility = ["//visibility:public"]) +# TODO(#1566): Move Firebase rules to their own package GOOGLE_SERVICES_RESOURCES = google_services_xml( package_name = "org.oppia.app", google_services_json = "google-services.json", From 62a2fa729d90e93f1185a22df785e21144ed3c83 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 6 Aug 2020 12:11:58 -0400 Subject: [PATCH 104/106] Added minSDK back --- utility/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index c1709cdb835..6d4711a80a6 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - From 8eac40c9de6e32a58c7cab8f563e86ed81ca4cc1 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 6 Aug 2020 12:28:43 -0400 Subject: [PATCH 105/106] Alphabetized dependencies --- WORKSPACE | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 0227b76d9ba..3d6b42663bc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -108,34 +108,34 @@ load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = DAGGER_ARTIFACTS + [ - "org.robolectric:robolectric:4.3", - "org.robolectric:annotations:4.3", - "androidx.appcompat:appcompat:1.0.2", "androidx.annotation:annotation:1.1.0", + "androidx.appcompat:appcompat:1.0.2", "androidx.core:core-ktx:1.0.1", "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03", "androidx.test.ext:junit:1.1.1", "com.android.support:support-annotations:28.0.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", - "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", - "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", - "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", - "org.jetbrains.kotlin:kotlin-reflect:1.3.41", - "com.google.truth:truth:0.43", + "com.caverock:androidsvg-aar:1.4", + "com.crashlytics.sdk.android:crashlytics:2.9.8", + "com.github.bumptech.glide:glide:4.11.0", "com.google.firebase:firebase-analytics:17.4.4", "com.google.firebase:firebase-crashlytics:17.1.1", - "com.crashlytics.sdk.android:crashlytics:2.9.8", + "com.google.truth:truth:0.43", "io.fabric.sdk.android:fabric:1.4.7", - "com.github.bumptech.glide:glide:4.11.0", - "com.caverock:androidsvg-aar:1.4", - "org.mockito:mockito-core:2.19.0", "junit:junit:4.12", + "org.jetbrains.kotlin:kotlin-reflect:1.3.41", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.72", + "org.jetbrains.kotlin:kotlin-test-junit:1.3.72", + "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2", + "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", + "org.mockito:mockito-core:2.19.0", + "org.robolectric:annotations:4.3", + "org.robolectric:robolectric:4.3", ], repositories = DAGGER_REPOSITORIES + [ - "https://maven.google.com", - "https://repo1.maven.org/maven2", - "https://jcenter.bintray.com/", "https://bintray.com/bintray/jcenter", + "https://jcenter.bintray.com/", "https://maven.fabric.io/public", + "https://maven.google.com", + "https://repo1.maven.org/maven2", ], ) From a1843d27da3ae00f34b8e9acf9791775587fc170 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 7 Aug 2020 12:56:39 -0400 Subject: [PATCH 106/106] Changed targetSdk to 28 --- utility/src/main/AndroidManifest.xml | 2 +- utility/src/test/AndroidManifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index 6d4711a80a6..0e527c3295d 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="28" /> diff --git a/utility/src/test/AndroidManifest.xml b/utility/src/test/AndroidManifest.xml index 6d4711a80a6..0e527c3295d 100644 --- a/utility/src/test/AndroidManifest.xml +++ b/utility/src/test/AndroidManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="28" />