Skip to content

Commit

Permalink
Fixes #1678: Optimize Bazel protobuf rules install [BLOCKED: #1634] (#…
Browse files Browse the repository at this point in the history
…1679)

* Translated RecyclerViewBindingAdapter

* Deleted kotlin binding adapters

* Translated GuidelineBindingAdapter

* Translated StateAssemblerMarginBindingAdapters

* Translated StateAssemblerPaddingBindingAdapters

* Almost finished translating ViewBindingAdapter

* Fixed the duplicate google-services.json issue

* Created Issue and added TODO

* Translated ViewBindingAdapter

* Added minSDK back

* Alphabetized dependencies

* Fixed firebase target

* Trying to fix StateRetreiverTest

* Binding Adapter files are building with Gradle!

* Fixed ktlint violation

* Revert "Deleted kotlin binding adapters"

This reverts commit 84037cb.

* Revert "Translated GuidelineBindingAdapter"

This reverts commit ce92d0a.

* Revert "Translated StateAssemblerMarginBindingAdapters"

This reverts commit 88c9492.

* Revert "Translated StateAssemblerPaddingBindingAdapters"

This reverts commit d66af07.

* Git mv on DrawableBindingAdapters

* Translated DrawableBindingAdapters

* Deleted java files

* Translated EditTextBA and GuidelineBA

* Translated ImageViewBA

* Added missing semicolon

* Translated MarginBindingAdapters

* Translated State AssemblerMarginBA

* Translated StateAssemblerPaddingBA

* Translated TextViewBA

* Revert "Translated TextViewBA"

This reverts commit 849549d.

* Changed targetSdk to 28

* Revert "Revert "Translated TextViewBA""

This reverts commit 6cfa75d.

* Fixed formatting issues and changed NotNull to NonNull

* Refactored GuidelineBindingAdapter to be GuidelineBindingAdapters

* Fixed some double space errors and other typos

* Added missing ViewBindingAdapter

* Deleted extra spaces and fixed more nit issues

* Made all classes final

* Added top level documentation

* Reformatted some comments to fit java style

* Reformatted imports

* Created Issue and added TODOs for re-restricitng access

* Added min and target SDK to domain manifest

* Added documentation comment

* Deleted unused domain_tests library

* Revert "Deleted unused domain_tests library"

This reverts commit 65e71cc.

* Removed unused domain)tests library

* Annotations and helpers library builds

* Listeners library builds

* View models build

* Views now build

* Added documentation comments

* Started removing binding dependencies from views

* Removed fragment imports used only for comments in order to build view files

* Pulled binding dependenvy out of ConceptCardViewModel

* Edited R import statements for Bazel to build

* Fixed more errors, view_model builds

* Worked through more errors

* Added a dependency

* View library builds

* Ordered BUILD file for better merging

* Both databinding adapters and recyclerview adapters are building

* Starting writing databinding resources library

* Removed unused listeners

* Added missing comments

* Formatted files and added missing @nonnull annotations

* Fixed ktlint errors

* Revert "Formatted files and added missing @nonnull annotations"

This reverts commit 84b6125.

* Added genrule for viewmodel files

* Added view genrule

* Both Bazel and Gradle are building

* Fixed ktlint errors

* Delete vcs.xml

* Renamed files, deleted unused files, and added some documentation

* Improved implementation of some functions in ViewBindingShimImpl and added documentation

* Fixed ktlint errors

* Put genrules in a loop, created issue to remove genrules post-gradle and added TODO

* Added more documentation, created an issue to remove shim files, added TODO

* Fixed Gradle build error

* Added documentation, created an issue, added a TODO

* Formatted single line comments

* Fixing more nits

* Fixed more nits.

* Fixed getTimeAgo() function

* Suppressed warning in bindToRecyclerViewAdapter

* Builds in both Bazel and Gradle

* Added comments to BUILD file

* Fixed profile_chooser_profile_view error

* Fixed profile_chooser_add_view

* Fixed walthrough_final_fragment error

* Fixed profile_chooser_fragment error

* Fixed walthrough_activity error

* Fixed onboarding_fragment error

* Fixed audio_fragment error

* Fixed unused presnter errors, databining resources now build

* Builds with Gradle

* Fixed WalkthroughWelcomeFragmentPresenter to not contain unnecessary methods bc of interface

* Removed unnecessary method from WalkthroughActivity

* Removed the need for ProfileChooserListener, added comments to WalkthroughListeners

* Genrule is working

* Simplified genrule

* Alphabetized lists in app module BUILD

