Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2643: Introduce canonical Bazel library structure & migrate util accessibility package #2775

Merged
merged 10 commits into from
Mar 7, 2021
46 changes: 46 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
# TODO(#1532): Rename file to 'BUILD' post-Gradle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we be replacing all instances of //visibility:public with one of these package groups?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think so. We may want to replace all instances with a package group, but the ones here are specifically corresponding to the types of libraries introduced in this PR.


# Corresponds to being accessible to all Oppia targets. This should be used for production APIs &
# modules that may be used both in production targets and in tests.
package_group(
name = "oppia_api_visibility",
packages = [
"//...",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this similar to oppia_binary_visibility below?

if not what packages does each cover, when do we need to use oppia_api_visibility & oppia_binary_visibility

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I tried making this clear in the documentation, but maybe it could use a bit more work. We'll generally be using API visibility unless something should only be accessible to the binary. I split them out to make the visibility groups themselves more explicit & to provide more control.

],
)

# Corresponds to being accessible to the Oppia binary. This should only be used by production-facing
# modules that must be included in the top-level binary in order for the app to build.
package_group(
name = "oppia_binary_visibility",
packages = [
"//",
],
)

# Corresponds to being accessible to Oppia tests. This should be used by fakes & test-only modules
# that can be included in tests for custom state arrangement or to satisfy upstream/downstream
# dependency requirements for components whose production implementations cannot be used in test
# environments.
# TODO(#2773): Remove the open visibility access granted here & instead restrict this access to only
# test targets.
package_group(
name = "oppia_testing_visibility",
packages = [
"//app/...",
"//data/...",
"//domain/...",
"//testing/...",
"//utility/...",
],
)

# Special visibility group specific to prod modules. This provides access to the module for both the
# Oppia binary & tests.
package_group(
name = "oppia_prod_module_visibility",
includes = [
":oppia_binary_visibility",
":oppia_testing_visibility",
],
)

# TODO(#1640): Move binary manifest to top-level package post-Gradle.
android_binary(
name = "oppia",
Expand Down
4 changes: 4 additions & 0 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ kt_android_library(
"//third_party:androidx_databinding_databinding-common",
"//third_party:androidx_databinding_databinding-runtime",
"//third_party:circularimageview_circular_image_view",
"//utility/src/main/java/org/oppia/android/util/accessibility",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've missed this earlier.

Why are we adding the deps in app/BUILD.bazel
and why not utility/BUILD.bazel

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is where the dependency is needed. It's not used by anything in utility, and to some extent, that's expected since utility is a collection of utility libraries to be used elsewhere in the codebase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean if there are any packages, which are directly used in the app module then we can directly add this in the app/BUILD.bazel?

but I think it would be better if we can pass it through utility/BUILD.bazel

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's how it should be. We're planning to get rid of all the top-level BUILD files--libraries should always depend as directly on the thing they need as possible. Occasionally we may introduce libraries that export parts of their implementation (which can be useful when versioning APIs), but that's something that would come after everything is modularized.

Happy to chat about this further, and I'm sure @fsharpasharp can provide some insight here, too.

],
)

Expand Down Expand Up @@ -632,6 +633,7 @@ kt_android_library(
"//third_party:com_google_android_flexbox",
"//third_party:javax_annotation_javax_annotation-api_jar",
"//utility",
"//utility/src/main/java/org/oppia/android/util/accessibility:prod_module",
],
)

Expand Down Expand Up @@ -697,6 +699,8 @@ TEST_DEPS = [
"//third_party:org_robolectric_annotations",
"//third_party:robolectric_android-all",
"//utility",
"//utility/src/main/java/org/oppia/android/util/accessibility",
"//utility/src/main/java/org/oppia/android/util/accessibility:test_module",
]

