Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add shared Android lint tooling

Neeraj Gupta3eee09137e69
diff --git a/.github/scripts/ci/paths.json b/.github/scripts/ci/paths.json
index 2cd1332b05..7e1dbbf047 100644
--- a/.github/scripts/ci/paths.json
+++ b/.github/scripts/ci/paths.json
@@ -1,4 +1,5 @@
{
+ "android-lint": [".github/workflows/android-lint.yml", "android/**"],
"apple-lint": [".github/workflows/apple-lint.yml", "apple/**"],
"dependency-review": [
"**/Cargo.lock",
@@ -27,6 +28,12 @@
"docs-verify-build": [".github/workflows/docs-verify-build.yml", "docs/**"],
"ensu-android-build": [
".github/workflows/ensu-android-build.yml",
+ "android/build.gradle.kts",
+ "android/settings.gradle.kts",
+ "android/gradle.properties",
+ "android/gradle/**",
+ "android/gradlew",
+ "android/gradlew.bat",
"android/apps/ensu/**",
"android/apps/ensu/rust/**",
"rust/.cargo/config.toml",
diff --git a/.github/scripts/ci/test.mjs b/.github/scripts/ci/test.mjs
index 372aa5904a..1bcd846811 100644
--- a/.github/scripts/ci/test.mjs
+++ b/.github/scripts/ci/test.mjs
@@ -16,6 +16,26 @@ test("docs changes do not wait for unrelated workflows", (t) => {
checkResult(results(selected));
});
+test("Android lint configuration does not build Ensu", (t) => {
+ for (const file of ["android/detekt.yml", "android/scripts/lint.sh"]) {
+ assert.deepEqual(select(t, [file]), ["android-lint", "repo-lint"]);
+ }
+});
+
+test("shared Android build inputs select Ensu", (t) => {
+ for (const file of [
+ "android/build.gradle.kts",
+ "android/settings.gradle.kts",
+ "android/gradle.properties",
+ "android/gradle/wrapper/gradle-wrapper.properties",
+ "android/gradle/verification-metadata.xml",
+ "android/gradlew",
+ "android/gradlew.bat",
+ ]) {
+ assert.ok(select(t, [file]).includes("ensu-android-build"), file);
+ }
+});
+
test("shared build inputs select their consumers", (t) => {
assert.deepEqual(select(t, [".github/actions/setup-flutter/action.yml"]), [
"mobile-lint",
diff --git a/.github/workflows/android-lint.yml b/.github/workflows/android-lint.yml
new file mode 100644
index 0000000000..e1def9c9cb
--- /dev/null
+++ b/.github/workflows/android-lint.yml
@@ -0,0 +1,14 @@
+name: "Lint (Android)"
+
+on:
+ workflow_call:
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+ - run: ./android/scripts/lint.sh
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b744fc9f93..2f127fb0a8 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,6 +24,11 @@ jobs:
- id: select
run: node .github/scripts/ci/check.mjs select HEAD^1 HEAD
+ android-lint:
+ needs: select
+ if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'android-lint') }}
+ uses: ./.github/workflows/android-lint.yml
+
apple-lint:
needs: select
if: ${{ contains(fromJSON(needs.select.outputs.jobs), 'apple-lint') }}
@@ -104,6 +109,7 @@ jobs:
if: ${{ always() }}
needs:
- select
+ - android-lint
- apple-lint
- dependency-review
- desktop-lint
diff --git a/.github/workflows/ensu-android-build.yml b/.github/workflows/ensu-android-build.yml
index 30b3f887ad..1a5b4104ef 100644
--- a/.github/workflows/ensu-android-build.yml
+++ b/.github/workflows/ensu-android-build.yml
@@ -32,5 +32,5 @@ jobs:
working-directory: rust
- name: Build Ensu
- working-directory: android/apps/ensu
- run: ./gradlew :app:assembleDebug
+ working-directory: android
+ run: ./gradlew :ensu:app:assembleDebug
diff --git a/.github/workflows/ensu-build.yml b/.github/workflows/ensu-build.yml
index 98443d5bec..20d7b81e20 100644
--- a/.github/workflows/ensu-build.yml
+++ b/.github/workflows/ensu-build.yml
@@ -350,7 +350,8 @@ jobs:
EOF
- name: Build signed Android artifacts
- run: ./gradlew -PversionCode="${BUILD_NUMBER}" :app:assembleRelease :app:bundleRelease
+ working-directory: android
+ run: ./gradlew -PversionCode="${BUILD_NUMBER}" :ensu:app:assembleRelease :ensu:app:bundleRelease
- name: Prepare whatsnew
run: |
diff --git a/.github/workflows/warm-caches.yml b/.github/workflows/warm-caches.yml
index b6d1c09a52..737afd998e 100644
--- a/.github/workflows/warm-caches.yml
+++ b/.github/workflows/warm-caches.yml
@@ -147,8 +147,8 @@ jobs:
working-directory: rust
- name: Build Ensu
- working-directory: android/apps/ensu
- run: ./gradlew :app:assembleDebug
+ working-directory: android
+ run: ./gradlew :ensu:app:assembleDebug
ensu-ios:
# For ensu-ios-build.yml.
diff --git a/android/apps/ensu/README.md b/android/apps/ensu/README.md
index c5e44c34c1..a15130b1c8 100644
--- a/android/apps/ensu/README.md
+++ b/android/apps/ensu/README.md
@@ -15,7 +15,7 @@ To know more about Ente, see [our main README](../../../README.md) or visit [ent
cargo codegen native
```
-3. Open the project in Android Studio and run the `app` module. If the Android NDK is missing, Android Studio will prompt to install it.
+3. Open `android/` in Android Studio and run Ensu's `app` module. If the Android NDK is missing, Android Studio will prompt to install it.
That's it. Apart from the `cargo codegen`, this is a normal Android project. Gradle cross-compiles the Rust libraries to JNI `.so` files automatically when building the app.
@@ -40,25 +40,25 @@ That's it. Apart from the `cargo codegen`, this is a normal Android project. Gra
Build and install a debug APK on a connected device or emulator:
```sh
-cd android/apps/ensu
-./gradlew :app:installDebug
+cd android
+./gradlew :ensu:app:installDebug
adb shell am start -n io.ente.ensu.debug/io.ente.ensu.MainActivity
```
Release APK:
```sh
-./gradlew :app:assembleRelease
+./gradlew :ensu:app:assembleRelease
```
-Output: `app/build/outputs/apk/release/app-release.apk`.
+Output: `apps/ensu/app/build/outputs/apk/release/app-release.apk`.
Release AAB (Play Store bundle):
```sh
-./gradlew :app:bundleRelease
+./gradlew :ensu:app:bundleRelease
```
-Output: `app/build/outputs/bundle/release/app-release.aab`.
+Output: `apps/ensu/app/build/outputs/bundle/release/app-release.aab`.
Release builds use a debug keystore located at `debug.keystore`. For production releases, configure your own signing keys in `app/build.gradle.kts`.
diff --git a/android/apps/ensu/rust/build.gradle.kts b/android/apps/ensu/rust/build.gradle.kts
index 41bc0ff48f..3cdbeca65c 100644
--- a/android/apps/ensu/rust/build.gradle.kts
+++ b/android/apps/ensu/rust/build.gradle.kts
@@ -134,6 +134,6 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
// Custom WebGPU/XNNPACK build; the Rust runtime dynamically loads its
// libonnxruntime.so. Resolved from the Ivy repository declared in
- // settings.gradle.kts and SHA-256 pinned in gradle/verification-metadata.xml.
+ // settings.gradle.kts and SHA-256 pinned in android/gradle/verification-metadata.xml.
api("io.ente.onnxruntime:onnxruntime-webgpu-android:1.28.1-r1@aar")
}
diff --git a/android/apps/ensu/settings.gradle.kts b/android/apps/ensu/settings.gradle.kts
index 391759cc0c..1c488c3d99 100644
--- a/android/apps/ensu/settings.gradle.kts
+++ b/android/apps/ensu/settings.gradle.kts
@@ -14,7 +14,7 @@ dependencyResolutionManagement {
maven { url = uri("https://jitpack.io") }
// Ente's custom prebuilt ONNX Runtime AAR is resolved straight from
// its GitHub release; its SHA-256 is pinned in
- // gradle/verification-metadata.xml.
+ // android/gradle/verification-metadata.xml.
exclusiveContent {
forRepository {
ivy {
diff --git a/android/build.gradle.kts b/android/build.gradle.kts
new file mode 100644
index 0000000000..5355450966
--- /dev/null
+++ b/android/build.gradle.kts
@@ -0,0 +1,41 @@
+import com.ncorti.ktfmt.gradle.KtfmtExtension
+import dev.detekt.gradle.extensions.DetektExtension
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
+
+plugins {
+ id("com.android.application") version "8.10.1" apply false
+ id("com.android.library") version "8.10.1" apply false
+ id("com.ncorti.ktfmt.gradle") version "0.27.0"
+ id("dev.detekt") version "2.0.0-alpha.6"
+ id("org.jetbrains.kotlin.jvm") version "2.4.20" apply false
+}
+
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+
+ apply(plugin = "com.ncorti.ktfmt.gradle")
+ apply(plugin = "dev.detekt")
+ extensions.configure<KtfmtExtension> {
+ kotlinLangStyle()
+ maxWidth.set(100)
+ }
+
+ extensions.configure<DetektExtension> { config.setFrom(rootProject.file("detekt.yml")) }
+
+ tasks.withType<KotlinCompilationTask<*>>().configureEach {
+ compilerOptions.allWarningsAsErrors.set(true)
+ }
+}
+
+tasks.register("lint") {
+ dependsOn(
+ allprojects.map { project ->
+ project.tasks.matching {
+ it.name in listOf("ktfmtCheck", "detektMain", "detektTest", "lintDebug")
+ }
+ }
+ )
+}
diff --git a/android/checks/gradle-order/check.py b/android/checks/gradle-order/check.py
new file mode 100644
index 0000000000..753e94978b
--- /dev/null
+++ b/android/checks/gradle-order/check.py
@@ -0,0 +1,173 @@
+import os
+import re
+import sys
+from collections import defaultdict
+from pathlib import Path
+
+TOKEN = re.compile(r'''//[^\n]*|/\*|"""|"|'(?:\\.|[^'\\])*'|`[^`]*`|\w+|[^\s]''')
+COMMENT = re.compile(r'/\*|\*/')
+
+
+def parse(source):
+ root = []
+ stack = [root]
+ for value, offset, _ in tokens(source):
+ if value in (")", "}", "]"):
+ stack.pop()
+ continue
+ children = []
+ stack[-1].append((value, offset, children))
+ if value in ("(", "{", "["):
+ stack.append(children)
+ return root
+
+
+def tokens(source, start=0):
+ while match := TOKEN.search(source, start):
+ value = match.group()
+ start = match.end()
+ if value.startswith("//"):
+ continue
+ if value == "/*":
+ depth = 1
+ start = len(source)
+ for marker in COMMENT.finditer(source, match.end()):
+ depth += 1 if marker.group() == "/*" else -1
+ if depth == 0:
+ start = marker.end()
+ break
+ continue
+ if value in ('"', '"""'):
+ start = string_end(source, start, value)
+ yield source[match.start():start], match.start(), start
+
+
+def string_end(source, offset, quote):
+ while offset < len(source):
+ if source.startswith(quote, offset):
+ return offset + len(quote)
+ if quote == '"' and source[offset] == "\\":
+ offset += 2
+ elif source.startswith("${", offset):
+ depth = 1
+ for value, _, end in tokens(source, offset + 2):
+ if value == "{":
+ depth += 1
+ elif value == "}":
+ depth -= 1
+ if depth == 0:
+ offset = end
+ break
+ else:
+ return len(source)
+ else:
+ offset += 1
+ return offset
+
+
+def calls(nodes):
+ for index, (name, offset, _) in enumerate(nodes[:-1]):
+ if index and nodes[index - 1][0] in (".", "fun"):
+ continue
+ bracket, _, arguments = nodes[index + 1]
+ if name in ("if", "when", "for", "while", "catch"):
+ continue
+ if name.isidentifier() and bracket in ("(", "{"):
+ yield name, offset, bracket, arguments
+
+
+def walk(nodes):
+ yield nodes
+ for _, _, children in nodes:
+ if children:
+ yield from walk(children)
+
+
+def arguments(nodes):
+ result = [[]]
+ for node in nodes:
+ if node[0] == ",":
+ result.append([])
+ else:
+ result[-1].append(node)
+ return result
+
+
+def dependency_key(nodes):
+ if len(nodes) == 1 and nodes[0][0].startswith('"'):
+ value = nodes[0][0].strip('"')
+ return value if value.startswith(":") else ":".join(value.split(":")[:2])
+ if len(nodes) == 2 and nodes[0][0] in ("project", "platform", "enforcedPlatform"):
+ return dependency_arguments_key(arguments(nodes[1][2]))
+ if nodes and all(value.isidentifier() or value == "." for value, _, _ in nodes):
+ return "".join(value for value, _, _ in nodes)
+ return None
+
+
+def dependency_arguments_key(args):
+ named = {
+ arg[0][0]: dependency_key(arg[2:])
+ for arg in args
+ if len(arg) >= 3 and arg[1][0] == "="
+ }
+ if named.get("group") is not None and named.get("name") is not None:
+ return f'{named["group"]}:{named["name"]}'
+ if named.get("path") is not None:
+ return named["path"]
+ return dependency_key(args[0])
+
+
+def check(source, path):
+ includes = []
+ groups = []
+ for nodes in walk(parse(source)):
+ for name, offset, bracket, body in calls(nodes):
+ if name == "include" and bracket == "(" and Path(path).name == "settings.gradle.kts":
+ includes.extend(
+ (value.strip('"'), position)
+ for value, position, _ in body
+ if value.startswith('"') and "$" not in value
+ )
+ if name != "dependencies" or bracket != "{":
+ continue
+ dependencies = defaultdict(list)
+ for configuration, position, opening, declaration in calls(body):
+ if opening != "(":
+ continue
+ args = arguments(declaration)
+ if configuration == "add" and len(args) > 1:
+ configuration = dependency_key(args.pop(0))
+ key = dependency_arguments_key(args)
+ if configuration and key is not None:
+ dependencies[configuration].append((key, position))
+ groups.extend(dependencies.items())
+ groups.append(("include", sorted(includes, key=lambda entry: entry[1])))
+ errors = []
+ for group, entries in groups:
+ for (previous, _), (current, offset) in zip(entries, entries[1:]):
+ if previous > current:
+ line = source.count("\n", 0, offset) + 1
+ errors.append(
+ f"{path}:{line}: {group} must be sorted: {previous!r} precedes {current!r}"
+ )
+ return errors
+
+
+def main(root):
+ errors = []
+ for directory, children, files in os.walk(root):
+ relative = Path(directory).relative_to(root)
+ children[:] = sorted(
+ child for child in children
+ if child not in ("build", ".gradle") and relative / child != Path("apps/ensu")
+ )
+ for name in sorted(files):
+ if name.endswith(".gradle.kts"):
+ errors.extend(check((Path(directory) / name).read_text(), relative / name))
+ for error in errors:
+ print(error, file=sys.stderr)
+ return bool(errors)
+
+
+if __name__ == "__main__":
+ sys.exit(main(Path(sys.argv[1])))
diff --git a/android/checks/gradle-order/test.py b/android/checks/gradle-order/test.py
new file mode 100644
index 0000000000..6a65314063
--- /dev/null
+++ b/android/checks/gradle-order/test.py
@@ -0,0 +1,131 @@
+import subprocess
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from runpy import run_path
+
+script = Path(__file__).with_name("check.py")
+check = run_path(script)["check"]
+
+
+class GradleOrderTest(unittest.TestCase):
+ def errors(self, source):
+ return check(source, "settings.gradle.kts")
+
+ def test_includes_across_calls_and_multiline_arguments(self):
+ errors = self.errors('include(":b")\ninclude(\n ":a",\n ":c",\n)')
+ self.assertEqual(errors, [
+ "settings.gradle.kts:3: include must be sorted: ':b' precedes ':a'"
+ ])
+ self.assertFalse(self.errors('include(":a", ":b")\ninclude(":c")'))
+
+ def test_comments_strings_and_repositories_are_not_declarations(self):
+ self.assertFalse(self.errors('''
+ // include(":z", ":a")
+ val text = """include(":z", ":a")"""
+ repositories { mavenCentral(); google() }
+ include(":a", ":b")
+ '''))
+
+ def test_character_literals_do_not_change_declaration_nesting(self):
+ for literal in ["'('", "')'", "'['", "']'", "'{'", "'}'", r"'\''", r"'\\'"]:
+ with self.subTest(literal=literal):
+ self.assertEqual(
+ self.errors(f'val marker = {literal}\ninclude(":b", ":a")'),
+ ["settings.gradle.kts:2: include must be sorted: ':b' precedes ':a'"],
+ )
+
+ def test_each_dependency_configuration_is_sorted_independently(self):
+ self.assertFalse(self.errors('''
+ dependencies {
+ implementation("a:lib:2")
+ testImplementation("z:test:1")
+ implementation("b:lib:1")
+ }
+ '''))
+ errors = self.errors('''
+ dependencies {
+ implementation("b:lib:1")
+ testImplementation("a:test:1")
+ implementation("a:lib:2")
+ }
+ ''')
+ self.assertEqual(len(errors), 1)
+ self.assertIn("implementation must be sorted: 'b:lib' precedes 'a:lib'", errors[0])
+
+ def test_strings_preserve_following_declarations(self):
+ for expression in [
+ 'val endpoint = "https://ente.io"',
+ 'val label = "Marker: ${listOf(")").single()}"',
+ 'val label = """Marker: ${listOf("}").single()}"""',
+ 'val label = "Nested: ${"inner ${listOf("]").single()}"}"',
+ 'val label = "Value: ${run { /* } */ "}" }}"',
+ ]:
+ with self.subTest(expression=expression):
+ self.assertEqual(
+ self.errors(f'{expression}; include(":b", ":a")'),
+ ["settings.gradle.kts:1: include must be sorted: ':b' precedes ':a'"],
+ )
+
+ def test_named_dependency_coordinates_mix_with_string_notation(self):
+ errors = self.errors('''
+ dependencies {
+ implementation(name = "lib", version = "1", group = "z")
+ implementation("a:lib:1")
+ }
+ ''')
+ self.assertEqual(len(errors), 1)
+ self.assertIn("implementation must be sorted: 'z:lib' precedes 'a:lib'", errors[0])
+
+ def test_build_script_file_filters_are_not_project_includes(self):
+ self.assertFalse(check('''
+ tasks.register<Copy>("first") { include("z/**") }
+ tasks.register<Copy>("second") { include("a/**") }
+ ''', "build.gradle.kts"))
+
+ def test_projects_platforms_catalogs_and_add(self):
+ for first, second, expected in [
+ ('project(":packages:z")', 'project(":packages:a")', "':packages:z' precedes ':packages:a'"),
+ ('project(path = ":packages:z")', 'project(path = ":packages:a")', "':packages:z' precedes ':packages:a'"),
+ ('project(path = ":packages:z", configuration = "default")', 'project(":packages:a")', "':packages:z' precedes ':packages:a'"),
+ ('platform("z:bom:1")', 'enforcedPlatform("a:bom:1")', "'z:bom' precedes 'a:bom'"),
+ ('libs.z', 'libs.a', "'libs.z' precedes 'libs.a'"),
+ ]:
+ with self.subTest(first=first):
+ errors = self.errors(f'dependencies {{ api({first}); api({second}) }}')
+ self.assertEqual(len(errors), 1)
+ self.assertIn(expected, errors[0])
+ self.assertFalse(self.errors(f'dependencies {{ api({second}); api({first}) }}'))
+ self.assertEqual(len(self.errors('''
+ dependencies { add("implementation", "z:lib:1"); implementation("a:lib:1") }
+ ''')), 1)
+
+ def test_dependency_customization_is_not_another_declaration(self):
+ self.assertFalse(self.errors('''
+ dependencies {
+ implementation("a:lib:1") {
+ exclude(group = "z")
+ exclude(group = "a")
+ }
+ implementation("b:lib:1")
+ }
+ '''))
+
+ def test_cli_excludes_ensu_and_generated_files(self):
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ for name in ["apps/ensu/build.gradle.kts", "build/build.gradle.kts", ".gradle/build.gradle.kts"]:
+ path = root / name
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text('dependencies { api("z:lib:1"); api("a:lib:1") }')
+ result = subprocess.run([sys.executable, script, root], capture_output=True, text=True)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ (root / "settings.gradle.kts").write_text('include(":z", ":a")')
+ result = subprocess.run([sys.executable, script, root], capture_output=True, text=True)
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("include must be sorted", result.stderr)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/android/detekt.yml b/android/detekt.yml
new file mode 100644
index 0000000000..90ee64c9e0
--- /dev/null
+++ b/android/detekt.yml
@@ -0,0 +1,57 @@
+config:
+ validation: true
+ warningsAsErrors: true
+
+coroutines:
+ active: true
+ GlobalCoroutineUsage:
+ active: true
+ RedundantSuspendModifier:
+ active: true
+ SleepInsteadOfDelay:
+ active: true
+ SuspendFunSwallowedCancellation:
+ active: true
+
+empty-blocks:
+ active: true
+ EmptyCatchBlock:
+ active: true
+
+exceptions:
+ active: true
+ RethrowCaughtException:
+ active: true
+ ReturnFromFinally:
+ active: true
+ ThrowingExceptionFromFinally:
+ active: true
+
+potential-bugs:
+ active: true
+ CastToNullableType:
+ active: true
+ CharArrayToStringCall:
+ active: true
+ ElseCaseInsteadOfExhaustiveWhen:
+ active: true
+ EqualsWithHashCodeExist:
+ active: true
+ IgnoredReturnValue:
+ active: true
+ ImplicitDefaultLocale:
+ active: true
+ InvalidRange:
+ active: true
+ UnnecessaryNotNullCheck:
+ active: true
+ UnnecessaryNotNullOperator:
+ active: true
+ UnnecessarySafeCall:
+ active: true
+ UnreachableCatchBlock:
+ active: true
+ UnreachableCode:
+ active: true
+ UnsafeCallOnNullableType:
+ active: true
diff --git a/android/gradle.properties b/android/gradle.properties
new file mode 100644
index 0000000000..c2adf04b5c
--- /dev/null
+++ b/android/gradle.properties
@@ -0,0 +1 @@
+org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
diff --git a/android/apps/ensu/gradle/verification-metadata.xml b/android/gradle/verification-metadata.xml
similarity index 100%
rename from android/apps/ensu/gradle/verification-metadata.xml
rename to android/gradle/verification-metadata.xml
diff --git a/android/apps/ensu/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from android/apps/ensu/gradle/wrapper/gradle-wrapper.jar
rename to android/gradle/wrapper/gradle-wrapper.jar
diff --git a/android/apps/ensu/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
similarity index 100%
rename from android/apps/ensu/gradle/wrapper/gradle-wrapper.properties
rename to android/gradle/wrapper/gradle-wrapper.properties
diff --git a/android/apps/ensu/gradlew b/android/gradlew
similarity index 100%
rename from android/apps/ensu/gradlew
rename to android/gradlew
diff --git a/android/apps/ensu/gradlew.bat b/android/gradlew.bat
similarity index 100%
rename from android/apps/ensu/gradlew.bat
rename to android/gradlew.bat
diff --git a/android/scripts/lint.sh b/android/scripts/lint.sh
new file mode 100755
index 0000000000..34ef5d2943
--- /dev/null
+++ b/android/scripts/lint.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+cd "$(dirname "$0")/.."
+python3 checks/gradle-order/check.py .
+python3 checks/gradle-order/test.py
+./gradlew :lint
diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts
new file mode 100644
index 0000000000..0e09ed5360
--- /dev/null
+++ b/android/settings.gradle.kts
@@ -0,0 +1,12 @@
+pluginManagement {
+ repositories {
+ google()
+ gradlePluginPortal()
+ mavenCentral()
+ }
+}
+
+rootProject.name = "android"
+
+// TODO: Include Ensu in shared linting.
+includeBuild("apps/ensu")
diff --git a/docs/docs/self-hosting/development/building-from-source.md b/docs/docs/self-hosting/development/building-from-source.md
index 3ba44fa6ba..43512214bf 100644
--- a/docs/docs/self-hosting/development/building-from-source.md
+++ b/docs/docs/self-hosting/development/building-from-source.md
@@ -307,12 +307,12 @@ cargo codegen native
Then, for example, to run the Ensu Android app:
```sh
-cd android/apps/ensu
-./gradlew :app:installDebug
+cd android
+./gradlew :ensu:app:installDebug
adb shell am start -n io.ente.ensu.debug/io.ente.ensu.MainActivity
```
-Or, if you have Android Studio, you can just open `android/apps/ensu` and run. Same goes for opening `apple/apps/ensu` in Xcode and running.
+Or, if you have Android Studio, you can just open `android/` and run Ensu's `app` module. Same goes for opening `apple/apps/ensu` in Xcode and running.
## That's all folks.