Skip to content

build: Introduce Gradle Convention Plugins#20778

Open
david-allison wants to merge 8 commits intoankidroid:mainfrom
david-allison:convention-plugin
Open

build: Introduce Gradle Convention Plugins#20778
david-allison wants to merge 8 commits intoankidroid:mainfrom
david-allison:convention-plugin

Conversation

@david-allison
Copy link
Copy Markdown
Member

@david-allison david-allison commented Apr 19, 2026

Purpose / Description

See: https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html

Benefits of convention plugins

  • One place for configuration changes
  • Simplifies the process of verifying correctness of new modules
  • Reduced code in build.gradle.kts files
  • Ensures all modules apply the same set of common transformations
  • Fewer footguns with configuration cache interactions

Fixes

Approach

  • Start with the obvious duplication in android libraries
  • Discover inconsistences: lint, JaCoCo and fix them
  • Discover issues with minifying both the library and the app, fix this
    • Likely a small speedup
  • Then extract both api and lint-rules

How Has This Been Tested?

Learning (optional, can help others)

Opus does seem to be worse - not reading files fully

This was a much more difficult change than I expected, lots of false starts, but I feel it's worthwhile. It picked up a few issues (compat + JaCoCo), and is a solid architectural change for the future.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Comment thread vbpd/proguard-rules.pro
Comment on lines -23 to -26
-keep class dev.androidbroadcast.vbpd.ViewBindingProperty { *; }
-keep class dev.androidbroadcast.vbpd.ActivityViewBindings { *; }
-keep class dev.androidbroadcast.vbpd.FragmentViewBindings { *; }
-keep class dev.androidbroadcast.vbpd.internal.VbpdUtilsKt { *; } No newline at end of file
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was necessary because we were minifying the library. We now let the app take care of this.

@david-allison david-allison changed the title build: Introduce Convention Plugins build: Introduce Gradle Convention Plugins Apr 19, 2026
@david-allison

This comment was marked as resolved.

@david-allison david-allison added Blocked by dependency Currently blocked by some other dependent / related change Next version Changes to be merged in the next version, to keep the current release stable. labels Apr 19, 2026
Copy link
Copy Markdown
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

draft I know, and marked for next version, but I dig it

@david-allison david-allison marked this pull request as ready for review April 19, 2026 15:32
@david-allison david-allison removed the Blocked by dependency Currently blocked by some other dependent / related change label Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

38779315: Old APK size
38779315: New APK size

@mikehardy
Copy link
Copy Markdown
Member

I was already expecting this to be merged 😆 was reviewing another PR and thought "what is all this boilerplate, ugh"

@mikehardy mikehardy mentioned this pull request Apr 19, 2026
5 tasks
@david-allison david-allison added Needs Review and removed Has Conflicts Next version Changes to be merged in the next version, to keep the current release stable. labels Apr 20, 2026
Comment thread AnkiDroid/build.gradle
Comment thread buildSrc/src/main/kotlin/ankidroid.android-api-library.gradle.kts Outdated
Comment thread api/build.gradle.kts Outdated
Comment thread api/build.gradle.kts
For Android libraries

This consolidates:
* compileSdk
* minSdk
* compileOptions [sourceCompatibility]

All properties were standardized, so this is a no-op.

**Benefits**
* One place for configuration changes
* Simplifies the process of verifying correctness of new modules
* Reduced code in `build.gradle.kts` files
* Ensures all modules apply the same set of common transformations
* Fewer footguns with configuration cache interactions

Issue 20775

Assisted-by: Claude Opus 4.7 - discussion, selection of initial
properties to move
Via the convention plugin.

Lint is newly applied to `:vbpd`

Issue 20775

Assisted-by: Claude Opus 4.7 - explanation and fix
None of these files are used - holdover from using the 'new module'
template

If needed, these can be added on a case-by-case basis

Issue 20775

Assisted-by: Claude Opus 4.7 - research and fix
The value was the default - no need for it to exist

Issue 20775
* One of the files had no content
* vbpd was only necessary because we were minifying the library

Minification is enabled at the app level, two rounds of minification
were unnecessary, slow, and caused the need for the proguard file

.createProguardRulesFiles` can be used if necessary to regenerate the
files

Issue 20775

Assisted-by: Claude Opus 4.7 - research and fix
* `:compat` had this flag missing
* `:vbpd` has no tests, so effectively a no-op

Issue 20775

Assisted-by: Claude Opus 4.7 - diagnostic and fix
`kotlin-jvm` is intended for our modules which target `java-library`

Issue 20775

Assisted-by: Claude Opus 4.7
Likely only one consumer: `:api`, added to standardize .kts files

The API has separate requirements, but these are noise in the main
gradle.kts file.

Issue 20775

Assisted-by: Claude Opus 4.7 - full refactor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce Gradle Convention Plugin

3 participants