From d68f0a9e5f1b364c0ee4e33ccf252d07dae9cdef Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 29 Jun 2020 16:18:45 -0400 Subject: [PATCH 001/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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/120] 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 ae52338b093ce58fe86732122861127db513e1be Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 17:38:50 -0400 Subject: [PATCH 041/120] Utility tests are building and passing (except in_memory_blocking_cache_test) --- testing/BUILD.bazel | 2 +- utility/BUILD.bazel | 223 ++++++++++++------ .../org/oppia/util/data/DemoJavaTest.java | 20 -- 3 files changed, 157 insertions(+), 88 deletions(-) delete mode 100644 utility/src/test/java/org/oppia/util/data/DemoJavaTest.java diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 8ff5cf7f4c4..cbc6c597373 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -5,7 +5,7 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) kt_android_library( - name = "testing_main_lib", + name = "testing_lib", custom_package = "org.oppia.testing", srcs = glob(["src/main/java/**/*.kt"]), manifest = "src/main/AndroidManifest.xml", diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 855877147df..26d5805f1d9 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -1,19 +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") +load("//:oppia_android_test.bzl", "oppia_android_test") -kt_android_library( - name = "utility_lib", - custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/**/*.kt"], - exclude = ["src/main/java/org/oppia/util/logging/firebase/*.kt"]), +''' +oppia_android_test( + name = "netowrk_connection_creator_test_oppia", + srcs = ["src/test/java/org/oppia/util/networking/NetworkConnectionUtilTest.kt"], resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/main/AndroidManifest.xml", - deps = [ - ":dagger", - "//model:model_lib", - "//firebase:crashlytics_lib", - "//firebase:crashlytics_deps", + src_library_name = "utility_test_lib", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.datetime.NetworkConnectionUtilTest", + test_manifest = "src/test/TestManifest.xml", +)''' + +android_library( + name = "utility_deps", + exports = [ artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), @@ -31,97 +34,183 @@ kt_android_library( artifact("androidx.test.ext:junit"), artifact("org.mockito:mockito-core:2.19.0"), ], - 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"), +android_library( + name = "utility_test_deps", + exports = [ 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("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), + 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.appcompat:appcompat"), - artifact("androidx.core:core-ktx"), - artifact("junit:junit"), - artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), + 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_lib", + custom_package = "org.oppia.util", + 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", + ":utility_deps", ], + visibility = ["//visibility:public"] ) kt_android_library( - name = "async_test_lib", + name = "utility_test_lib", custom_package = "org.oppia.util", - srcs = ["src/test/java/org/oppia/util/data/AsyncResultTest.kt"], + srcs = glob(["src/test/java/org/oppia/util/**/*.kt"], + exclude = ["src/test/java/org/oppia/util/logging/firebase/*.kt"]), resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/test/TestManifest.xml", deps = [ - ":async", + ":utility_lib", + "//testing:testing_lib", ":dagger", + "//model:model_lib", + "//firebase:crashlytics_lib", + "//firebase:crashlytics_deps", "@robolectric//bazel:android-all", "@maven//:org_robolectric_robolectric", - artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), + ":utility_test_deps", + ":utility_deps", ], + visibility = ["//visibility:public"] ) android_local_test( - name = "async_tests", + name = "async_result_test", custom_package = "org.oppia.util", test_class = "org.oppia.util.data.AsyncResultTest", manifest = "src/test/TestManifest.xml", deps = [ - ":async_test_lib", + ":utility_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"), + ":utility_deps", + ":utility_test_deps", ], ) 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"), - ], + name = "data_providers_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.data.DataProvidersTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":utility_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + ":utility_deps", + ":utility_test_deps", + ], ) -#TODO: Get android_local_test working with kotlin files +# TODO: Builds but does not pass +android_local_test( + name = "in_memory_blocking_cache_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.data.InMemoryBlockingCacheTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":utility_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + ":utility_deps", + ":utility_test_deps", + ], +) + +android_local_test( + name = "date_time_util_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.datetime.DateTimeUtilTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":utility_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + ":utility_deps", + ":utility_test_deps", + ], +) + +android_local_test( + name = "event_bundle_creator_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.logging.EventBundleCreatorTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":utility_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + ":utility_deps", + ":utility_test_deps", + ], +) + +android_local_test( + name = "network_connection_util_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.networking.NetworkConnectionUtilTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":utility_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + ":utility_deps", + ":utility_test_deps", + ], +) + +android_local_test( + name = "directory_management_util_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.profile.DirectoryManagementUtilTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":utility_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + ":utility_deps", + ":utility_test_deps", + ], +) +android_local_test( + name = "oppia_date_time_formatter_test", + custom_package = "org.oppia.util", + test_class = "org.oppia.util.system.OppiaDateTimeFormatterTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":utility_test_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + ":utility_deps", + ":utility_test_deps", + ], +) + +#TODO: Get android_local_test working with kotlin files dagger_rules() 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 782cae9d57c2fa25e8f3033fc59c164fa1067c2b Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 17:58:51 -0400 Subject: [PATCH 042/120] Added android_local_test() rules for testing, building but not passing --- testing/BUILD.bazel | 50 +++++++++++++++++++++++++++++++++++++++++++-- utility/BUILD.bazel | 14 ++++++------- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index cbc6c597373..460f1756228 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -4,6 +4,30 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") package(default_visibility = ["//visibility:public"]) +android_library( + name = "testing_test_deps", + exports = [ + "@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"), + artifact("io.fabric.sdk.android:fabric"), + artifact("com.google.gms:google-services"), + artifact("com.android.support:support-annotations"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core"), + ], +) + kt_android_library( name = "testing_lib", custom_package = "org.oppia.testing", @@ -40,7 +64,7 @@ kt_android_library( srcs = glob(["src/test/java/**/*.kt"]), manifest = "src/main/AndroidManifest.xml", deps = [ - ":testing_main_lib", + ":testing_lib", ":dagger", "//model:model_lib", "//utility:utility_lib", @@ -65,6 +89,28 @@ kt_android_library( ], ) -#TODO: Add android_local_test rule +#TODO: Building but not passing +android_local_test( + name = "fake_event_logger_test", + custom_package = "org.oppia.testing", + test_class = "org.oppia.testing.FakeEventLoggerTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":testing_test_lib", + ":testing_test_deps", + ], +) + +#TODO: Building but not passing +android_local_test( + name = "fake_exception_logger_test", + custom_package = "org.oppia.testing", + test_class = "org.oppia.testing.FakeExceptionLoggerTest", + manifest = "src/test/TestManifest.xml", + deps = [ + ":testing_test_lib", + ":testing_test_deps", + ], +) dagger_rules() diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 26d5805f1d9..0ff4c9b243d 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -14,6 +14,7 @@ oppia_android_test( test_manifest = "src/test/TestManifest.xml", )''' +# TODO: Remove testing dependencies android_library( name = "utility_deps", exports = [ @@ -36,13 +37,14 @@ android_library( ], ) +# TODO: Remove non-testing dependencies android_library( name = "utility_test_deps", exports = [ artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), + artifact("org.jetbrains.kotlin:kotlin-test-junit"), artifact("com.google.truth:truth"), artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), @@ -50,12 +52,12 @@ android_library( 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.crashlytics.sdk.android:crashlytics"), + artifact("io.fabric.sdk.android:fabric"), + artifact("com.google.gms:google-services"), artifact("com.android.support:support-annotations"), artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core:2.19.0"), + artifact("org.mockito:mockito-core"), ], ) @@ -211,6 +213,4 @@ android_local_test( ], ) -#TODO: Get android_local_test working with kotlin files - dagger_rules() From 19036092eb0a8692490c0c2a37ae0ace9a4e0ea2 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 18:03:24 -0400 Subject: [PATCH 043/120] Added a test manifest for testing module --- testing/src/test/TestManifest.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 testing/src/test/TestManifest.xml diff --git a/testing/src/test/TestManifest.xml b/testing/src/test/TestManifest.xml new file mode 100644 index 00000000000..c9f0c28ba64 --- /dev/null +++ b/testing/src/test/TestManifest.xml @@ -0,0 +1,6 @@ + + + + From 67deaa7e7fce837118b397def6b08e2ad56fba86 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 18:09:11 -0400 Subject: [PATCH 044/120] Oppia_android_test is working --- oppia_android_test.bzl | 63 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 oppia_android_test.bzl diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl new file mode 100644 index 00000000000..c2c9929fd5d --- /dev/null +++ b/oppia_android_test.bzl @@ -0,0 +1,63 @@ +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, + ":dagger", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + artifact("org.jetbrains.kotlin:kotlin-test-junit"), + 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"), + ], + ) + + native.android_local_test( + name = name + "_test", + custom_package = custom_package, + test_class = test_class, + manifest = test_manifest, + deps = [ + ":" + name + "_lib", + "@robolectric//bazel:android-all", + "@maven//:org_robolectric_robolectric", + artifact("com.google.truth:truth"), + artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), + 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"), + ], + ) \ No newline at end of file From af824141ec0081edebc3c53fbe68b1255bf82681 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 18:25:23 -0400 Subject: [PATCH 045/120] Utility_test is now working --- oppia_android_test.bzl | 4 ++-- utility/BUILD.bazel | 15 ++++++--------- utility/utility_test.bzl | 13 +++++++++++++ 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 utility/utility_test.bzl diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index c2c9929fd5d..4d57a479699 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -35,7 +35,7 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files ) native.android_local_test( - name = name + "_test", + name = name, custom_package = custom_package, test_class = test_class, manifest = test_manifest, @@ -60,4 +60,4 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files artifact("junit:junit"), artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), ], - ) \ No newline at end of file + ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 0ff4c9b243d..6ee8f80e5b3 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -2,17 +2,14 @@ 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") load("//:oppia_android_test.bzl", "oppia_android_test") +load("//utility:utility_test.bzl", "utility_test") -''' -oppia_android_test( + +utility_test( name = "netowrk_connection_creator_test_oppia", - srcs = ["src/test/java/org/oppia/util/networking/NetworkConnectionUtilTest.kt"], - resource_files = glob(["src/main/res/**/*.xml"]), - src_library_name = "utility_test_lib", - custom_package = "org.oppia.util", - test_class = "org.oppia.util.datetime.NetworkConnectionUtilTest", - test_manifest = "src/test/TestManifest.xml", -)''' + src = ["src/test/java/org/oppia/util/networking/NetworkConnectionUtilTest.kt"], + test_class = "org.oppia.util.networking.NetworkConnectionUtilTest", +) # TODO: Remove testing dependencies android_library( diff --git a/utility/utility_test.bzl b/utility/utility_test.bzl new file mode 100644 index 00000000000..b6c3d060356 --- /dev/null +++ b/utility/utility_test.bzl @@ -0,0 +1,13 @@ +load("//:oppia_android_test.bzl", "oppia_android_test") + +def utility_test(name, src, test_class): + + oppia_android_test( + name = name, + srcs = src, + resource_files = native.glob(["src/main/res/**/*.xml"]), + src_library_name = "utility_test_lib", + custom_package = "org.oppia.util", + test_class = test_class, + test_manifest = "src/test/TestManifest.xml", + ) From 219ea6e78af899143ee032fed0b7da433e4a3faa Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 18:30:05 -0400 Subject: [PATCH 046/120] Testing_test.bzl is now working --- testing/BUILD.bazel | 11 +++++++++-- testing/testing_test.bzl | 13 +++++++++++++ utility/BUILD.bazel | 1 - 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 testing/testing_test.bzl diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 460f1756228..758873a2fdd 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -1,8 +1,15 @@ 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") + +testing_test( + name = "FakeExceptionLoggerTest", + src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], + test_class = "org.oppia.testing.FakeExceptionLoggerTest", +) android_library( name = "testing_test_deps", @@ -61,7 +68,7 @@ kt_android_library( kt_android_library( name = "testing_test_lib", 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_lib", diff --git a/testing/testing_test.bzl b/testing/testing_test.bzl new file mode 100644 index 00000000000..037d144ef02 --- /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_test_lib", + custom_package = "org.oppia.testing", + test_class = test_class, + test_manifest = "src/test/TestManifest.xml", + ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 6ee8f80e5b3..eaa0b4ab865 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -4,7 +4,6 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") load("//:oppia_android_test.bzl", "oppia_android_test") load("//utility:utility_test.bzl", "utility_test") - utility_test( name = "netowrk_connection_creator_test_oppia", src = ["src/test/java/org/oppia/util/networking/NetworkConnectionUtilTest.kt"], From 8562a4dd33a80c22d84553245f78cbbc74d00154 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 18:38:34 -0400 Subject: [PATCH 047/120] changed all android_local_test rules to utility_test rules --- utility/BUILD.bazel | 102 +++++++------------------------------------- 1 file changed, 16 insertions(+), 86 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index eaa0b4ab865..96f72f73fbf 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -4,12 +4,6 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") load("//:oppia_android_test.bzl", "oppia_android_test") load("//utility:utility_test.bzl", "utility_test") -utility_test( - name = "netowrk_connection_creator_test_oppia", - src = ["src/test/java/org/oppia/util/networking/NetworkConnectionUtilTest.kt"], - test_class = "org.oppia.util.networking.NetworkConnectionUtilTest", -) - # TODO: Remove testing dependencies android_library( name = "utility_deps", @@ -96,117 +90,53 @@ kt_android_library( visibility = ["//visibility:public"] ) -android_local_test( +utility_test( name = "async_result_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/data/AsyncResultTest.kt"], test_class = "org.oppia.util.data.AsyncResultTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) -android_local_test( +utility_test( name = "data_providers_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/data/DataProvidersTest.kt"], test_class = "org.oppia.util.data.DataProvidersTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) # TODO: Builds but does not pass -android_local_test( +utility_test( name = "in_memory_blocking_cache_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/data/InMemoryBlockingCacheTest.kt"], test_class = "org.oppia.util.data.InMemoryBlockingCacheTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) -android_local_test( +utility_test( name = "date_time_util_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/datetime/DateTimeUtilTest.kt"], test_class = "org.oppia.util.datetime.DateTimeUtilTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) -android_local_test( +utility_test( name = "event_bundle_creator_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/logging/EventBundleCreatorTest.kt"], test_class = "org.oppia.util.logging.EventBundleCreatorTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) -android_local_test( +utility_test( name = "network_connection_util_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/networking/NetworkConnectionUtilTest.kt"], test_class = "org.oppia.util.networking.NetworkConnectionUtilTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) -android_local_test( +utility_test( name = "directory_management_util_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/profile/DirectoryManagementUtilTest.kt"], test_class = "org.oppia.util.profile.DirectoryManagementUtilTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) -android_local_test( +utility_test( name = "oppia_date_time_formatter_test", - custom_package = "org.oppia.util", + src = ["src/test/java/org/oppia/util/system/OppiaDateTimeFormatterTest.kt"], test_class = "org.oppia.util.system.OppiaDateTimeFormatterTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":utility_test_lib", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_deps", - ":utility_test_deps", - ], ) dagger_rules() From 5d6dd4072a8b8f0e5b02a479e9b95f2ddc97764e Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 21 Jul 2020 19:09:27 -0400 Subject: [PATCH 048/120] Named test rules correctly --- testing/BUILD.bazel | 28 ++++++---------------------- utility/BUILD.bazel | 16 ++++++++-------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 758873a2fdd..f47d2d97696 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -5,12 +5,6 @@ package(default_visibility = ["//visibility:public"]) load("//:oppia_android_test.bzl", "oppia_android_test") load("//testing:testing_test.bzl", "testing_test") -testing_test( - name = "FakeExceptionLoggerTest", - src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], - test_class = "org.oppia.testing.FakeExceptionLoggerTest", -) - android_library( name = "testing_test_deps", exports = [ @@ -97,27 +91,17 @@ kt_android_library( ) #TODO: Building but not passing -android_local_test( - name = "fake_event_logger_test", - custom_package = "org.oppia.testing", +testing_test( + name = "FakeEventLoggerTest", + src = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], test_class = "org.oppia.testing.FakeEventLoggerTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":testing_test_lib", - ":testing_test_deps", - ], ) #TODO: Building but not passing -android_local_test( - name = "fake_exception_logger_test", - custom_package = "org.oppia.testing", +testing_test( + name = "FakeExceptionLoggerTest", + src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], test_class = "org.oppia.testing.FakeExceptionLoggerTest", - manifest = "src/test/TestManifest.xml", - deps = [ - ":testing_test_lib", - ":testing_test_deps", - ], ) dagger_rules() diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 96f72f73fbf..3c1b3bb91f3 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -91,50 +91,50 @@ kt_android_library( ) utility_test( - name = "async_result_test", + name = "AsyncResultTest", src = ["src/test/java/org/oppia/util/data/AsyncResultTest.kt"], test_class = "org.oppia.util.data.AsyncResultTest", ) utility_test( - name = "data_providers_test", + name = "DataProvidersTest", src = ["src/test/java/org/oppia/util/data/DataProvidersTest.kt"], test_class = "org.oppia.util.data.DataProvidersTest", ) # TODO: Builds but does not pass utility_test( - name = "in_memory_blocking_cache_test", + name = "InMemoryBlockingCacheTest", src = ["src/test/java/org/oppia/util/data/InMemoryBlockingCacheTest.kt"], test_class = "org.oppia.util.data.InMemoryBlockingCacheTest", ) utility_test( - name = "date_time_util_test", + name = "DateTimeUtilTest", src = ["src/test/java/org/oppia/util/datetime/DateTimeUtilTest.kt"], test_class = "org.oppia.util.datetime.DateTimeUtilTest", ) utility_test( - name = "event_bundle_creator_test", + name = "EventBundleCreatorTest", src = ["src/test/java/org/oppia/util/logging/EventBundleCreatorTest.kt"], test_class = "org.oppia.util.logging.EventBundleCreatorTest", ) utility_test( - name = "network_connection_util_test", + name = "NetworkConnectionUtilTest", src = ["src/test/java/org/oppia/util/networking/NetworkConnectionUtilTest.kt"], test_class = "org.oppia.util.networking.NetworkConnectionUtilTest", ) utility_test( - name = "directory_management_util_test", + name = "DirectoryManagementUtilTest", src = ["src/test/java/org/oppia/util/profile/DirectoryManagementUtilTest.kt"], test_class = "org.oppia.util.profile.DirectoryManagementUtilTest", ) utility_test( - name = "oppia_date_time_formatter_test", + name = "OppiaDateTimeFormatterTest", src = ["src/test/java/org/oppia/util/system/OppiaDateTimeFormatterTest.kt"], test_class = "org.oppia.util.system.OppiaDateTimeFormatterTest", ) From 3d21443a9f75941be98898af575ef9ea5d77d747 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 10:53:44 -0400 Subject: [PATCH 049/120] Added missing dependency, all tests now pass --- WORKSPACE | 1 + oppia_android_test.bzl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index 4ee98f2b2da..a41bce274c2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -119,6 +119,7 @@ maven_install( "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.jetbrains.kotlin:kotlin-reflect:1.3.72", "org.robolectric:annotations:4.3", ], repositories = DAGGER_REPOSITORIES + [ diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 4d57a479699..79d9541176d 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -31,6 +31,7 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files artifact("androidx.core:core-ktx"), artifact("junit:junit"), artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), + artifact("org.jetbrains.kotlin:kotlin-reflect"), ], ) @@ -59,5 +60,6 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files artifact("androidx.core:core-ktx"), artifact("junit:junit"), artifact("org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar"), + artifact("org.jetbrains.kotlin:kotlin-reflect"), ], ) From 761c0c5f197a545e41bd8fe5d4b1b63a503b59e3 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 12:24:56 -0400 Subject: [PATCH 050/120] Removed all unused dependencies --- WORKSPACE | 15 ++-------- oppia_android_test.bzl | 36 ----------------------- testing/BUILD.bazel | 60 +------------------------------------ utility/BUILD.bazel | 67 ++++++------------------------------------ 4 files changed, 13 insertions(+), 165 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index a41bce274c2..b5f129f8f5e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -100,27 +100,18 @@ 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", - "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-test-junit:1.3.72", + "org.jetbrains.kotlin:kotlin-reflect: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.jetbrains.kotlin:kotlin-reflect:1.3.72", - "org.robolectric:annotations:4.3", ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 79d9541176d..52d0ef332e8 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -12,26 +12,6 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files manifest = test_manifest, deps = [ ":" + src_library_name, - ":dagger", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - artifact("org.jetbrains.kotlin:kotlin-test-junit"), - 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"), - artifact("org.jetbrains.kotlin:kotlin-reflect"), ], ) @@ -44,22 +24,6 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files ":" + name + "_lib", "@robolectric//bazel:android-all", "@maven//:org_robolectric_robolectric", - artifact("com.google.truth:truth"), - artifact("org.jetbrains.kotlin:kotlin-test-junit:1.3.72"), - 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"), artifact("org.jetbrains.kotlin:kotlin-reflect"), ], ) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index f47d2d97696..f43ff9d03cd 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -5,57 +5,17 @@ package(default_visibility = ["//visibility:public"]) load("//:oppia_android_test.bzl", "oppia_android_test") load("//testing:testing_test.bzl", "testing_test") -android_library( - name = "testing_test_deps", - exports = [ - "@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"), - artifact("io.fabric.sdk.android:fabric"), - artifact("com.google.gms:google-services"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core"), - ], -) - kt_android_library( name = "testing_lib", 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", - "//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"), ], ) @@ -67,26 +27,8 @@ kt_android_library( deps = [ ":testing_lib", ":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"), ], ) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 3c1b3bb91f3..9216345fa13 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -4,53 +4,6 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") load("//:oppia_android_test.bzl", "oppia_android_test") load("//utility:utility_test.bzl", "utility_test") -# TODO: Remove testing dependencies -android_library( - name = "utility_deps", - exports = [ - 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: Remove non-testing dependencies -android_library( - name = "utility_test_deps", - exports = [ - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("org.jetbrains.kotlin:kotlin-test-junit"), - 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"), - artifact("io.fabric.sdk.android:fabric"), - artifact("com.google.gms:google-services"), - artifact("com.android.support:support-annotations"), - artifact("androidx.test.ext:junit"), - artifact("org.mockito:mockito-core"), - ], -) - kt_android_library( name = "utility_lib", custom_package = "org.oppia.util", @@ -61,9 +14,10 @@ kt_android_library( deps = [ ":dagger", "//model:model_lib", - "//firebase:crashlytics_lib", - "//firebase:crashlytics_deps", - ":utility_deps", + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), ], visibility = ["//visibility:public"] ) @@ -76,16 +30,14 @@ kt_android_library( resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/test/TestManifest.xml", deps = [ + ":dagger", ":utility_lib", "//testing:testing_lib", - ":dagger", "//model:model_lib", - "//firebase:crashlytics_lib", - "//firebase:crashlytics_deps", - "@robolectric//bazel:android-all", - "@maven//:org_robolectric_robolectric", - ":utility_test_deps", - ":utility_deps", + artifact("org.jetbrains.kotlin:kotlin-test-junit"), + artifact("com.google.truth:truth"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core"), ], visibility = ["//visibility:public"] ) @@ -102,7 +54,6 @@ utility_test( test_class = "org.oppia.util.data.DataProvidersTest", ) -# TODO: Builds but does not pass utility_test( name = "InMemoryBlockingCacheTest", src = ["src/test/java/org/oppia/util/data/InMemoryBlockingCacheTest.kt"], From 94213cdb133a905f2fbe154167f55d34a840de12 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 13:08:02 -0400 Subject: [PATCH 051/120] 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 052/120] 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 7c1ddf8fa6268a3c3b9ce3680d889d15a82266bc Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 13:45:52 -0400 Subject: [PATCH 053/120] Fixed visibility --- testing/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index f43ff9d03cd..3d3f2e07f90 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -1,7 +1,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"]) load("//:oppia_android_test.bzl", "oppia_android_test") load("//testing:testing_test.bzl", "testing_test") @@ -17,6 +16,7 @@ kt_android_library( artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), ], + visibility = ["//visibility:public"] ) kt_android_library( From 33ff9306b0d6665a3df1b780610d2dd4e36e1aea Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 13:47:49 -0400 Subject: [PATCH 054/120] Initial BUILD file added --- domain/BUILD.bazel | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 domain/BUILD.bazel diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel new file mode 100644 index 00000000000..e69de29bb2d From 08ed2dc107726352780ed4b35fe3b38ca71a1ee0 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 13:49:36 -0400 Subject: [PATCH 055/120] Remove addressed TODOs --- WORKSPACE | 1 - testing/BUILD.bazel | 2 -- 2 files changed, 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index b5f129f8f5e..883486ff498 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -96,7 +96,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", diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 3d3f2e07f90..959d8bb0829 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -32,14 +32,12 @@ kt_android_library( ], ) -#TODO: Building but not passing testing_test( name = "FakeEventLoggerTest", src = ["src/test/java/org/oppia/testing/FakeEventLoggerTest.kt"], test_class = "org.oppia.testing.FakeEventLoggerTest", ) -#TODO: Building but not passing testing_test( name = "FakeExceptionLoggerTest", src = ["src/test/java/org/oppia/testing/FakeExceptionLoggerTest.kt"], From 9505de23880d35a204a5b669e1a89ecbb02be377 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 14:54:13 -0400 Subject: [PATCH 056/120] Started writing build rule --- domain/BUILD.bazel | 25 +++++++++++++++++++++++++ model/BUILD.bazel | 8 +++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index e69de29bb2d..405bc1b2e3d 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -0,0 +1,25 @@ +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") + +kt_android_library( + name = "domain_lib", + custom_package = "org.oppia.domain", + srcs = glob(["src/main/**/*.kt"]), + data = glob(["src/main/assets/*.json",]), + manifest = "src/main/AndroidManifest.xml", + deps = [ + ":dagger", + "//model:model_lib", + #"//model:exploration_proto", + "//utility:utility_lib", + "//data:cache_store_lib", + artifact("androidx.appcompat:appcompat"), + artifact("com.github.bumptech.glide:glide"), + artifact("com.caverock:androidsvg-aar"), + artifact("androidx.lifecycle:lifecycle-livedata-ktx"), + ], + visibility = ["//visibility:public"] +) + +dagger_rules() diff --git a/model/BUILD.bazel b/model/BUILD.bazel index bedc30c3bb1..5263488274e 100644 --- a/model/BUILD.bazel +++ b/model/BUILD.bazel @@ -120,11 +120,9 @@ android_library( ":thumbnail_java_proto", ":translation_java_proto", ":voiceover_java_proto", - ], - data = [ - ":exploration_proto", - ":question_proto", - ":topic_proto", + ":exploration_proto_java_lib", + ":question_proto_java_lib", + ":topic_proto_java_lib", ], visibility = ["//visibility:public"], ) From e1ce0d1916e9ee226995b9e7653f1d28723ffdc2 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 17:01:42 -0400 Subject: [PATCH 057/120] 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 058/120] 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 2981277960d9ed16f0540b2e9dbd2bbf3f98809c Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 17:29:42 -0400 Subject: [PATCH 059/120] Removed unused dependencies in domain_lib --- domain/BUILD.bazel | 6 ------ 1 file changed, 6 deletions(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 405bc1b2e3d..07ebef2422d 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -11,13 +11,7 @@ kt_android_library( deps = [ ":dagger", "//model:model_lib", - #"//model:exploration_proto", - "//utility:utility_lib", "//data:cache_store_lib", - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), ], visibility = ["//visibility:public"] ) From 17dc39ae48d40c9fec6c426816e4ff0039a4ae83 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 22 Jul 2020 18:07:48 -0400 Subject: [PATCH 060/120] Working on building domain test files --- domain/BUILD.bazel | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 07ebef2422d..f101dc217e5 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -5,7 +5,7 @@ load("@dagger//:workspace_defs.bzl", "dagger_rules") kt_android_library( name = "domain_lib", custom_package = "org.oppia.domain", - srcs = glob(["src/main/**/*.kt"]), + srcs = glob(["src/main/java/org/oppia/domain/**/*.kt"]), data = glob(["src/main/assets/*.json",]), manifest = "src/main/AndroidManifest.xml", deps = [ @@ -16,4 +16,28 @@ kt_android_library( visibility = ["//visibility:public"] ) +#TODO: Get test files to build +''' +kt_android_library( + name = "domain_test_lib", + custom_package = "org.oppia.domain", + srcs = glob(["src/test/java/org/oppia/domain/**/*.kt"]), + data = glob(["src/main/assets/*.json",]), + manifest = "src/test/TestManifest.xml", + deps = [ + ":dagger", + ":domain_lib", + "//model:model_lib", + "//data:cache_store_lib", + artifact("com.google.truth:truth"), + artifact("androidx.test.ext:junit"), + artifact("org.robolectric:robolectric"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), + "@robolectric//bazel:android-all", + artifact("org.jetbrains.kotlin:kotlin-reflect"), + ], + visibility = ["//visibility:public"] +)''' + dagger_rules() From 999b3f817c67dcdd5f591232a0485be8440115aa Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 10:32:12 -0400 Subject: [PATCH 061/120] Added a test manifest --- domain/src/test/TestManifest.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 domain/src/test/TestManifest.xml diff --git a/domain/src/test/TestManifest.xml b/domain/src/test/TestManifest.xml new file mode 100644 index 00000000000..e1c76297cbe --- /dev/null +++ b/domain/src/test/TestManifest.xml @@ -0,0 +1,6 @@ + + + + From 47d4e0c59013afc1c1bd8937277217caf208745d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 13:54:45 -0400 Subject: [PATCH 062/120] Test files now build --- WORKSPACE | 2 ++ domain/BUILD.bazel | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 883486ff498..2c308bf3c4d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -111,6 +111,8 @@ maven_install( "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03", "org.mockito:mockito-core:2.19.0", "androidx.test.ext:junit:1.1.1", + "android.arch.core:core-testing:1.1.1", + "androidx.arch.core:core-testing:2.1.0" ], repositories = DAGGER_REPOSITORIES + [ "https://maven.google.com", diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index f101dc217e5..fc3e4e69bd9 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -12,16 +12,16 @@ kt_android_library( ":dagger", "//model:model_lib", "//data:cache_store_lib", + "//testing:testing_lib", ], - visibility = ["//visibility:public"] + visibility = ["//visibility:public"], ) -#TODO: Get test files to build -''' kt_android_library( name = "domain_test_lib", custom_package = "org.oppia.domain", - srcs = glob(["src/test/java/org/oppia/domain/**/*.kt"]), + srcs = glob(["src/test/java/org/oppia/domain/**/*.kt", + "src/main/java/org/oppia/domain/**/*.kt"]), data = glob(["src/main/assets/*.json",]), manifest = "src/test/TestManifest.xml", deps = [ @@ -29,15 +29,14 @@ kt_android_library( ":domain_lib", "//model:model_lib", "//data:cache_store_lib", + "//testing:testing_lib", + "@robolectric//bazel:android-all", artifact("com.google.truth:truth"), artifact("androidx.test.ext:junit"), - artifact("org.robolectric:robolectric"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - "@robolectric//bazel:android-all", - artifact("org.jetbrains.kotlin:kotlin-reflect"), + artifact("org.jetbrains.kotlin:kotlin-test-junit"), + artifact("androidx.arch.core:core-testing"), ], - visibility = ["//visibility:public"] -)''' + visibility = ["//visibility:public"], +) dagger_rules() From 89307b1d69196d0490873d1c8050e55a09927a4d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 14:27:37 -0400 Subject: [PATCH 063/120] Added test rules, some tests not building or passing --- domain/BUILD.bazel | 208 +++++++++++++++++++++++++++++++++++++++++ domain/domain_test.bzl | 13 +++ 2 files changed, 221 insertions(+) create mode 100644 domain/domain_test.bzl diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index fc3e4e69bd9..1dc0ce913aa 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -1,6 +1,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") +load("//domain:domain_test.bzl", "domain_test") kt_android_library( name = "domain_lib", @@ -35,8 +36,215 @@ kt_android_library( artifact("androidx.test.ext:junit"), artifact("org.jetbrains.kotlin:kotlin-test-junit"), artifact("androidx.arch.core:core-testing"), + artifact("org.jetbrains.kotlin:kotlin-reflect"), ], visibility = ["//visibility:public"], ) +domain_test( + name = "AudioPlayerControllerTest", + src = ["src/test/java/org/oppia/domain/audio/AudioPlayerControllerTest.kt"], + test_class = "org.oppia.domain.audio.AudioPlayerControllerTest", +) + +domain_test( + name = "CellularAudioDialogControllerTest", + src = ["src/test/java/org/oppia/domain/audio/CellularAudioDialogControllerTest.kt"], + test_class = "org.oppia.domain.audio.CellularAudioDialogControllerTest", +) + +#TODO: Not building +domain_test( + name = "AnswerClassificationControllerTest", + src = ["src/test/java/org/oppia/domain/classify/AnswerClassificationControllerTest.kt"], + test_class = "org.oppia.domain.classify.AnswerClassificationControllerTest", +) + +#TODO: Not building +domain_test( + name = "NumericInputEqualsRuleClassifierProviderTest", + src = ["src/test/java/org/oppia/domain/classify/NumericInputEqualsRuleClassifierProviderTest.kt"], + test_class = "org.oppia.domain.classify.NumericInputEqualsRuleClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/dragAndDropSortInput/" + + "DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.dragAndDropSortInput." + + "DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/dragAndDropSortInput/" + + "DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.dragAndDropSortInput." + + "DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "DragDropSortInputIsEqualToOrderingClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/dragAndDropSortInput/" + + "DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.dragAndDropSortInput." + + "DragDropSortInputIsEqualToOrderingClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/dragAndDropSortInput/" + + "DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.dragAndDropSortInput." + + "DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "ImageClickInputIsInRegionRuleClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/imageClickInput/" + + "ImageClickInputIsInRegionRuleClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.imageClickInput." + + "ImageClickInputIsInRegionRuleClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "MultipleChoiceInputEqualsRuleClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/multiplechoiceinput/" + + "MultipleChoiceInputEqualsRuleClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.multiplechoiceinput." + + "MultipleChoiceInputEqualsRuleClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "TextInputContainsRuleClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/textinput/" + + "TextInputContainsRuleClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.textinput." + + "TextInputContainsRuleClassifierProviderTest", +) + +#TODO: Not building +domain_test( + name = "TextInputEqualsRuleClassifierProviderTest", + src = [ + "src/test/java/org/oppia/domain/classify/rules/textinput/" + + "TextInputEqualsRuleClassifierProviderTest.kt" + ], + test_class = "org.oppia.domain.classify.rules.textinput." + + "TextInputEqualsRuleClassifierProviderTest", +) + +#TODO: Building not passing +domain_test( + name = "ExplorationDataControllerTest", + src = ["src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt"], + test_class = "org.oppia.domain.exploration.ExplorationDataControllerTest", +) + +#TODO: Not building +domain_test( + name = "ExplorationProgressControllerTest", + src = ["src/test/java/org/oppia/domain/exploration/ExplorationProgressControllerTest.kt"], + test_class = "org.oppia.domain.exploration.ExplorationProgressControllerTest", +) + +domain_test( + name = "OnboardingFlowControllerTest", + src = ["src/test/java/org/oppia/domain/onboarding/OnboardingFlowControllerTest.kt"], + test_class = "org.oppia.domain.onboarding.OnboardingFlowControllerTest", +) + +domain_test( + name = "AnalyticsControllerTest", + src = ["src/test/java/org/oppia/domain/oppialogger/analytics/AnalyticsControllerTest.kt"], + test_class = "org.oppia.domain.oppialogger.analytics.AnalyticsControllerTest", +) + +domain_test( + name = "ProfileManagementControllerTest", + src = ["src/test/java/org/oppia/domain/profile/ProfileManagementControllerTest.kt"], + test_class = "org.oppia.domain.profile.ProfileManagementControllerTest", +) + +domain_test( + name = "ProfileTestHelperTest", + src = ["src/test/java/org/oppia/domain/profile/ProfileTestHelperTest.kt"], + test_class = "org.oppia.domain.profile.ProfileTestHelperTest", +) + +#TODO: Building not passing +domain_test( + name = "QuestionAssessmentProgressControllerTest", + src = ["src/test/java/org/oppia/domain/question/QuestionAssessmentProgressControllerTest.kt"], + test_class = "org.oppia.domain.question.QuestionAssessmentProgressControllerTest", +) + +#TODO: Building not passing +domain_test( + name = "QuestionTrainingControllerTest", + src = ["src/test/java/org/oppia/domain/question/QuestionTrainingControllerTest.kt"], + test_class = "org.oppia.domain.question.QuestionTrainingControllerTest", +) + +domain_test( + name = "StoryProgressControllerTest", + src = ["src/test/java/org/oppia/domain/topic/StoryProgressControllerTest.kt"], + test_class = "org.oppia.domain.topic.StoryProgressControllerTest", +) + +#TODO: Building not passing +domain_test( + name = "StoryProgressTestHelperTest", + src = ["src/test/java/org/oppia/domain/topic/StoryProgressTestHelperTest.kt"], + test_class = "org.oppia.domain.topic.StoryProgressTestHelperTest", +) + +#TODO: Building not passing +domain_test( + name = "TopicControllerTest", + src = ["src/test/java/org/oppia/domain/topic/TopicControllerTest.kt"], + test_class = "org.oppia.domain.topic.TopicControllerTest", +) + +#TODO: Building not passing +domain_test( + name = "TopicListControllerTest", + src = ["src/test/java/org/oppia/domain/topic/TopicListControllerTest.kt"], + test_class = "org.oppia.domain.topic.TopicListControllerTest", +) + +domain_test( + name = "InteractionObjectExtensionsTest", + src = ["src/test/java/org/oppia/domain/util/InteractionObjectExtensionsTest.kt"], + test_class = "org.oppia.domain.util.InteractionObjectExtensionsTest", +) + +#TODO: Building not passing +domain_test( + name = "StateRetrieverTest", + src = ["src/test/java/org/oppia/domain/util/StateRetrieverTest.kt"], + test_class = "org.oppia.domain.util.StateRetrieverTest", +) + dagger_rules() diff --git a/domain/domain_test.bzl b/domain/domain_test.bzl new file mode 100644 index 00000000000..23015ed3eb9 --- /dev/null +++ b/domain/domain_test.bzl @@ -0,0 +1,13 @@ +load("//:oppia_android_test.bzl", "oppia_android_test") + +def domain_test(name, src, test_class): + + oppia_android_test( + name = name, + srcs = src, + resource_files = native.glob(["src/main/res/**/*.xml"]), + src_library_name = "domain_test_lib", + custom_package = "org.oppia.domain", + test_class = test_class, + test_manifest = "src/test/TestManifest.xml", + ) From 25e9c7375340b204568539dcf490b4b2e4909bad Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 15:28:12 -0400 Subject: [PATCH 064/120] Added data attribute to test macros --- domain/BUILD.bazel | 4 ++-- domain/domain_test.bzl | 2 +- oppia_android_test.bzl | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 1dc0ce913aa..6a23257d578 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -7,7 +7,7 @@ kt_android_library( name = "domain_lib", custom_package = "org.oppia.domain", srcs = glob(["src/main/java/org/oppia/domain/**/*.kt"]), - data = glob(["src/main/assets/*.json",]), + data = glob(["src/main/assets/**"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", @@ -23,7 +23,7 @@ kt_android_library( custom_package = "org.oppia.domain", srcs = glob(["src/test/java/org/oppia/domain/**/*.kt", "src/main/java/org/oppia/domain/**/*.kt"]), - data = glob(["src/main/assets/*.json",]), + data = glob(["src/main/assets/**"]), manifest = "src/test/TestManifest.xml", deps = [ ":dagger", diff --git a/domain/domain_test.bzl b/domain/domain_test.bzl index 23015ed3eb9..cb6f1e73a8e 100644 --- a/domain/domain_test.bzl +++ b/domain/domain_test.bzl @@ -5,9 +5,9 @@ def domain_test(name, src, test_class): oppia_android_test( name = name, srcs = src, - resource_files = native.glob(["src/main/res/**/*.xml"]), src_library_name = "domain_test_lib", custom_package = "org.oppia.domain", test_class = test_class, test_manifest = "src/test/TestManifest.xml", + data = native.glob(["src/main/assets/**"]), ) diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 52d0ef332e8..98ce40a06c0 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -1,8 +1,8 @@ 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): +def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, src_library_name, + data=None, resource_files=None): kt_android_library( name = name + "_lib", @@ -13,17 +13,20 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files deps = [ ":" + src_library_name, ], + data = data, ) native.android_local_test( - name = name, + name = name + "_test_lib", custom_package = custom_package, test_class = test_class, manifest = test_manifest, deps = [ + ":" + src_library_name, ":" + name + "_lib", "@robolectric//bazel:android-all", "@maven//:org_robolectric_robolectric", artifact("org.jetbrains.kotlin:kotlin-reflect"), ], + data = data ) From 461d249b2070e5690d8b66d09dba250a03eb7129 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 16:49:01 -0400 Subject: [PATCH 065/120] All tests now build, some do not pass --- domain/BUILD.bazel | 15 ++------ .../AnswerClassificationController.kt | 2 +- .../classify/rules/GenericRuleClassifier.kt | 34 +++++++++---------- ...nteractionObjectTypeExtractorRepository.kt | 6 ++-- ...asElementXAtPositionYClassifierProvider.kt | 2 +- ...lementXBeforeElementYClassifierProvider.kt | 2 +- ...nputIsEqualToOrderingClassifierProvider.kt | 2 +- ...gWithOneItemIncorrectClassifierProvider.kt | 2 +- ...ckInputIsInRegionRuleClassifierProvider.kt | 2 +- ...ChoiceInputEqualsRuleClassifierProvider.kt | 2 +- ...umericInputEqualsRuleClassifierProvider.kt | 2 +- ...TextInputContainsRuleClassifierProvider.kt | 2 +- .../TextInputEqualsRuleClassifierProvider.kt | 2 +- .../exploration/ExplorationRetriever.kt | 2 +- oppia_android_test.bzl | 3 +- 15 files changed, 34 insertions(+), 46 deletions(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 6a23257d578..c270abcca56 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -21,8 +21,7 @@ kt_android_library( kt_android_library( name = "domain_test_lib", custom_package = "org.oppia.domain", - srcs = glob(["src/test/java/org/oppia/domain/**/*.kt", - "src/main/java/org/oppia/domain/**/*.kt"]), + srcs = glob(["src/test/java/org/oppia/domain/**/*.kt"]), data = glob(["src/main/assets/**"]), manifest = "src/test/TestManifest.xml", deps = [ @@ -53,21 +52,18 @@ domain_test( test_class = "org.oppia.domain.audio.CellularAudioDialogControllerTest", ) -#TODO: Not building domain_test( name = "AnswerClassificationControllerTest", src = ["src/test/java/org/oppia/domain/classify/AnswerClassificationControllerTest.kt"], test_class = "org.oppia.domain.classify.AnswerClassificationControllerTest", ) -#TODO: Not building domain_test( name = "NumericInputEqualsRuleClassifierProviderTest", src = ["src/test/java/org/oppia/domain/classify/NumericInputEqualsRuleClassifierProviderTest.kt"], test_class = "org.oppia.domain.classify.NumericInputEqualsRuleClassifierProviderTest", ) -#TODO: Not building domain_test( name = "DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest", src = [ @@ -78,7 +74,6 @@ domain_test( + "DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest", ) -#TODO: Not building domain_test( name = "DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest", src = [ @@ -89,7 +84,6 @@ domain_test( + "DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest", ) -#TODO: Not building domain_test( name = "DragDropSortInputIsEqualToOrderingClassifierProviderTest", src = [ @@ -100,7 +94,6 @@ domain_test( + "DragDropSortInputIsEqualToOrderingClassifierProviderTest", ) -#TODO: Not building domain_test( name = "DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProviderTest", src = [ @@ -111,7 +104,6 @@ domain_test( + "DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProviderTest", ) -#TODO: Not building domain_test( name = "ImageClickInputIsInRegionRuleClassifierProviderTest", src = [ @@ -122,7 +114,6 @@ domain_test( + "ImageClickInputIsInRegionRuleClassifierProviderTest", ) -#TODO: Not building domain_test( name = "MultipleChoiceInputEqualsRuleClassifierProviderTest", src = [ @@ -133,7 +124,6 @@ domain_test( + "MultipleChoiceInputEqualsRuleClassifierProviderTest", ) -#TODO: Not building domain_test( name = "TextInputContainsRuleClassifierProviderTest", src = [ @@ -144,7 +134,6 @@ domain_test( + "TextInputContainsRuleClassifierProviderTest", ) -#TODO: Not building domain_test( name = "TextInputEqualsRuleClassifierProviderTest", src = [ @@ -162,7 +151,7 @@ domain_test( test_class = "org.oppia.domain.exploration.ExplorationDataControllerTest", ) -#TODO: Not building +#TODO: Building not passing domain_test( name = "ExplorationProgressControllerTest", src = ["src/test/java/org/oppia/domain/exploration/ExplorationProgressControllerTest.kt"], diff --git a/domain/src/main/java/org/oppia/domain/classify/AnswerClassificationController.kt b/domain/src/main/java/org/oppia/domain/classify/AnswerClassificationController.kt index f933c7bf263..195e7b662a9 100644 --- a/domain/src/main/java/org/oppia/domain/classify/AnswerClassificationController.kt +++ b/domain/src/main/java/org/oppia/domain/classify/AnswerClassificationController.kt @@ -21,7 +21,7 @@ class AnswerClassificationController @Inject constructor( * Classifies the specified answer in the context of the specified [Interaction] and returns the [Outcome] that best * matches the learner's answer. */ - internal fun classify(interaction: Interaction, answer: InteractionObject): Outcome { + fun classify(interaction: Interaction, answer: InteractionObject): Outcome { val interactionClassifier = checkNotNull( interactionClassifiers[interaction.id] ) { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/GenericRuleClassifier.kt b/domain/src/main/java/org/oppia/domain/classify/rules/GenericRuleClassifier.kt index eacd0362ae8..2a37438fc0d 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/GenericRuleClassifier.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/GenericRuleClassifier.kt @@ -12,11 +12,11 @@ import javax.inject.Inject * Child classes must ensure all specified types properly correspond to the type to which the parameter's specified * [InteractionObject.ObjectTypeCase] also corresponds. */ -internal class GenericRuleClassifier private constructor( - private val expectedAnswerObjectType: InteractionObject.ObjectTypeCase, - private val orderedExpectedParameterTypes: LinkedHashMap< +class GenericRuleClassifier constructor( + val expectedAnswerObjectType: InteractionObject.ObjectTypeCase, + val orderedExpectedParameterTypes: LinkedHashMap< String, InteractionObject.ObjectTypeCase>, - private val matcherDelegate: MatcherDelegate + val matcherDelegate: MatcherDelegate ) : RuleClassifier { override fun matches(answer: InteractionObject, inputs: Map): Boolean { check(answer.objectTypeCase == expectedAnswerObjectType) { @@ -47,7 +47,7 @@ internal class GenericRuleClassifier private constructor( return input } - internal interface NoInputInputMatcher { + interface NoInputInputMatcher { /** * Returns whether the validated and extracted answer matches the expectations per the specification of this * classifier. @@ -55,7 +55,7 @@ internal class GenericRuleClassifier private constructor( fun matches(answer: T): Boolean } - internal interface SingleInputMatcher { + interface SingleInputMatcher { /** * Returns whether the validated and extracted answer matches the single validated and extracted input parameter per * the specification of this classifier. @@ -63,7 +63,7 @@ internal class GenericRuleClassifier private constructor( fun matches(answer: T, input: T): Boolean } - internal interface MultiTypeSingleInputMatcher { + interface MultiTypeSingleInputMatcher { /** * Returns whether the validated and extracted answer matches the single validated and extracted input parameter per * the specification of this classifier. @@ -71,7 +71,7 @@ internal class GenericRuleClassifier private constructor( fun matches(answer: AT, input: IT): Boolean } - internal interface MultiTypeDoubleInputMatcher { + interface MultiTypeDoubleInputMatcher { /** * Returns whether the validated and extracted answer matches the two validated and extracted input parameters per * the specification of this classifier. @@ -79,7 +79,7 @@ internal class GenericRuleClassifier private constructor( fun matches(answer: AT, firstInput: ITF, secondInput: ITS): Boolean } - internal interface DoubleInputMatcher { + interface DoubleInputMatcher { /** * Returns whether the validated and extracted answer matches the two validated and extracted input parameters per * the specification of this classifier. @@ -87,11 +87,11 @@ internal class GenericRuleClassifier private constructor( fun matches(answer: T, firstInput: T, secondInput: T): Boolean } - internal sealed class MatcherDelegate { + sealed class MatcherDelegate { abstract fun matches(answer: InteractionObject, inputs: List): Boolean - internal class NoInputMatcherDelegate( + class NoInputMatcherDelegate( private val matcher: NoInputInputMatcher, private val extractObject: (InteractionObject) -> T ) : MatcherDelegate() { @@ -101,7 +101,7 @@ internal class GenericRuleClassifier private constructor( } } - internal class SingleInputMatcherDelegate( + class SingleInputMatcherDelegate( private val matcher: SingleInputMatcher, private val extractObject: (InteractionObject) -> T ) : MatcherDelegate() { @@ -111,7 +111,7 @@ internal class GenericRuleClassifier private constructor( } } - internal class MultiTypeSingleInputMatcherDelegate( + class MultiTypeSingleInputMatcherDelegate( private val matcher: MultiTypeSingleInputMatcher, private val extractAnswerObject: (InteractionObject) -> AT, private val extractInputObject: (InteractionObject) -> IT @@ -122,7 +122,7 @@ internal class GenericRuleClassifier private constructor( } } - internal class DoubleInputMatcherDelegate( + class DoubleInputMatcherDelegate( private val matcher: DoubleInputMatcher, private val extractObject: (InteractionObject) -> T ) : MatcherDelegate() { @@ -136,7 +136,7 @@ internal class GenericRuleClassifier private constructor( } } - internal class MultiTypeDoubleInputMatcherDelegate( + class MultiTypeDoubleInputMatcherDelegate( private val matcher: MultiTypeDoubleInputMatcher, private val extractAnswerObject: (InteractionObject) -> AT, private val extractFirstParamObject: (InteractionObject) -> ITF, @@ -154,8 +154,8 @@ internal class GenericRuleClassifier private constructor( } /** Factory to create new [GenericRuleClassifier]s. */ - internal class Factory @Inject constructor( - private val interactionObjectTypeExtractorRepository: InteractionObjectTypeExtractorRepository + class Factory @Inject constructor( + val interactionObjectTypeExtractorRepository: InteractionObjectTypeExtractorRepository ) { /** Returns a new [GenericRuleClassifier] for an answer that is not matched to any input values. */ inline fun createNoInputClassifier( diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/InteractionObjectTypeExtractorRepository.kt b/domain/src/main/java/org/oppia/domain/classify/rules/InteractionObjectTypeExtractorRepository.kt index 451fae51ee2..5f769fca465 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/InteractionObjectTypeExtractorRepository.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/InteractionObjectTypeExtractorRepository.kt @@ -13,8 +13,8 @@ import kotlin.reflect.KClass * managing the enum->method relationship directly. */ @Singleton // Avoid recomputing the mapping multiple times. -internal class InteractionObjectTypeExtractorRepository @Inject constructor() { - private val extractors: Map> by lazy { +class InteractionObjectTypeExtractorRepository @Inject constructor() { + val extractors: Map> by lazy { computeExtractorMap() } @@ -40,7 +40,7 @@ internal class InteractionObjectTypeExtractorRepository @Inject constructor() { } } - internal data class ExtractorMapping( + data class ExtractorMapping( val extractionType: KClass, val genericExtractor: (InteractionObject) -> T ) diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYClassifierProvider.kt index a2ed060f210..07acfacab05 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYClassifierProvider.kt @@ -13,7 +13,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/03f16147e513ad31cbbf3ce882867a1aac99d649/extensions/interactions/DragAndDropSortInput/directives/drag-and-drop-sort-input-rules.service.ts#L78 */ -internal class DragDropSortInputHasElementXAtPositionYClassifierProvider @Inject constructor( +class DragDropSortInputHasElementXAtPositionYClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.MultiTypeDoubleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYClassifierProvider.kt index d8f246da7bb..cea3c809c88 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYClassifierProvider.kt @@ -13,7 +13,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/132b9d8f059253548ea1efadf1ff76416dfa2832/extensions/interactions/DragAndDropSortInput/directives/drag-and-drop-sort-input-rules.service.ts#L88 */ -internal class DragDropSortInputHasElementXBeforeElementYClassifierProvider @Inject constructor( +class DragDropSortInputHasElementXBeforeElementYClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.MultiTypeDoubleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProvider.kt index 658b1418f5d..6bca675db66 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProvider.kt @@ -13,7 +13,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/7d15d813ae6577367a5884af4beb0d6995f19251/extensions/interactions/DragAndDropSortInput/directives/drag-and-drop-sort-input-rules.service.ts#L65 */ -internal class DragDropSortInputIsEqualToOrderingClassifierProvider @Inject constructor( +class DragDropSortInputIsEqualToOrderingClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProvider.kt index 3cc62c9c5ef..0fff3c6ad8e 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProvider.kt @@ -14,7 +14,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/132b9d8f059253548ea1efadf1ff76416dfa2832/extensions/interactions/DragAndDropSortInput/directives/drag-and-drop-sort-input-rules.service.ts#L72 */ -internal class DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProvider +class DragDropSortInputIsEqualToOrderingWithOneItemIncorrectClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProvider.kt index 171f480a20d..a81ebb9d6be 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProvider.kt @@ -12,7 +12,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a9b0e7866cbcdf5f8193a6ac2fab64458a7/extensions/interactions/ImageClickInput/directives/image-click-input-rules.service.ts#L29 */ -internal class ImageClickInputIsInRegionRuleClassifierProvider @Inject constructor( +class ImageClickInputIsInRegionRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.MultiTypeSingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProvider.kt index 5e595273963..617d4932e31 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProvider.kt @@ -12,7 +12,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/MultipleChoiceInput/directives/multiple-choice-input-rules.service.ts#L21 */ -internal class MultipleChoiceInputEqualsRuleClassifierProvider @Inject constructor( +class MultipleChoiceInputEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProvider.kt index 9268ef5e5db..b28ec314f2e 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProvider.kt @@ -12,7 +12,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumericInput/directives/numeric-input-rules.service.ts#L21 */ -internal class NumericInputEqualsRuleClassifierProvider @Inject constructor( +class NumericInputEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputContainsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputContainsRuleClassifierProvider.kt index 5a35371e5ab..01c60cd11ca 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputContainsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputContainsRuleClassifierProvider.kt @@ -12,7 +12,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/TextInput/directives/text-input-rules.service.ts#L70 */ -internal class TextInputContainsRuleClassifierProvider @Inject constructor( +class TextInputContainsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt index acc46fcbf8e..4e2bfebbb96 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt @@ -12,7 +12,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/TextInput/directives/text-input-rules.service.ts#L24 */ -internal class TextInputEqualsRuleClassifierProvider @Inject constructor( +public class TextInputEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/domain/exploration/ExplorationRetriever.kt b/domain/src/main/java/org/oppia/domain/exploration/ExplorationRetriever.kt index 04ce5bb2ac9..6301b96c8fb 100644 --- a/domain/src/main/java/org/oppia/domain/exploration/ExplorationRetriever.kt +++ b/domain/src/main/java/org/oppia/domain/exploration/ExplorationRetriever.kt @@ -17,7 +17,7 @@ class ExplorationRetriever @Inject constructor( ) { // TODO(#169): Force callers of this method on a background thread. /** Loads and returns an exploration for the specified exploration ID, or fails. */ - internal fun loadExploration(explorationId: String): Exploration { + fun loadExploration(explorationId: String): Exploration { val explorationObject = jsonAssetRetriever.loadJsonFromAsset("$explorationId.json") ?: return Exploration.getDefaultInstance() diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 98ce40a06c0..d595f7a4108 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -17,7 +17,7 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, sr ) native.android_local_test( - name = name + "_test_lib", + name = name, custom_package = custom_package, test_class = test_class, manifest = test_manifest, @@ -28,5 +28,4 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, sr "@maven//:org_robolectric_robolectric", artifact("org.jetbrains.kotlin:kotlin-reflect"), ], - data = data ) From 67fee1870d03d2951b51ac0bc6edc50ce052ec24 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 17:18:53 -0400 Subject: [PATCH 066/120] 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 4865d01389f87ca0401fed4a2faa8981f0389628 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Thu, 23 Jul 2020 18:09:29 -0400 Subject: [PATCH 067/120] All tests now pass --- domain/domain_test.bzl | 3 ++- .../domain/exploration/ExplorationDataControllerTest.kt | 1 + oppia_android_test.bzl | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/domain/domain_test.bzl b/domain/domain_test.bzl index cb6f1e73a8e..cea4a032680 100644 --- a/domain/domain_test.bzl +++ b/domain/domain_test.bzl @@ -9,5 +9,6 @@ def domain_test(name, src, test_class): custom_package = "org.oppia.domain", test_class = test_class, test_manifest = "src/test/TestManifest.xml", - data = native.glob(["src/main/assets/**"]), + assets = native.glob(["src/main/assets/**"]), + assets_dir = "src/main/assets/", ) diff --git a/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt b/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt index 27fd98a7997..e9b427d87fd 100644 --- a/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt @@ -165,6 +165,7 @@ class ExplorationDataControllerTest { ) verify(mockExplorationObserver, atLeastOnce()).onChanged(explorationResultCaptor.capture()) + explorationResultCaptor.value.getErrorOrNull()?.printStackTrace() assertThat(explorationResultCaptor.value.isSuccess()).isTrue() assertThat(explorationResultCaptor.value.getOrThrow()).isNotNull() val exploration = explorationResultCaptor.value.getOrThrow() diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index d595f7a4108..538544eda84 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, test_class, src_library_name, - data=None, resource_files=None): + assets=None, assets_dir=None, resource_files=None): kt_android_library( name = name + "_lib", @@ -13,7 +13,8 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, sr deps = [ ":" + src_library_name, ], - data = data, + assets = assets, + assets_dir = assets_dir, ) native.android_local_test( From ab9e295a7edf658df0844c4153de7ad44fbc90bc Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 11:20:41 -0400 Subject: [PATCH 068/120] Firebase dependency errors have been resolved --- WORKSPACE | 6 +++++- utility/BUILD.bazel | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 2c308bf3c4d..ed756a198f1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -112,7 +112,11 @@ maven_install( "org.mockito:mockito-core:2.19.0", "androidx.test.ext:junit:1.1.1", "android.arch.core:core-testing:1.1.1", - "androidx.arch.core:core-testing:2.1.0" + "androidx.arch.core:core-testing:2.1.0", + "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 9216345fa13..dfe88e0202a 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -7,13 +7,17 @@ load("//utility:utility_test.bzl", "utility_test") kt_android_library( name = "utility_lib", 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"]), + #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("com.google.firebase:firebase-analytics:17.4.4"), + artifact("com.google.firebase:firebase-crashlytics:17.1.1"), artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), artifact("com.caverock:androidsvg-aar"), From c6bbbf48fbd1715bacdaa35ce4bf537a65b78467 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 11:26:42 -0400 Subject: [PATCH 069/120] Save firebase dependency fixes for new PR --- WORKSPACE | 4 ---- utility/BUILD.bazel | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index ed756a198f1..f5561c4b720 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -113,10 +113,6 @@ maven_install( "androidx.test.ext:junit:1.1.1", "android.arch.core:core-testing:1.1.1", "androidx.arch.core:core-testing:2.1.0", - "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 dfe88e0202a..456f8c7a0d1 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -8,16 +8,12 @@ kt_android_library( name = "utility_lib", custom_package = "org.oppia.util", srcs = glob(["src/main/java/org/oppia/util/**/*.kt"]), - #exclude = ["src/main/java/org/oppia/util/logging/firebase/*.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("com.google.firebase:firebase-analytics:17.4.4"), - artifact("com.google.firebase:firebase-crashlytics:17.1.1"), artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), artifact("com.caverock:androidsvg-aar"), From 5c1b4dd86c5b9c18af6fb21dfdb20e2b2f880773 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 11:30:17 -0400 Subject: [PATCH 070/120] Fixed typo --- utility/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 456f8c7a0d1..9216345fa13 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -7,7 +7,7 @@ load("//utility:utility_test.bzl", "utility_test") kt_android_library( name = "utility_lib", custom_package = "org.oppia.util", - srcs = glob(["src/main/java/org/oppia/util/**/*.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", From 48eb9be3d8a1a01e1f3d59a62f77341a9f6ef8a4 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 11:40:53 -0400 Subject: [PATCH 071/120] 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 072/120] 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 073/120] 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 b6240dfc85ba50af7f74d3edd07adb6441c2ca04 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Fri, 24 Jul 2020 12:12:14 -0400 Subject: [PATCH 074/120] Firebase dependencies added --- utility/BUILD.bazel | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 67dd6bccb4e..8b5da2b1a2f 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -7,8 +7,7 @@ load("//utility:utility_test.bzl", "utility_test") kt_android_library( name = "utility_lib", 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 = [ @@ -32,8 +31,7 @@ kt_android_library( kt_android_library( name = "utility_test_lib", custom_package = "org.oppia.util", - srcs = glob(["src/test/java/org/oppia/util/**/*.kt"], - exclude = ["src/test/java/org/oppia/util/logging/firebase/*.kt"]), + srcs = glob(["src/test/java/org/oppia/util/**/*.kt"],), resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/test/TestManifest.xml", deps = [ @@ -41,6 +39,10 @@ kt_android_library( ":utility_lib", "//testing:testing_lib", "//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.kotlin:kotlin-test-junit"), artifact("com.google.truth:truth"), artifact("androidx.test.ext:junit"), From 8d6b28f8c1b55acfd51466a393e676ce00152dda Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 11:23:49 -0400 Subject: [PATCH 075/120] 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 076/120] 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 077/120] 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 078/120] 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 079/120] 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 080/120] 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 081/120] 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 082/120] 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 083/120] 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 084/120] 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 085/120] 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 ec75eda93c136d274ccf9e8e480b72ac6ba9286d Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 13:46:12 -0400 Subject: [PATCH 086/120] Fixed nits and error with testing lib dependencies --- testing/BUILD.bazel | 3 --- 1 file changed, 3 deletions(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index c99cb2a064c..946cc9733de 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -17,13 +17,10 @@ kt_android_library( 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 f9ac84f70ccd4cc0693b278de49601a93b0de460 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 13:50:16 -0400 Subject: [PATCH 087/120] Removed printStackTrace() --- .../oppia/domain/exploration/ExplorationDataControllerTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt b/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt index e9b427d87fd..27fd98a7997 100644 --- a/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt @@ -165,7 +165,6 @@ class ExplorationDataControllerTest { ) verify(mockExplorationObserver, atLeastOnce()).onChanged(explorationResultCaptor.capture()) - explorationResultCaptor.value.getErrorOrNull()?.printStackTrace() assertThat(explorationResultCaptor.value.isSuccess()).isTrue() assertThat(explorationResultCaptor.value.getOrThrow()).isNotNull() val exploration = explorationResultCaptor.value.getOrThrow() From a7c6a53847beb76463cfff37afa97c1973c9f2c8 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 14:01:11 -0400 Subject: [PATCH 088/120] Removed addressed TODOs, all tests pass --- data/BUILD.bazel | 6 +++--- domain/BUILD.bazel | 9 +-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/data/BUILD.bazel b/data/BUILD.bazel index be01bee5b57..018b9a09c5e 100644 --- a/data/BUILD.bazel +++ b/data/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") @@ -6,7 +7,6 @@ kt_android_library( name = "cache_store_lib", custom_package = "org.oppia.data.persistence", srcs = glob(["src/main/java/org/oppia/data/persistence/*.kt"]), - #resource_files = glob(["src/main/res/**/*.xml"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", @@ -17,7 +17,7 @@ kt_android_library( artifact("com.caverock:androidsvg-aar"), artifact("androidx.lifecycle:lifecycle-livedata-ktx"), ], - visibility = ["//visibility:public"] + visibility = ["//visibility:public"], ) -dagger_rules() \ No newline at end of file +dagger_rules() diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index c270abcca56..022e4f64f00 100644 --- a/domain/BUILD.bazel +++ b/domain/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") @@ -144,14 +145,12 @@ domain_test( + "TextInputEqualsRuleClassifierProviderTest", ) -#TODO: Building not passing domain_test( name = "ExplorationDataControllerTest", src = ["src/test/java/org/oppia/domain/exploration/ExplorationDataControllerTest.kt"], test_class = "org.oppia.domain.exploration.ExplorationDataControllerTest", ) -#TODO: Building not passing domain_test( name = "ExplorationProgressControllerTest", src = ["src/test/java/org/oppia/domain/exploration/ExplorationProgressControllerTest.kt"], @@ -182,14 +181,12 @@ domain_test( test_class = "org.oppia.domain.profile.ProfileTestHelperTest", ) -#TODO: Building not passing domain_test( name = "QuestionAssessmentProgressControllerTest", src = ["src/test/java/org/oppia/domain/question/QuestionAssessmentProgressControllerTest.kt"], test_class = "org.oppia.domain.question.QuestionAssessmentProgressControllerTest", ) -#TODO: Building not passing domain_test( name = "QuestionTrainingControllerTest", src = ["src/test/java/org/oppia/domain/question/QuestionTrainingControllerTest.kt"], @@ -202,21 +199,18 @@ domain_test( test_class = "org.oppia.domain.topic.StoryProgressControllerTest", ) -#TODO: Building not passing domain_test( name = "StoryProgressTestHelperTest", src = ["src/test/java/org/oppia/domain/topic/StoryProgressTestHelperTest.kt"], test_class = "org.oppia.domain.topic.StoryProgressTestHelperTest", ) -#TODO: Building not passing domain_test( name = "TopicControllerTest", src = ["src/test/java/org/oppia/domain/topic/TopicControllerTest.kt"], test_class = "org.oppia.domain.topic.TopicControllerTest", ) -#TODO: Building not passing domain_test( name = "TopicListControllerTest", src = ["src/test/java/org/oppia/domain/topic/TopicListControllerTest.kt"], @@ -229,7 +223,6 @@ domain_test( test_class = "org.oppia.domain.util.InteractionObjectExtensionsTest", ) -#TODO: Building not passing domain_test( name = "StateRetrieverTest", src = ["src/test/java/org/oppia/domain/util/StateRetrieverTest.kt"], From b618e18b5b544eea72895ad7cf77b9b55a1646bd Mon Sep 17 00:00:00 2001 From: miaboloix Date: Mon, 27 Jul 2020 14:06:23 -0400 Subject: [PATCH 089/120] Removed redundant public modifier --- .../rules/textinput/TextInputEqualsRuleClassifierProvider.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt index 4e2bfebbb96..ccfcd5bbe35 100644 --- a/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProvider.kt @@ -12,7 +12,7 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/TextInput/directives/text-input-rules.service.ts#L24 */ -public class TextInputEqualsRuleClassifierProvider @Inject constructor( +class TextInputEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { From 364435d0ad71e7bde21441e598568f185f7ba190 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Tue, 28 Jul 2020 16:09:29 -0400 Subject: [PATCH 090/120] 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 091/120] 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 092/120] 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 093/120] 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 094/120] 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 095/120] 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 096/120] 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 097/120] 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 098/120] 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 099/120] 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 100/120] 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 101/120] 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 102/120] 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 103/120] 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 104/120] 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 105/120] 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 106/120] 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 107/120] 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 108/120] 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 109/120] 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 110/120] 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 111/120] 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 4f8e77fabb3311f153fc906f73ef6dd445b890cb Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 12:28:24 -0400 Subject: [PATCH 112/120] Added comment to utility_test.bzl --- oppia_android_test.bzl | 4 ++-- utility/utility_test.bzl | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 11 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", diff --git a/utility/utility_test.bzl b/utility/utility_test.bzl index b6c3d060356..c6180397cd5 100644 --- a/utility/utility_test.bzl +++ b/utility/utility_test.bzl @@ -1,13 +1,18 @@ load("//:oppia_android_test.bzl", "oppia_android_test") def utility_test(name, src, test_class): + ''' + This macro exists as a way to customize the oppia_android_test() macro for the utility 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 = "utility_test_lib", - custom_package = "org.oppia.util", - test_class = test_class, - test_manifest = "src/test/TestManifest.xml", - ) + oppia_android_test( + name = name, + srcs = src, + resource_files = native.glob(["src/main/res/**/*.xml"]), + src_library_name = "utility_test_lib", + custom_package = "org.oppia.util", + test_class = test_class, + test_manifest = "src/test/TestManifest.xml", + ) From 0b9c14ae550c5ba27e0779530c3aabd07fd8112a Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 12:30:43 -0400 Subject: [PATCH 113/120] 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 17c92b32f2540f259e7cf1e9c90fabf6516f679e Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 12:49:31 -0400 Subject: [PATCH 114/120] Fixed typos and all tests pass --- utility/BUILD.bazel | 17 +++-------------- utility/utility_test.bzl | 4 ++-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 91ac2f185fb..94ce8514615 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -25,15 +25,10 @@ kt_android_library( "//model", "//firebase:crashlytics", "//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-android"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), - artifact("com.google.truth:truth"), + artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), artifact("com.caverock:androidsvg-aar"), - artifact("androidx.lifecycle:lifecycle-livedata-ktx"), ], visibility = ["//visibility:public"], ) @@ -43,24 +38,18 @@ kt_android_library( custom_package = "org.oppia.util", srcs = glob(["src/test/java/org/oppia/util/**/*.kt"],), resource_files = glob(["src/main/res/**/*.xml"]), - manifest = "src/test/TestManifest.xml", + manifest = "src/test/AndroidManifest.xml", deps = [ ":dagger", ":utility", "//testing", "//model", - "//firebase:crashlytics_lib", + "//firebase:crashlytics", "//firebase:crashlytics_deps", - artifact("com.google.firebase:firebase-analytics:17.4.4"), - artifact("com.google.firebase:firebase-crashlytics:17.1.1"), artifact("org.jetbrains.kotlin:kotlin-test-junit"), artifact("com.google.truth:truth"), artifact("androidx.test.ext:junit"), artifact("org.mockito:mockito-core"), - artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core"), - artifact("androidx.appcompat:appcompat"), - artifact("com.github.bumptech.glide:glide"), - artifact("com.caverock:androidsvg-aar"), ], visibility = ["//visibility:public"], ) diff --git a/utility/utility_test.bzl b/utility/utility_test.bzl index c6180397cd5..0c3a6fedc05 100644 --- a/utility/utility_test.bzl +++ b/utility/utility_test.bzl @@ -11,8 +11,8 @@ def utility_test(name, src, test_class): name = name, srcs = src, resource_files = native.glob(["src/main/res/**/*.xml"]), - src_library_name = "utility_test_lib", + src_library_name = "utility_tests", custom_package = "org.oppia.util", test_class = test_class, - test_manifest = "src/test/TestManifest.xml", + test_manifest = "src/test/AndroidManifest.xml", ) From fc7170f2de59e72f2f6f7be8649a552667141c83 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 12:52:03 -0400 Subject: [PATCH 115/120] Removed empty line --- utility/BUILD.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/utility/BUILD.bazel b/utility/BUILD.bazel index 94ce8514615..4f28b962794 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -54,7 +54,6 @@ kt_android_library( visibility = ["//visibility:public"], ) - utility_test( name = "AsyncResultTest", src = ["src/test/java/org/oppia/util/data/AsyncResultTest.kt"], From dc8ad1335982fd327e0a076869116067de24e859 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 13:28:16 -0400 Subject: [PATCH 116/120] Fixed errors from merge --- data/BUILD.bazel | 12 +++++--- domain/BUILD.bazel | 29 ++++++++++--------- domain/domain_test.bzl | 4 +-- .../{TestManifest.xml => AndroidManifest.xml} | 4 +-- oppia_android_test.bzl | 6 ++-- 5 files changed, 32 insertions(+), 23 deletions(-) rename domain/src/test/{TestManifest.xml => AndroidManifest.xml} (66%) diff --git a/data/BUILD.bazel b/data/BUILD.bazel index 018b9a09c5e..c1aa7fc5f51 100644 --- a/data/BUILD.bazel +++ b/data/BUILD.bazel @@ -1,17 +1,21 @@ -# 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") kt_android_library( - name = "cache_store_lib", + name = "cache_store", custom_package = "org.oppia.data.persistence", srcs = glob(["src/main/java/org/oppia/data/persistence/*.kt"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - "//model:model_lib", - "//utility:utility_lib", + "//model", + "//utility", artifact("androidx.appcompat:appcompat"), artifact("com.github.bumptech.glide:glide"), artifact("com.caverock:androidsvg-aar"), diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 022e4f64f00..2f1cd111aee 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -1,42 +1,45 @@ -# 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") load("//domain:domain_test.bzl", "domain_test") kt_android_library( - name = "domain_lib", + name = "domain", custom_package = "org.oppia.domain", srcs = glob(["src/main/java/org/oppia/domain/**/*.kt"]), data = glob(["src/main/assets/**"]), manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - "//model:model_lib", - "//data:cache_store_lib", - "//testing:testing_lib", + #"//model", + "//data:cache_store", + #"//testing", ], visibility = ["//visibility:public"], ) kt_android_library( - name = "domain_test_lib", + name = "domain_tests", custom_package = "org.oppia.domain", - srcs = glob(["src/test/java/org/oppia/domain/**/*.kt"]), + srcs = glob(["src/test/java/org/oppia/domain/**"]), data = glob(["src/main/assets/**"]), - manifest = "src/test/TestManifest.xml", + manifest = "src/test/AndroidManifest.xml", deps = [ ":dagger", - ":domain_lib", - "//model:model_lib", - "//data:cache_store_lib", - "//testing:testing_lib", + ":domain", + "//model", + "//data:cache_store", + "//testing", "@robolectric//bazel:android-all", artifact("com.google.truth:truth"), artifact("androidx.test.ext:junit"), artifact("org.jetbrains.kotlin:kotlin-test-junit"), artifact("androidx.arch.core:core-testing"), - artifact("org.jetbrains.kotlin:kotlin-reflect"), ], visibility = ["//visibility:public"], ) diff --git a/domain/domain_test.bzl b/domain/domain_test.bzl index cea4a032680..749b784a8d6 100644 --- a/domain/domain_test.bzl +++ b/domain/domain_test.bzl @@ -5,10 +5,10 @@ def domain_test(name, src, test_class): oppia_android_test( name = name, srcs = src, - src_library_name = "domain_test_lib", + src_library_name = "domain_tests", custom_package = "org.oppia.domain", test_class = test_class, - test_manifest = "src/test/TestManifest.xml", + test_manifest = "src/test/AndroidManifest.xml", assets = native.glob(["src/main/assets/**"]), assets_dir = "src/main/assets/", ) diff --git a/domain/src/test/TestManifest.xml b/domain/src/test/AndroidManifest.xml similarity index 66% rename from domain/src/test/TestManifest.xml rename to domain/src/test/AndroidManifest.xml index e1c76297cbe..2dc4e167ac0 100644 --- a/domain/src/test/TestManifest.xml +++ b/domain/src/test/AndroidManifest.xml @@ -1,6 +1,6 @@ - + diff --git a/oppia_android_test.bzl b/oppia_android_test.bzl index 427dd6c9dc4..793618dad77 100644 --- a/oppia_android_test.bzl +++ b/oppia_android_test.bzl @@ -1,8 +1,8 @@ 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): +def oppia_android_test(name, srcs, test_manifest, custom_package, test_class, src_library_name, + resource_files=None, assets=None, assets_dir=None): ''' 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 @@ -18,6 +18,8 @@ def oppia_android_test(name, srcs, test_manifest, custom_package, resource_files deps = [ ":" + src_library_name, ], + assets = assets, + assets_dir = assets_dir, ) native.android_local_test( From 53828c05506d6d141c770be55bc4fe975a6d4d54 Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 13:34:01 -0400 Subject: [PATCH 117/120] Added comments to data and domain BUILD files --- data/BUILD.bazel | 2 +- domain/BUILD.bazel | 8 +++++++- utility/BUILD.bazel | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/data/BUILD.bazel b/data/BUILD.bazel index c1aa7fc5f51..34a43dc5464 100644 --- a/data/BUILD.bazel +++ b/data/BUILD.bazel @@ -1,6 +1,6 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' - +This library provides data to the rest of the application. ''' load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 2f1cd111aee..b692a7d1a80 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -1,6 +1,12 @@ # TODO(#1532): Rename file to 'BUILD' post-Gradle. ''' - +This library contains the frontend controller and business service logic for the application. +It also contains Robolectric and JUnit tests for it's Kotlin files. +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. +In order to eliminate duplicate code, a custom macro domain_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 4f28b962794..c15c9d41334 100644 --- a/utility/BUILD.bazel +++ b/utility/BUILD.bazel @@ -5,6 +5,8 @@ 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. +In order to eliminate duplicate code, a custom macro utility_test() has been written to streamline +testing in this module. ''' load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") From 578ef768c5fca52c1058ea33ab54e4aa50490d4b Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 13:35:29 -0400 Subject: [PATCH 118/120] Fixed indentation in domain_test --- domain/domain_test.bzl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/domain/domain_test.bzl b/domain/domain_test.bzl index 749b784a8d6..a0c2853a8eb 100644 --- a/domain/domain_test.bzl +++ b/domain/domain_test.bzl @@ -2,13 +2,13 @@ load("//:oppia_android_test.bzl", "oppia_android_test") def domain_test(name, src, test_class): - oppia_android_test( - name = name, - srcs = src, - src_library_name = "domain_tests", - custom_package = "org.oppia.domain", - test_class = test_class, - test_manifest = "src/test/AndroidManifest.xml", - assets = native.glob(["src/main/assets/**"]), - assets_dir = "src/main/assets/", - ) + oppia_android_test( + name = name, + srcs = src, + src_library_name = "domain_tests", + custom_package = "org.oppia.domain", + test_class = test_class, + test_manifest = "src/test/AndroidManifest.xml", + assets = native.glob(["src/main/assets/**"]), + assets_dir = "src/main/assets/", + ) From 65eaa1de76bfb24bfc188e603313c0c8baf144ed Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 13:36:42 -0400 Subject: [PATCH 119/120] Removed commented-out dependencies --- domain/BUILD.bazel | 2 -- 1 file changed, 2 deletions(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index b692a7d1a80..77ca806c8f5 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -22,9 +22,7 @@ kt_android_library( manifest = "src/main/AndroidManifest.xml", deps = [ ":dagger", - #"//model", "//data:cache_store", - #"//testing", ], visibility = ["//visibility:public"], ) From 818440af6da1fdb51edc49209428624001b8b6fc Mon Sep 17 00:00:00 2001 From: miaboloix Date: Wed, 29 Jul 2020 16:28:07 -0400 Subject: [PATCH 120/120] Started convertin correct_answer to interaction object --- .../data/backends/gae/model/GaeSolution.kt | 2 +- .../org/oppia/domain/util/StateRetriever.kt | 20 +++++++++---------- model/src/main/proto/exploration.proto | 16 +++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/data/src/main/java/org/oppia/data/backends/gae/model/GaeSolution.kt b/data/src/main/java/org/oppia/data/backends/gae/model/GaeSolution.kt index 0c58247ec30..69fbc5745f2 100755 --- a/data/src/main/java/org/oppia/data/backends/gae/model/GaeSolution.kt +++ b/data/src/main/java/org/oppia/data/backends/gae/model/GaeSolution.kt @@ -12,7 +12,7 @@ data class GaeSolution( @Json(name = "interaction_id") val interactionId: String?, @Json(name = "answer_is_exclusive") val isAnswerExclusive: Boolean?, - @Json(name = "correct_answer") val correctAnswer: String?, + @Json(name = "correct_answer") val correctAnswer: Any?, @Json(name = "explanation") val explanation: GaeSubtitledHtml? ) diff --git a/domain/src/main/java/org/oppia/domain/util/StateRetriever.kt b/domain/src/main/java/org/oppia/domain/util/StateRetriever.kt index 216fad9ddce..91b2e175268 100644 --- a/domain/src/main/java/org/oppia/domain/util/StateRetriever.kt +++ b/domain/src/main/java/org/oppia/domain/util/StateRetriever.kt @@ -193,19 +193,19 @@ class StateRetriever @Inject constructor( .build() } - private fun createCorrectAnswer(containerObject: JSONObject): CorrectAnswer { + private fun createCorrectAnswer(containerObject: JSONObject): InteractionObject { val correctAnswerObject = containerObject.optJSONObject("correct_answer") return if (correctAnswerObject != null) { - CorrectAnswer.newBuilder() - .setNumerator(correctAnswerObject.getInt("numerator")) - .setDenominator(correctAnswerObject.getInt("denominator")) - .setWholeNumber(correctAnswerObject.getInt("wholeNumber")) - .setIsNegative(correctAnswerObject.getBoolean("isNegative")) - .build() +// CorrectAnswer.newBuilder() +// .setNumerator(correctAnswerObject.getInt("numerator")) +// .setDenominator(correctAnswerObject.getInt("denominator")) +// .setWholeNumber(correctAnswerObject.getInt("wholeNumber")) +// .setIsNegative(correctAnswerObject.getBoolean("isNegative")) +// .build() } else { - CorrectAnswer.newBuilder() - .setCorrectAnswer(containerObject.getString("correct_answer")) - .build() +// CorrectAnswer.newBuilder() +// .setCorrectAnswer(containerObject.getString("correct_answer")) +// .build() } } diff --git a/model/src/main/proto/exploration.proto b/model/src/main/proto/exploration.proto index 44f2552f295..182646bd2e6 100644 --- a/model/src/main/proto/exploration.proto +++ b/model/src/main/proto/exploration.proto @@ -110,7 +110,7 @@ message Solution { // Flag that is true if correct_answer is the only correct answer of the question. bool answer_is_exclusive = 2; // correct_answer of the State. - CorrectAnswer correct_answer = 3; + InteractionObject correct_answer = 3; // Core explanation to the correct answer. SubtitledHtml explanation = 4; // To check if the solution was revealed or not by the learner. @@ -119,13 +119,13 @@ message Solution { // Structure for a Correct answer in Solution // Maps from: data/src/main/java/org/oppia/data/backends/gae/model/GaeSolution.kt -message CorrectAnswer { - int32 denominator = 1; - int32 numerator = 2; - int32 whole_number = 3; - bool is_negative = 4; - string correct_answer = 5; -} +//message CorrectAnswer { +// int32 denominator = 1; +// int32 numerator = 2; +// int32 whole_number = 3; +// bool is_negative = 4; +// string correct_answer = 5; +//} // Structure for a single hint // Maps from: data/src/main/java/org/oppia/data/backends/gae/model/GaeHint.kt