* Quick cleanup, added missing documentation

* App library is building with Bazel

* Added Retrofit+Gson dependency for NetworkModule to build with Gradle

* Binary builds

* Started debugging runtime errors

* Fixed domain BUILD

* Added genrule comments, simplified gnerule targets in lists

* Fixed QuestionPlayerFragmentPresenter and StateFragmentPresenter

* Fixed QuestionPlayerViewModel & FRagmentPresenter as well as StateViewModel & FragmentPresenter

* Fixed some nits

* Fixed ktlint errors

* Added assets

* First test builds and passes

* Fixed DragDrop ViewBinding implementations, added modules to TestComponent

* Fix ktlint errors

* Fixed nits in TextViewBA

* Fixed Audio + Language test appearance bug

* Fixed ktlint errors

* Fixed ktlint error in FAQSingleActivityPresenter

* Fixed ktlin errors

* Cleaned up app BUILD file a bit

* Testing module tests now pass, all domain tests pass except StateRetreiver

* Removed unused dependencies, aplhabetized dependencies

* Fixed list formation

* Cleaned up BUILD

* Fixed nits

* Fixing some nits

* Refactored file names

* Altered walkthrough welcome fragment

* Renamed wasProfileEverBeenAddedValue to hasProfileEverBeenAddedValue

* Fixed ktlint error

* Removed unused dependencies and alphabetized them

* Deleted unused methods in ImageViewBA

* Removed data attribute from domain library

* Excluded DataBinderMapperImpl from Gradle build

* Most tests build and pass

* Started getting sharedTests to run

* All tests now build

* Fixed ktlint errors

* Fixed ktlint error

* Added missing TODOs

* Fixed merge errors

* Fixed nits

* Removed unnecessary field in StateFragmentAccessibilityTest

* Fixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTestFixed StateFragmentAccessibilityTest

* Injected context in AppVersionViewModel

* Used lambda function to resolve issues with QuestionPlayerVM and QuestionPlayerFragmentPresenter

* Fixed small errors

* Fixed ktlint errors

* Removed Moshi dependency from NetworkModule

* Fixed ktlint error

* Fixing listener file naming

* Fixed NetworkModule issue by removing it from ApplicationComponent temporarily

* Restored NetworkModule, fixed some nits

* Fixed typo, deleted unused file, removed retrofit gradle dependencies

* Removed NetworkModule from test files, fixed nits, fixed enable_data_binding in oppia_android_test

* Fixing nits

* Fixed more nits

* Fixed StateFragmentPresenter and view model, fixed some nits

* Fixed ktlint errors

* Altered for loop to append directly to DATABINDING_ADAPTERS

* Created issue and added TODO for ApplicationComponent and NetworkModule

* Added TODOs to test files with NetworkModule removed, added documentation to DataBinderMapperImple, fixed nits

* Added documentations, fixed nits

* Added proto optimization

* Fixed nits

* Fixed ktlint error

* Added documentation, fixed nits

* Added a few nits

* Removed unused imports

* Fixed nits

* Created issue, added TODO, updated docs

* Starting to put genrules into a macro

* Fixed documentation

* Added comment about binding adapters in Java

* Created test_with_resources and applied it to tests

* Add more context

* Fixed nits, created a PackageManagerHelper file

* Update WORKSPACE with Markdown

Co-authored-by: Ben Henning <[email protected]>

* Fixed doumenting comment

* Update app/src/main/java/org/oppia/app/utility/PackageManagerHelper.kt

Co-authored-by: Ben Henning <[email protected]>

* Fixed inject issue and nits

* Fixed typo

* Changed filename, included new file in Annotations library

* Fixed lint error

Co-authored-by: Ben Henning <[email protected]>
  • Loading branch information
