Introducing a new way to review your PRs.

Read the announcement

keiyoushi / extensions-source

Source code of extensions in https://github.com/keiyoushi/extensions

View on GitHub

13 documents · Updated Nov 19, 2026

docs / repository-build-and-settings

Repository Build and Settings

Overview

This repository is assembled as a large Android/Kotlin Gradle multi-project build. The root entry points are settings.gradle.kts, build.gradle.kts, gradle.properties, the version catalogs under gradle/*.toml, and the Gradle wrapper files gradlew, gradlew.bat, and gradle/wrapper/gradle-wrapper.properties.

settings.gradle.kts names the build Keiyoushi, attaches the included build at gradle/build-logic, configures plugin and dependency repositories (google(), mavenCentral(), the Gradle plugin portal for plugins, and JitPack), and then includes modules. It always includes :core, :compiler, and :lint-rules, includes every directory directly under lib/ as :lib:<name>, includes every directory directly under lib-multisrc/ as :lib-multisrc:<name>, and by default calls loadAllIndividualExtensions() to include every extension under src/<lang>/<source> as :src:<lang>:<source>. For local development, CONTRIBUTING.md documents replacing that broad load with loadIndividualExtension("<lang>", "<name>") to reduce Gradle sync/build cost.

The root build.gradle.kts is deliberately small. It puts libs.kotlin.gradle on the buildscript classpath, declares Android application/library and Kotlin serialization plugin aliases without applying them globally, applies the repository Spotless plugin via kei.plugins.spotless, and wires root clean, spotlessApply, and spotlessCheck to depend on matching tasks in the included gradle/build-logic build. Build behavior is therefore split between the root aggregator and the included build plugins exposed through the kei catalog; this doc covers the root wiring and catalogs, not the implementation inside gradle/build-logic.

ext-bootstrap.py is the repository-level scaffolding path for new extensions. It validates ASCII inputs, an HTTPS base URL, a repository path that contains common/, and an optional multisrc theme under lib-multisrc/. It creates src/…/build.gradle.kts and a package directory under src/eu/kanade/tachiyomi/extension/<lang-major>/<sanitized-extension-name>/. Non-multisrc scaffolds use libVersion = "1.6", versionCode = 1, alias(kei.plugins.extension), a starter @Source abstract class ... : KeiSource(), and a broad deeplink { path("/..*") }; multisrc scaffolds set theme, start at versionCode = 0, extend the theme class, and copy the theme libVersion if it can read it from the theme's build.gradle.kts.

The human-facing repository files in this scope (README.md, CONTRIBUTING.md, AGENTS.md, and CLAUDE.md) define contributor-facing expectations around this build. README.md points users to the published extension repo and issue flow. CONTRIBUTING.md is the canonical contributor guide for extension structure, module loading, bootstrapping, formatting, building, and linting. AGENTS.md is a condensed instruction layer for automated agents and explicitly defers to CONTRIBUTING.md; CLAUDE.md simply includes AGENTS.md.

Key files and responsibilities

  • settings.gradle.kts: owns repository discovery and inclusion. Changing module directory conventions under src/, lib/, or lib-multisrc/ must be reflected here because the include names are derived from the directory names.
  • build.gradle.kts: owns root-level plugin availability and aggregate formatting/clean task delegation to the included gradle/build-logic build.
  • gradle/libs.versions.toml: the default libs catalog for external dependency and plugin versions. It includes AGP, Kotlin, KSP, lint, ktlint, Spotless, Tapmoc, OkHttp, serialization, coroutine, testing, and extension runtime libraries; the common bundle groups the dependencies shared by extension code.
  • gradle/kei.versions.toml: the custom kei catalog created by settings.gradle.kts. It carries repository build constants (android-sdk-min, android-sdk-compile, android-sdk-target, and java) and versionless aliases for the included build plugins (kei.plugins.android.base, extension, library, spotless, and theme/multisrc).
  • gradle.properties: enables Gradle build cache, configuration cache, configure-on-demand, parallel execution, and parallel tooling sync; sets the Gradle JVM heap to -Xmx6144m; disables Kotlin's automatic stdlib dependency; and disables incremental KSP.
  • gradle/wrapper/gradle-wrapper.properties, gradlew, gradlew.bat, and gradle/wrapper/gradle-wrapper.jar: pin and launch Gradle. The wrapper currently downloads gradle-9.9.1-bin.zip with URL validation enabled, no retries, and a 10-second network timeout.
  • ext-bootstrap.py: scaffolds new source modules and starter source classes in the shape expected by the Gradle extension plugin and KSP source generation.
  • ktlintCodeStyle.xml: stores IDE code-style settings that mirror Kotlin official style, effectively disables star imports by setting the import thresholds to 2147483647, and fixes XML/Kotlin indentation and attribute arrangement expectations.
  • CONTRIBUTING.md: documents developer build commands: ./gradlew :src:<lang>:<source>:assembleDebug for a single APK, ./gradlew spotlessApply before committing/linting, and ./gradlew :src:<lang>:<source>:lintRelease (or direct lint tasks for changed lib, lib-multisrc, and core modules) before submission.
  • AGENTS.md and CLAUDE.md: route automated contributors to CONTRIBUTING.md and warn that build infrastructure (common/, core/, compiler/, gradle/) is higher-risk and should not be changed for ordinary source fixes.

Important build and configuration flows

Gradle settings and module discovery

When ./gradlew starts, the wrapper launches the pinned Gradle distribution from gradle/wrapper/gradle-wrapper.properties, then Gradle evaluates settings.gradle.kts. Plugin resolution can see the included build gradle/build-logic plus Google, Maven Central, the Gradle Plugin Portal, and JitPack. Dependency resolution uses the same external repositories except the plugin portal, and repositoriesMode is FAIL_ON_PROJECT_REPOS, so project-level repository declarations are intentionally rejected.

The default sync is broad: loadAllIndividualExtensions() walks src/, then each language directory, and includes every child directory except .gradle and build. The helper functions do not inspect build files; the presence of a directory determines inclusion. This is why CONTRIBUTING.md recommends editing settings.gradle.kts locally to load only one source during development.

Version catalogs and plugin aliases

Gradle automatically exposes gradle/libs.versions.toml as the libs catalog, which root build logic uses for external plugin coordinates like libs.kotlin.gradle and aliases such as libs.plugins.android.application. settings.gradle.kts explicitly creates a second catalog named kei from gradle/kei.versions.toml. Extension, library, multisrc, and formatting build scripts use kei.plugins.* aliases for repository-local convention plugins supplied by the included build.

Because kei.versions.toml contains SDK and Java constants consumed by build logic, Android SDK bumps should be treated as build-system changes even if no source module changes. Because libs.versions.toml centralizes plugin and library coordinates, dependency updates there affect root buildscript classpath, convention plugins, compiler/lint code, and extension runtime dependencies depending on which alias or bundle is changed.

Formatting and lint flow

The root build applies the kei.plugins.spotless plugin and delegates root spotlessApply/spotlessCheck to matching tasks in gradle/build-logic. ktlintCodeStyle.xml is the IDE-side companion for Kotlin/XML formatting. Contributors are expected to run ./gradlew spotlessApply before linting and then run lint on every Android module touched, not just on a dependent extension module.

Extension bootstrap flow

ext-bootstrap.py is intentionally opinionated so new modules line up with the build DSL described in CONTRIBUTING.md. It strips non-alphanumeric characters from the extension name for the directory, lowercases it, uses the major language component for the directory (pt-BR becomes src/pt/...), but writes the full language string into the generated source { lang = ... } block. For non-multisrc sources it writes starter methods that throw UnsupportedOperationException() for required KeiSource operations; for multisrc sources it writes a minimal abstract class extending the selected theme base class.

Coupling

  • If settings.gradle.kts changes module include naming, also check CONTRIBUTING.md and ext-bootstrap.py: the contributor guide and bootstrap script assume extensions live at src/<lang-major>/<sanitized-name> and are addressed as :src:<lang>:<source>.
  • If gradle/kei.versions.toml changes plugin aliases, update any root or generated build snippets that use kei.plugins.*. build.gradle.kts, CONTRIBUTING.md, and ext-bootstrap.py all rely on aliases such as kei.plugins.spotless and kei.plugins.extension being stable.
  • If gradle/kei.versions.toml changes android-sdk-* or java, verify the included build logic that consumes those values and the prerequisite text in CONTRIBUTING.md; the root catalog is the shared source for those build constants.
  • If gradle/libs.versions.toml changes Kotlin, KSP, AGP, or lint versions, verify the root build.gradle.kts classpath/plugin aliases and the compiler/lint/build-logic consumers. The catalog is centralized, so a version bump can change plugin resolution and generated-code behavior across all modules.
  • If gradle.properties toggles configuration cache, configure-on-demand, parallelism, or KSP incremental mode, run representative extension and shared-module tasks. These flags affect the very large dynamic project graph created by settings.gradle.kts.
  • If ext-bootstrap.py changes generated build file fields, keep CONTRIBUTING.md's bootstrap and build.gradle.kts examples in sync; new contributors often copy one of those two paths rather than both.

Risks

  • settings.gradle.kts: the default loadAllIndividualExtensions() includes every directory under src/. If a non-module directory is added there, Gradle will still include it as a project and can fail configuration; if many modules are loaded unnecessarily, local syncs can become very slow.
  • ext-bootstrap.py: the script derives both directory and package fragments by stripping characters from --extname. If two different names sanitize to the same lowercase value, the second run stops only after detecting the existing extension directory, so naming collisions must be handled manually.
  • gradle/wrapper/gradle-wrapper.properties: retries=0 and networkTimeout=10000 make wrapper downloads fail quickly on transient network issues. If CI or contributor machines begin seeing wrapper download failures, this file is the retry/timeout control point.

Path-routable coverage notes

  • AGENTS.md, CLAUDE.md: automated-agent contributor instructions and their delegation to CONTRIBUTING.md.
  • README.md, CONTRIBUTING.md: repository usage, contribution, bootstrapping, local module loading, formatting, building, and linting guidance.
  • settings.gradle.kts: root build naming, repository policy, version catalog creation, included build attachment, and dynamic project inclusion.
  • build.gradle.kts, gradle.properties: root plugin/task aggregation and Gradle performance/configuration flags.
  • gradle/*.toml: external dependency/plugin versions and repository-local build constants/plugin aliases.
  • gradlew, gradlew.bat, gradle/wrapper/**: Gradle wrapper launch scripts, wrapper JAR, and pinned distribution settings.
  • ext-bootstrap.py: new extension module scaffolding and generated starter build/source files.
  • ktlintCodeStyle.xml: IDE formatting settings paired with repository Spotless/ktlint expectations.