Fix part of #2747, #1532: Remove support for Gradle (#5652)
## Explanation
Fixes part of #2747
Fixes #1532
This PR is doing a lot to address the vast majority of #2747--removing
support for Gradle. It doesn't address everything, however--some items
will need to be addressed in future PRs (largely new cleanup
opportunities that are unlocked with the removal of Gradle). However, it
does remove the entirety of Gradle definition infrastructure.
This PR specifically:
- Removes all Gradle build definitions (``.gradle`` files,
``settings.gradle``, the ``gradlew`` wrappers, and the
``gradle/wrapper`` directory). As a side benefit, this removes some of
the last binary files from the codebase. :)
- Removes a bunch of Gradle-specific files not actually used by the
Bazel builds, including proguard-rules.pro files (Bazel has separate
definitions under ``config/proguard/``), some manifest files, and some
Robolectric-specific definitions.
- Deletes the ``main.yml`` workflow (which was disabled in #5629). This
is entirely a Gradle-specific workflow, so there's nothing that needs to
be moved over as all of what's being tested is covered more efficiently
and thoroughly in other specific workflow files.
- Updates to ``.gitignore`` per the Gradle file removals (fewer
files/directories need to be ignored).
- Removed all TODOs on #1532 and marking it as fixed as part of this PR
rather than performing the file rename. See
https://github.com/oppia/oppia-android/issues/1532#issuecomment-2610933772
for an explanation on why.
- Some comments have been updated rather than addressed where it made
sense that addressing the problem was not exactly specific to Gradle
support (there's a desire to remove all references to 'Gradle' as a
clear way to ensure everything Gradle-specific has been successfully
removed from the codebase--this has largely been done).
- The infrastructure and definitions for segmenting tests between Bazel
and Gradle has been completely removed (resulting in broad changes in
the codebase) since Gradle-specific behaviors can't be tested anymore,
and Bazel-specific behaviors are now the default.
- Some of the waiting logic in ``StateFragmentTest`` and
``ExplorationActivityTest`` has been kept but had its removal TODO
removed. This is because the code seems to have changed (or the original
problem misunderstood). These waits seem actually necessary due to
relying on real image loading, so the fix is more complex than simply
"migrate to Bazel & move off of Gradle." There's real test
infrastructure work needed to fix these tests properly, and it doesn't
seem sufficiently important to prioritize (though note it did seem
possible to remove the waits outright in ``ExplorationActivityTest``
without issue). The longer-term infrastructure work is tracked in #1523.
- ``LoadLessonProtosFromAssets`` has been made default true (since it
can't ever be false with Gradle removed). See the note below on removing
JSON assets for the work to fully clean this up.
- The removal of ``OppiaTestRunner`` as it was only used for Gradle
builds to help it set up state correctly for orchestrated tests (i.e.
Espresso). We may need to reintroduce something like this in the future,
but for now there's no value in keeping an unused class.
- Some simplifications in ``RepositoryFile`` and test removals in
``RepositoryFileTest`` now that Gradle build directories no longer need
to be filtered.
- ``TestEnvironmentConfig`` was removed since there's no longer a need
to test which environment tests are currently running in.
- Some Espresso documentation was removed since it's clearly no longer
needed, but more documentation work is still needing to be completed
(this was noticed due to the removal of ``OppiaTestRunner``).
- ``ApiMockLoader`` was simplified now that test config artifacts are in
a single location during testing time.
- ``InitializeDefaultLocaleRule`` can now have nearly all of its
reflection removed since it can be directly built to reference the
classes that it's interacting with (which wasn't possible in the Gradle
world, see the TODO in that class). Some new tests were added, as well,
which brings its test coverage to 100%.
- Updates CODEOWNERS to reflect all of the many file changes from the
above.
- Broad removal of the word 'module' in **many** locations and
documentation. This term is generally replaced with the more
architectural term 'layer' as to not overload 'module' from a Gradle,
Bazel, and Dagger perspective (plus others). This required a lot of
changes specifically in the Android Lint tool implementation and tests
to try and keep the term 'module' specific to cases where it still makes
sense (other than Dagger which is the bulk of the existing reference).
- `TransformAndroidManifest` was updated to support adding top-level
comments in manifest files (which are TODOs for #6010 to move or remove
manifest files--see below). Tests were also added to test the new
functionality.
- A bunch of files were changed simply because my local editor removed
trailing spaces and they were included in those various files that I
happened to change (largely for 'module' reference renames and/or
'Gradle' reference removals/rewordings).
Note also that this work opens up more things that still need to be, or
can now be, addressed, including:
- Removal of JSON lesson loading per #5663. We're no longer testing this
behavior correctly as domain level tests would previously verify JSON
loading logic in Gradle builds and proto logic in Bazel builds. This
means there's a strong likelihood of breakages occurring if JSON loading
isn't removed.
- Ensuring Espresso tests can actually run with Bazel (see #4991). We no
longer can verify Espresso behaviors now that Gradle is removed, which
also subsequently means all test gating on Robolectric is redundant and
all tests gated on Espresso never run.
- It's possible #4748 is now made redundant with the removal of
Gradle-specific ``robolectric.properties`` files, though I'm not
entirely certain at this point which SDK version is used in Bazel tests
for Robolectric (other than it being tied to Robolectric version and
that we pull in all supported SDKs so that tests can selectively opt
into specific SDKs for testing).
- Possibly some of the language configuration bits can be simplified now
that we don't need to gracefully fail if the configuration is missing
(since it never should be), but there's no plan to audit or track work
for this.
- Reorganization of the codebase now that Gradle no longer imposes
arbitrary modules (see
https://github.com/oppia/oppia-android/issues/59#issuecomment-528217795)
as well as fixing testing artifact isolation (multiple issues tracking
parts of this, and ideas possibly not yet captured in issues).
- `genrule`s can now be removed to improve symbol analysis in Android
Studio (and general build system complexity). See #1617.
- Some documentation can potentially be improved, but with the
replacement of the terms 'Gradle' and 'module' (plus past documentation
changes that happened as a result of moving the team over to Bazel
exclusively) much of the existing documentation seems solid.
- It may now be possible to update to newer versions of Kotlin and
Robolectric without worrying about AGP incompatibilities.
- Moving the app `AndroidManifest.xml` from the app directory to the
top-level directory to address #1640. Unfortunately this can't be done
as part of this PR (as previously attempted) due to #6010 and required
changes to the Android Lint script. Note that the addressing of #6010
also allows other manifests to potentially be removed and, hopefully, a
reduction of manifests to the bare minimum (the top-level plus any
asset-holding libraries--at least for now).
## Essential Checklist
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).
## For UI-specific PRs only
There are no known UI effects from removing Gradle support, but build
infrastructure is complex and this is _not_ a no-op change. It's
expected that the Bazel builds are relatively the same as before,
however (see the APK & AAB differences analysis), so there shouldn't be
an UI or UX changes as a result of this work.