miaboloix and BenHenning committed Aug 22, 2020
1 parent 8cacffb commit 3093921
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 39 deletions.
34 changes: 12 additions & 22 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,20 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_reg
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",
],
'''
The proto_compiler and proto_java_toolchain bindings load the protos rules needed for the model
module while helping us avoid the unnecessary compilation of protoc. Referecences:
- https://github.com/google/startup-os/blob/5f30a62/WORKSPACE#L179-L187
- https://github.com/bazelbuild/bazel/issues/7095
'''
bind(
name = "proto_compiler",
actual = "//tools:protoc"
)

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",
],
bind(
name = "proto_java_toolchain",
actual = "//tools:java_toolchain"
)

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
Expand Down
14 changes: 0 additions & 14 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# TODO(#1532): Rename file to 'BUILD' post-Gradle.
'''
This library contains the app's core source files and functionality.
Note that:
- Most files should be built inside of app library. However, listener files, annotation
files, view files, view model files, and binding adapter files need to be manually added. The
Expand All @@ -21,7 +20,6 @@ load("//app:test_with_resources.bzl", "test_with_resources")
'''
Source files for the annotations library. The files inside the annotations library are dependencies
for all other libraries in app module, except the listeners library.
Place your file here if:
- A view, view model, or layout file depends on it
- It is an annotation or helper file of some kind
Expand All @@ -38,7 +36,6 @@ ANNOTATIONS = [
'''
Source files for the listeners library. The files inside the listeners library are dependencies for
all other libraries in app module, except the annotations library.
Place your file here if:
- A view, view model, or layout file depends on it
- It is either a listener, an interface, or a direct dependency of one in this list
Expand Down Expand Up @@ -91,7 +88,6 @@ LISTENERS = [

'''
Source files for the databinding_resources library.
The files inside this list include all layout files. Please note that layouts MUST NOT depend on
presenters or fragments. Instead, they should depend on a listener or interface as an abstraction.
'''
Expand All @@ -102,7 +98,6 @@ DATABINDING_LAYOUTS = ["src/main/res/layout*/**"]
# TODO(#1617): Remove genrules post-gradle
'''
Source files for the view_models library that import resources.
Place your file here if:
- It is a view model
- It imports resources (ex: `import org.oppia.app.R`)
Expand All @@ -123,7 +118,6 @@ VIEW_MODELS_WITH_RESOURCE_IMPORTS = [

'''
Source files for the view_models library that DO NOT import resources.
Place your file here if:
- It is a view model
- It does not import resources
Expand Down Expand Up @@ -245,7 +239,6 @@ VIEW_MODELS = [
# TODO(#1617): Remove genrules post-gradle
'''
Genrule for source files in the view_models library.
Because each databinding library must have a unique package name and manifest, resources must be
imported using the proper package name when building with Bazel. This genrule alters those imports
in order to keep Gradle building.
Expand All @@ -266,7 +259,6 @@ for file in VIEW_MODELS_WITH_RESOURCE_IMPORTS]
# TODO(#1617): Remove genrules post-gradle
'''
Source files for the views library that import resources.
Place your file here if:
- It is a view file
- It imports resources (ex: `import org.oppia.app.R`)
Expand All @@ -280,7 +272,6 @@ VIEWS_WITH_RESOURCE_IMPORTS = [

'''
Source files for the views library that DO NOT import resources.
Place your file here if:
- It is a view file
- It does not import resources
Expand All @@ -307,7 +298,6 @@ VIEWS = [
# TODO(#1617): Remove genrules post-gradle
'''
Genrule for source files in the views library.
Because each databinding library must have a unique package name and manifest, resources must be
imported using the proper package name when building with Bazel. This genrule alters those imports
in order to keep Gradle building.
Expand All @@ -328,7 +318,6 @@ for file in VIEWS_WITH_RESOURCE_IMPORTS]
# TODO(#1617): Remove genrules post-gradle
'''
Binding adapter files that import resources.
Place your file here if:
- It is a binding adapter
- It imports resources (ex: `import org.oppia.app.R`)
Expand All @@ -341,7 +330,6 @@ BINDING_ADAPTERS_WITH_RESOURCE_IMPORTS = [

'''
Binding adapter files that DO NOT import resources.
Place your file here if:
- It is a binding adapter
- It does not import resources
Expand All @@ -362,7 +350,6 @@ BINDING_ADAPTERS = [
# TODO(#1617): Remove genrules post-gradle
'''
Genrule for source files in the binding_adapters library.
Because each databinding library must have a unique package name and manifest, resources must be
imported using the proper package name when building with Bazel. This genrule alters those imports
in order to keep Gradle building.
Expand Down Expand Up @@ -397,7 +384,6 @@ APP_FILES_WITH_RESOURCE_IMPORTS = glob(["src/main/java/org/oppia/app/**/*.kt"],

'''
Genrule for source files in the app library.
Because each databinding library must have a unique package name and manifest, resources must be
imported using the proper package name when building with Bazel. This genrule alters those imports
in order to keep Gradle building.
Expand Down
3 changes: 0 additions & 3 deletions model/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ In Bazel, proto files are built using the proto_library() and java_lite_proto_li
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")

proto_library(
Expand Down

0 comments on commit 3093921

Please sign in to comment.