Skip to content

feat(bundle-jvm): Automatically collect JVM source files with respecting excludes and gitignore #3260

Merged
romtsn merged 16 commits intomasterfrom
rz/feat/bundle-jvm-filtering
Apr 14, 2026
Merged

feat(bundle-jvm): Automatically collect JVM source files with respecting excludes and gitignore #3260
romtsn merged 16 commits intomasterfrom
rz/feat/bundle-jvm-filtering

Conversation

@romtsn
Copy link
Copy Markdown
Member

@romtsn romtsn commented Apr 10, 2026

Summary

  • Filter collected sources by JVM file extensions (java, kt, scala, groovy) instead of collecting all files
  • Exclude common build output directories by default (build, .gradle, .cxx, node_modules)
  • Respect .gitignore / .ignore rules as an additional layer of defense
  • Add --exclude CLI arg for user-provided glob patterns on top of defaults

This enables invoking bundle-jvm directly on a project root without needing to pre-copy sources into a separate directory (e.g. from the Android Gradle plugin's CollectSourcesTask).

This also does not break the existing plugins' workflows, only in subtle cases where a non-JVM file has been included into the src/main/java source set, but this is likely not supported on the product side either.

Test plan

  • Run bundle-jvm on an Android project root and verify only .java/.kt files are collected
  • Verify build/ directory contents are excluded
  • Verify .gitignored paths are respected
  • Test --exclude with custom glob patterns
  • Verify existing callers of ReleaseFileSearch are unaffected (default respect_ignores: false)

🤖 Generated with Claude Code

romtsn and others added 2 commits April 10, 2026 11:46
Filter collected sources by JVM file extensions (java, kt, scala,
groovy, kts) and exclude common build output directories by default
(build, .gradle, .cxx, node_modules). Also respect .gitignore rules
as an additional layer of defense. Users can provide extra --exclude
glob patterns on top of the defaults.

This enables invoking bundle-jvm directly on a project root without
needing to pre-copy sources into a separate directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f7e112c

romtsn and others added 4 commits April 10, 2026 11:52
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@romtsn romtsn marked this pull request as ready for review April 10, 2026 10:06
@romtsn romtsn requested review from a team and szokeasaurusrex as code owners April 10, 2026 10:06
@romtsn romtsn requested a review from adinauer April 10, 2026 10:06
@romtsn romtsn changed the title feat(bundle-jvm): Add JVM extension filtering and default excludes feat(bundle-jvm): Automatically collect JVM source files with respecting excludes and gitignore Apr 10, 2026
romtsn and others added 3 commits April 10, 2026 12:15
Add .clj and .cljc to JVM extensions. Expand default excludes to cover
Maven (target, .mvn), IDE (.idea, .vscode, .eclipse, .settings, .fleet),
and common output dirs (bin, out, .kotlin).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Include Scala (.scala, .sc), Groovy (.groovy, .gvy, .gy, .gsh),
Gradle (.gradle), Clojure (.clj, .cljs, .cljc, .edn), JRuby (.rb),
and Jython (.py).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Some small suggestions

Sort DEFAULT_EXCLUDES alphabetically. Avoid allocating intermediate
vectors by using Cow and iterator chaining for excludes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
romtsn and others added 3 commits April 13, 2026 17:45
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Split default excludes into two categories:
- Safe excludes (dot-prefixed dirs, node_modules) applied globally
  via walker overrides since they can never be valid JVM package names
- Ambiguous excludes (build, target, bin, out) applied via post-filter
  only when they appear outside of src/ directories

This prevents false exclusion of legitimate packages like
com.example.build while still excluding build output directories
like app/build/generated/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix is_in_ambiguous_build_dir to check for src only in ancestors
*above* the ambiguous directory. Previously, build/src/main/java/Foo.java
would not be excluded because src appeared in the full path, even though
build is the outermost (non-src) directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix is_in_ambiguous_build_dir to check *all* ambiguous directories in
the path, not just the first one found. Previously,
build/src/main/java/com/example/target/Foo.java would be kept because
the inner `target` has `src` above it, even though the outer `build`
does not. Now any ambiguous dir without a src ancestor triggers exclusion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cursor[bot]

This comment was marked as resolved.

- Store SAFE_EXCLUDES as plain names (consistent with AMBIGUOUS_EXCLUDES),
  prepend ! at the call site for all excludes uniformly
- Remove Cow import and ceremony — no longer needed
- Merge filter + map into filter_map to avoid redundant strip_prefix
- Move source.path and source.contents instead of cloning (owned via
  into_iter)
- Trim redundant doc comments

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@romtsn romtsn merged commit f825541 into master Apr 14, 2026
26 checks passed
@romtsn romtsn deleted the rz/feat/bundle-jvm-filtering branch April 14, 2026 15:21
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.

2 participants