# App module tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.oppia.android.domain.oppialogger.loguploader.LogUploadWorkerModule
import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfigurationModule
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.util.accessibility.AccessibilityModule
import org.oppia.android.util.accessibility.AccessibilityProdModule
import org.oppia.android.util.caching.CachingModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -59,7 +59,7 @@ import javax.inject.Singleton
GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, CachingModule::class,
QuestionModule::class, LogReportingModule::class,
AccessibilityModule::class, ImageClickInputModule::class,
AccessibilityProdModule::class, ImageClickInputModule::class,
LogStorageModule::class, IntentFactoryShimModule::class,
ViewBindingShimModule::class, PrimeTopicAssetsControllerModule::class,
ExpirationMetaDataRetrieverModule::class, RatioInputModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.oppia.android.app.recyclerview.OnDragEndedListener
import org.oppia.android.app.recyclerview.OnItemDragListener
import org.oppia.android.app.shim.ViewBindingShim
import org.oppia.android.app.shim.ViewComponentFactory
import org.oppia.android.util.accessibility.CustomAccessibilityManager
import org.oppia.android.util.accessibility.AccessibilityChecker
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.parser.ExplorationHtmlParserEntityType
import org.oppia.android.util.parser.HtmlParser
Expand All @@ -39,7 +39,7 @@ class DragDropSortInteractionView @JvmOverloads constructor(
lateinit var htmlParserFactory: HtmlParser.Factory

@Inject
lateinit var accessibilityManager: CustomAccessibilityManager
lateinit var accessibilityChecker: AccessibilityChecker

@Inject
@field:ExplorationHtmlParserEntityType
Expand All @@ -60,7 +60,7 @@ class DragDropSortInteractionView @JvmOverloads constructor(
super.onAttachedToWindow()
(FragmentManager.findFragment<Fragment>(this) as ViewComponentFactory)
.createViewComponent(this).inject(this)
isAccessibilityEnabled = accessibilityManager.isScreenReaderEnabled()
isAccessibilityEnabled = accessibilityChecker.isScreenReaderEnabled()
}

fun allowMultipleItemsInSamePosition(isAllowed: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.oppia.android.app.shim.ViewBindingShim
import org.oppia.android.app.shim.ViewComponentFactory
import org.oppia.android.app.utility.ClickableAreasImage
import org.oppia.android.app.utility.OnClickableAreaClickedListener
import org.oppia.android.util.accessibility.CustomAccessibilityManager
import org.oppia.android.util.accessibility.AccessibilityChecker
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.parser.DefaultGcsPrefix
import org.oppia.android.util.parser.ExplorationHtmlParserEntityType
Expand Down Expand Up @@ -41,7 +41,7 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
private lateinit var listener: OnClickableAreaClickedListener

@Inject
lateinit var accessibilityManager: CustomAccessibilityManager
lateinit var accessibilityChecker: AccessibilityChecker

@Inject
lateinit var imageLoader: ImageLoader
Expand Down Expand Up @@ -132,7 +132,7 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
(FragmentManager.findFragment<Fragment>(this) as ViewComponentFactory)
.createViewComponent(this)
.inject(this)
isAccessibilityEnabled = accessibilityManager.isScreenReaderEnabled()
isAccessibilityEnabled = accessibilityChecker.isScreenReaderEnabled()
}

fun setOnRegionClicked(onRegionClicked: OnClickableAreaClickedListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.profile.ProfileTestHelper
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -556,7 +556,7 @@ class AdministratorControlsActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -228,7 +228,7 @@ class AppVersionActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.story.StoryProgressTestHelper
import org.oppia.android.testing.time.FakeOppiaClock
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -450,7 +450,7 @@ class CompletedStoryListActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -166,7 +166,7 @@ class FAQListFragmentTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration
import org.oppia.android.domain.question.QuestionModule
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.DefaultResourceBucketName
import org.oppia.android.util.gcsresource.GcsResourceModule
Expand Down Expand Up @@ -165,7 +165,7 @@ class FAQSingleActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.OppiaTestRule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.RunOn
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
import org.oppia.android.testing.TestPlatform
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -235,7 +235,7 @@ class HelpFragmentTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.domain.topic.TEST_TOPIC_ID_0
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.RunOn
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestLogReportingModule
Expand All @@ -88,6 +87,7 @@ import org.oppia.android.testing.profile.ProfileTestHelper
import org.oppia.android.testing.story.StoryProgressTestHelper
import org.oppia.android.testing.time.FakeOppiaClock
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -1445,7 +1445,7 @@ class HomeActivityTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, GlideImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ import org.oppia.android.domain.topic.FRACTIONS_STORY_ID_0
import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID
import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule
import org.oppia.android.testing.RobolectricModule
import org.oppia.android.testing.TestAccessibilityModule
import org.oppia.android.testing.TestCoroutineDispatchers
import org.oppia.android.testing.TestDispatcherModule
import org.oppia.android.testing.TestImageLoaderModule
Expand All @@ -78,6 +77,7 @@ import org.oppia.android.testing.profile.ProfileTestHelper
import org.oppia.android.testing.story.StoryProgressTestHelper
import org.oppia.android.testing.time.FakeOppiaClock
import org.oppia.android.testing.time.FakeOppiaClockModule
import org.oppia.android.util.accessibility.AccessibilityTestModule
import org.oppia.android.util.caching.testing.CachingTestModule
import org.oppia.android.util.gcsresource.GcsResourceModule
import org.oppia.android.util.logging.LoggerModule
Expand Down Expand Up @@ -838,7 +838,7 @@ class RecentlyPlayedFragmentTest {
DragDropSortInputModule::class, ImageClickInputModule::class, InteractionsModule::class,
GcsResourceModule::class, TestImageLoaderModule::class, ImageParsingModule::class,
HtmlParserEntityTypeModule::class, QuestionModule::class, TestLogReportingModule::class,
TestAccessibilityModule::class, LogStorageModule::class, CachingTestModule::class,
AccessibilityTestModule::class, LogStorageModule::class, CachingTestModule::class,
PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class,
ViewBindingShimModule::class, RatioInputModule::class,
ApplicationStartupListenerModule::class, LogUploadWorkerModule::class,
Expand Down
Loading