Skip to content

refactor(build): convert jacoco.gradle Kotlin DSL#20911

Merged
david-allison merged 2 commits intoankidroid:mainfrom
david-allison:20910-jacoco
May 2, 2026
Merged

refactor(build): convert jacoco.gradle Kotlin DSL#20911
david-allison merged 2 commits intoankidroid:mainfrom
david-allison:20910-jacoco

Conversation

@david-allison
Copy link
Copy Markdown
Member

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

Note

Assisted-by: Claude Opus 4.7 - all

Fixes

Approach

Asked Claude to do a 1:1 conversion.

Claude: explanation of differences
Moved testCoverage into build.gradle because AGP types (CommonExtension) aren't on the applied .kts script's compile classpath.

The 1:1 conversion preserves the Groovy structure where Kotlin permits. Two unavoidable deviations from the original:
- sourceDirectories.from = X → sourceDirectories.setFrom(X) — Groovy's .from = X is metaprogramming that calls setFrom.
ConfigurableFileCollection.from exposes only a getter (returning Set<Object>) in Java, so Kotlin has no = setter to bind to. Kotlin DSL's lazy-property assignment only applies to Property<T>, not file collections.
- new GradleScriptException(msg, null) → GradleException(msg) — In this Gradle/Kotlin version the second parameter rejects null at compile time GradleException is GradleScriptException's parent and produces an equivalent build failure with a null cause.

How Has This Been Tested?

Trusting CI on this one.
I ran :AnkiDroid:jacocoUnitTestReport and :AnkiDroid:jacocoAndroidTestReport` and fixed configuration cache issues

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

This is prep for converting jacoco to .kts

This commit ensures that `git blame` is maintained

Issue 20910
Moved testCoverage into build.gradle because AGP types (CommonExtension)
 aren't on the applied .kts script's compile classpath.

Part of issue 20910: moving to .kts

Assisted-by: Claude Opus 4.7 - all

The 1:1 conversion preserves the Groovy structure where Kotlin permits.
Two unavoidable deviations from the original:
- sourceDirectories.from = X → sourceDirectories.setFrom(X) — Groovy's
.from = X is metaprogramming that calls setFrom.
ConfigurableFileCollection.from exposes only a getter
(returning Set<Object>) in Java, so Kotlin has no = setter to bind to.
Kotlin DSL's lazy-property assignment only applies to Property<T>, not
file collections.
- new GradleScriptException(msg, null) → GradleException(msg) — In this
 Gradle/Kotlin version the second parameter rejects null at compile time
 GradleException is GradleScriptException's parent and produces an
 equivalent build failure with a null cause.
@david-allison
Copy link
Copy Markdown
Member Author

Given the diff, I'd rather break git bisect on this commit, and perform a rename.

Reviewer's choice, but we should be consistent with the remaining files.

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.

"the proof is in the pudding" --> https://app.codecov.io/gh/ankidroid/Anki-Android/pull/20911

LGTM, is readable enough

You bisect more than most, I'm not concerned with the diff really, I think over time the ability to read this diff will have zero value (who exactly is ever going to read it? and why?), but bisect has value (especially around a release) so I would lean somewhat heavily towards preserving bisect as the "has value" choice.

But having said that, leaving to you to merge however you see fit - at will

@mikehardy mikehardy added Needs Author Reply Waiting for a reply from the original author Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) CI and removed Needs Review labels May 2, 2026
@david-allison
Copy link
Copy Markdown
Member Author

Reading the diff is temporary, keeping git history is worthwhile breaking the build for

@david-allison david-allison added this pull request to the merge queue May 2, 2026
Merged via the queue into ankidroid:main with commit fb28b7a May 2, 2026
19 checks passed
@github-actions github-actions Bot removed Needs Author Reply Waiting for a reply from the original author Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) labels May 2, 2026
@github-actions github-actions Bot added this to the 2.24 release milestone May 2, 2026
@david-allison david-allison deleted the 20910-jacoco branch May 2, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants