Skip to content

ADFA-4636: Remove Kotlin/JS and Kotlin/Native backends from kt-android.jar#1506

Open
davidschachterADFA wants to merge 2 commits into
stagefrom
ADFA-4636-remove-kotlin-js-native-backends
Open

ADFA-4636: Remove Kotlin/JS and Kotlin/Native backends from kt-android.jar#1506
davidschachterADFA wants to merge 2 commits into
stagefrom
ADFA-4636-remove-kotlin-js-native-backends

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds excludeEntryPrefixes support to ExternalJarDependencyConfiguration and ExternalAssetsPlugin, allowing ZIP entries matching listed prefixes to be stripped from a cached copy of a downloaded JAR before it is added as a dependency
  • Configures kotlin-analysis-api to strip all org/jetbrains/kotlin/js/ and org/jetbrains/kotlin/konan/ classes and their associated META-INF/*.kotlin_module entries (794 entries, ~3.4 MB) — neither backend has any place in an Android IDE
  • The stripped JAR is cached alongside the original and only regenerated when the original changes (mtime check)

Test plan

  • Build succeeds with the stripped JAR
  • Kotlin code analysis still works in the IDE (completions, diagnostics)
  • APK size is reduced by ~3.4 MB compared to before

🤖 Generated with Claude Code

…d.jar

Adds excludeEntryPrefixes support to ExternalJarDependencyConfiguration and
ExternalAssetsPlugin so that ZIP entries matching listed prefixes are stripped
from a cached copy of the downloaded JAR before it is added as a dependency.
Configures kotlin-analysis-api to strip all org/jetbrains/kotlin/js/ and
org/jetbrains/kotlin/konan/ classes (794 entries, ~3.4 MB) since neither
backend has any place in an Android IDE.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds configurable ZIP-entry filtering for external JAR dependencies. Matching entries are omitted into a cached -stripped.jar, and the Kotlin analysis API dependency excludes Kotlin/JS and Kotlin/Native backend artifacts.

Changes

External JAR stripping

Layer / File(s) Summary
Exclusion configuration contract
composite-builds/.../ExternalAssetsExtension.kt
Adds excludeEntryPrefixes, defaulting to an empty list, for excluding matching ZIP entries.
Stripping and dependency wiring
composite-builds/.../ExternalAssetsPlugin.kt, subprojects/kotlin-analysis-api/build.gradle.kts
Creates or reuses stripped JARs, excludes matching entries, selects the stripped artifact, and configures Kotlin backend exclusions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: Daniel-ADFA, jatezzz

Sequence Diagram(s)

sequenceDiagram
  participant jarDependency
  participant stripJar
  participant fileTree
  jarDependency->>stripJar: prepare stripped JAR using excluded prefixes
  stripJar->>stripJar: copy non-matching ZIP entries
  jarDependency->>fileTree: include stripped JAR artifact
Loading

Poem

A bunny trims the JAR with care,
Skipping Kotlin paths in air.
JS and Native hop away,
Clean bytes join the build today.
-stripped.jar rests light and fair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly reflects the main change: removing Kotlin/JS and Kotlin/Native backends from kt-android.jar.
Description check ✅ Passed The description accurately summarizes the JAR stripping support and the Kotlin/JS and Kotlin/Native exclusions.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-4636-remove-kotlin-js-native-backends

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/ExternalAssetsPlugin.kt (1)

88-88: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer suffix-safe derivation over String.replace.

config.jarName.replace(".jar", "-stripped.jar") replaces every occurrence of .jar and silently produces an unmodified name if the file has no .jar extension. Use removeSuffix/substringBeforeLast to target only the extension.

-            val stripped = cacheDir.resolve(config.jarName.replace(".jar", "-stripped.jar"))
+            val stripped = cacheDir.resolve("${config.jarName.removeSuffix(".jar")}-stripped.jar")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/ExternalAssetsPlugin.kt`
at line 88, In the stripped artifact path within the relevant asset-processing
function, replace config.jarName.replace(".jar", "-stripped.jar") with
suffix-safe logic that removes only a trailing .jar extension and appends
-stripped.jar, using removeSuffix or substringBeforeLast; preserve the original
basename and avoid replacing earlier occurrences or silently accepting an
invalid extension.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/ExternalAssetsPlugin.kt`:
- Around line 104-107: Update the strip-cache logic in the relevant task or
function containing the dest/source timestamp check so changes to
excludeEntryPrefixes invalidate the existing stripped JAR. Persist a
deterministic hash or serialized representation of the prefix set alongside the
output, compare it during the up-to-date check, and regenerate the stripped
artifact when it differs while preserving the existing timestamp check.
- Around line 109-125: Update stripJar to write the stripped archive to a
temporary file in dest’s directory, using the existing ZIP stream logic against
that temp path. After successful completion, atomically move the temp file to
dest, with an appropriate fallback if atomic moves are unsupported; ensure
failures delete the temporary file and never leave a partial dest. Keep the
existing size calculation and logging based on the finalized destination.

---

Nitpick comments:
In
`@composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/ExternalAssetsPlugin.kt`:
- Line 88: In the stripped artifact path within the relevant asset-processing
function, replace config.jarName.replace(".jar", "-stripped.jar") with
suffix-safe logic that removes only a trailing .jar extension and appends
-stripped.jar, using removeSuffix or substringBeforeLast; preserve the original
basename and avoid replacing earlier occurrences or silently accepting an
invalid extension.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7a8d843c-21ea-4d0f-bc04-9a0a2b12618e

📥 Commits

Reviewing files that changed from the base of the PR and between 232cec2 and d557b26.

📒 Files selected for processing (3)
  • composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/ExternalAssetsPlugin.kt
  • composite-builds/build-logic/plugins/src/main/java/com/itsaky/androidide/plugins/extension/ExternalAssetsExtension.kt
  • subprojects/kotlin-analysis-api/build.gradle.kts

- Use removeSuffix(".jar") instead of replace(".jar", ...) so only the
  trailing extension is affected, not any earlier occurrence in the name
- Add a .prefixes companion file alongside the stripped JAR so changes
  to excludeEntryPrefixes invalidate the cached output even when the
  source JAR mtime is unchanged
- Write to a .tmp file and atomically rename to dest on success; delete
  the temp file on any failure to prevent partial output from being
  treated as valid on subsequent builds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@davidschachterADFA

Copy link
Copy Markdown
Collaborator Author

At the top of this PR, Claude Code's test plan says the APK should shrink by about 3.4 MB. In the interactive Claude session, an estimate of 274 kB was provided. I measured an actual reduction of 590 kB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants